Permalink
Browse files

Merge remote-tracking branch 'origin/188'

* origin/188:
  Added optional formating in view node, fixing issue #188.
  Fixed issue #192, added preference for selecting default handling of child-less nodes.
  • Loading branch information...
2 parents 71723f0 + d1e1a37 commit c76ee75047086f1efc6ed880fe6d50afa3a1e8a2 @matburt committed Mar 16, 2012
View
@@ -38,14 +38,24 @@
android:summary="@string/summary_agenda_title"
android:title="@string/title_agenda_title" />
<CheckBoxPreference
- android:key="combineBlockAgendas"
android:dependency="useAgendaTitle"
+ android:key="combineBlockAgendas"
android:summary="@string/preference_combine_block_agenda_summary"
android:title="@string/preference_combine_block_agenda_title" />
<CheckBoxPreference
android:key="viewWrapLines"
android:summary="@string/summary_view_wrap_lines"
android:title="@string/title_view_wrap_lines" />
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:key="viewDefaultEdit"
+ android:summary="When checked, the default behaviour for clicking on nodes without children will be editing. Else it will be viewing."
+ android:title="Edit on click" />
+ <CheckBoxPreference
+ android:defaultValue="true"
+ android:key="viewApplyFormating"
+ android:summary="Apply formating of orgmode emphasis, bold, underline and strike-through when viewing."
+ android:title="Apply view formating" />
<ListPreference
android:defaultValue="0"
@@ -56,14 +66,16 @@
android:title="@string/preference_recursion_level_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/preference_storage" >
- <!-- <ListPreference
+
+ <!--
+ <ListPreference
android:defaultValue="internal"
android:entries="@array/storageModes"
android:entryValues="@array/storageModesVals"
android:key="storageMode"
android:summary="@string/preference_storage_summary"
android:title="@string/preference_storage_title" />
- -->
+ -->
<CheckBoxPreference
android:key="captureWithTimestamp"
android:summary="@string/summary_capture_with_timestamp"
@@ -85,46 +97,49 @@
android:key="calendarEnabled"
android:summary="@string/preference_calendar_synch"
android:title="@string/preference_calendar_synch_title" />
-
+
<ListPreference
android:defaultValue=""
- android:key="calendarName"
android:dependency="calendarEnabled"
+ android:key="calendarName"
android:summary="@string/preference_calendar_name_summary"
android:title="@string/preference_calendar_name" />
+
<CheckBoxPreference
- android:key="calendarShowDone"
android:defaultValue="true"
android:dependency="calendarEnabled"
+ android:key="calendarShowDone"
android:summary="@string/preference_calendar_show_done_summary"
- android:title="@string/preference_calendar_show_done" />
+ android:title="@string/preference_calendar_show_done" />
<CheckBoxPreference
- android:key="calendarHabits"
android:defaultValue="true"
android:dependency="calendarEnabled"
+ android:key="calendarHabits"
android:summary="@string/preference_calendar_show_habits_summary"
android:title="@string/preference_calendar_show_habits" />
<CheckBoxPreference
- android:key="calendarReminder"
android:dependency="calendarEnabled"
+ android:key="calendarReminder"
android:summary="@string/preference_calendar_reminder_summary"
android:title="@string/preference_calendar_reminder" />
+
<EditTextPreference
+ android:dependency="calendarReminder"
android:key="calendarReminderInterval"
android:maxLength="3"
- android:dependency="calendarReminder"
android:numeric="integer"
android:summary="@string/preference_calendar_reminder_interval_summary"
android:title="@string/preference_calendar_reminder_interval" />
-
</PreferenceCategory>
-
<PreferenceCategory android:title="@string/preference_other" >
- <!-- <PreferenceScreen
+
+ <!--
+ <PreferenceScreen
android:key="Widget"
android:summary="@string/preferences_widget_summary"
android:title="@string/preference_widget_title" >
- </PreferenceScreen> -->
+ </PreferenceScreen>
+ -->
<PreferenceScreen
android:key="VersionDisp"
android:summary="0.8.4"
@@ -129,7 +129,8 @@ private String convertToHTML() {
text = text.replaceAll("\\n(\\s*\\d+[\\)\\.])", "<br/>\n$1"); // wrap ordered lists
text = text.replaceAll("((\\s*\\|[^\\n]*\\|\\s*(?:<br/>)?\\n)+)", "<pre>$1</pre>");
-
+
+ Log.d("MobileOrg", text);
text = "<html><body>" + text + "</body></html>";
} else {
text = text.replaceAll("\\n", "<br/>\n");
@@ -138,7 +139,6 @@ private String convertToHTML() {
return text;
}
-
private String convertLinks(String text) {
Pattern linkPattern = Pattern.compile("\\[\\[([^\\]]*)\\]\\[([^\\]]*)\\]\\]");
@@ -229,12 +229,33 @@ private String nodeToHTML(NodeWrapper node, int headingLevel) {
result.append("</b></font> <hr />");
if (!node.getCleanedPayload(appInst.getDB()).equals("")) {
- result.append(node.getCleanedPayload(appInst.getDB()));
+ String payload = node.getCleanedPayload(appInst.getDB());
+ if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
+ "viewApplyFormating", true))
+ payload = applyFormating(payload);
+ result.append(payload);
result.append("\n<br/>\n");
}
result.append("<br/>\n");
return result.toString();
}
+
+ private String getFormatingRegex(String character, String tag, String text) {
+ return text.replaceAll(
+ "(\\s)\\" + character +
+ "(\\S[\\S\\s]*\\S)" +
+ "\\" + character + "(\\s)"
+ , "$1<" + tag + ">$2</" + tag + ">$3");
+ }
+
+ private String applyFormating(String text) {
+ text = getFormatingRegex("*", "b", text);
+ text = getFormatingRegex("/", "i", text);
+ text = getFormatingRegex("_", "u", text);
+ text = getFormatingRegex("+", "strike", text);
+
+ return text;
+ }
}
@@ -444,12 +444,18 @@ public void onItemClick(AdapterView<?> parent, View v, int position,
return;
}
- Long node_id = listView.getItemIdAtPosition(position);
+ Long clicked_node_id = listView.getItemIdAtPosition(position);
lastSelection = position;
- if (appInst.getDB().hasNodeChildren(node_id))
- runExpandSelection(node_id);
- else
- runEditNodeActivity(node_id);
+ if (appInst.getDB().hasNodeChildren(clicked_node_id) || node_id == -1)
+ runExpandSelection(clicked_node_id);
+ else {
+ if (PreferenceManager.getDefaultSharedPreferences(
+ parent.getContext())
+ .getBoolean("viewDefaultEdit", true))
+ runEditNodeActivity(clicked_node_id);
+ else
+ runViewNodeActivity(clicked_node_id);
+ }
}
};
@@ -127,7 +127,11 @@ public String getTags() {
if(tagsColumn == -1)
return "";
- return cursor.getString(tagsColumn);
+ String tags = cursor.getString(tagsColumn);
+ if(tags == null)
+ return "";
+
+ return tags;
}
/**

0 comments on commit c76ee75

Please sign in to comment.