Skip to content
This repository
Browse code

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...
commit c76ee75047086f1efc6ed880fe6d50afa3a1e8a2 2 parents 71723f0 + d1e1a37
Matthew Jones authored
43 res/xml/preferences.xml
@@ -38,14 +38,24 @@
38 38 android:summary="@string/summary_agenda_title"
39 39 android:title="@string/title_agenda_title" />
40 40 <CheckBoxPreference
41   - android:key="combineBlockAgendas"
42 41 android:dependency="useAgendaTitle"
  42 + android:key="combineBlockAgendas"
43 43 android:summary="@string/preference_combine_block_agenda_summary"
44 44 android:title="@string/preference_combine_block_agenda_title" />
45 45 <CheckBoxPreference
46 46 android:key="viewWrapLines"
47 47 android:summary="@string/summary_view_wrap_lines"
48 48 android:title="@string/title_view_wrap_lines" />
  49 + <CheckBoxPreference
  50 + android:defaultValue="true"
  51 + android:key="viewDefaultEdit"
  52 + android:summary="When checked, the default behaviour for clicking on nodes without children will be editing. Else it will be viewing."
  53 + android:title="Edit on click" />
  54 + <CheckBoxPreference
  55 + android:defaultValue="true"
  56 + android:key="viewApplyFormating"
  57 + android:summary="Apply formating of orgmode emphasis, bold, underline and strike-through when viewing."
  58 + android:title="Apply view formating" />
49 59
50 60 <ListPreference
51 61 android:defaultValue="0"
@@ -56,14 +66,16 @@
56 66 android:title="@string/preference_recursion_level_title" />
57 67 </PreferenceCategory>
58 68 <PreferenceCategory android:title="@string/preference_storage" >
59   - <!-- <ListPreference
  69 +
  70 + <!--
  71 + <ListPreference
60 72 android:defaultValue="internal"
61 73 android:entries="@array/storageModes"
62 74 android:entryValues="@array/storageModesVals"
63 75 android:key="storageMode"
64 76 android:summary="@string/preference_storage_summary"
65 77 android:title="@string/preference_storage_title" />
66   - -->
  78 + -->
67 79 <CheckBoxPreference
68 80 android:key="captureWithTimestamp"
69 81 android:summary="@string/summary_capture_with_timestamp"
@@ -85,46 +97,49 @@
85 97 android:key="calendarEnabled"
86 98 android:summary="@string/preference_calendar_synch"
87 99 android:title="@string/preference_calendar_synch_title" />
88   -
  100 +
89 101 <ListPreference
90 102 android:defaultValue=""
91   - android:key="calendarName"
92 103 android:dependency="calendarEnabled"
  104 + android:key="calendarName"
93 105 android:summary="@string/preference_calendar_name_summary"
94 106 android:title="@string/preference_calendar_name" />
  107 +
95 108 <CheckBoxPreference
96   - android:key="calendarShowDone"
97 109 android:defaultValue="true"
98 110 android:dependency="calendarEnabled"
  111 + android:key="calendarShowDone"
99 112 android:summary="@string/preference_calendar_show_done_summary"
100   - android:title="@string/preference_calendar_show_done" />
  113 + android:title="@string/preference_calendar_show_done" />
101 114 <CheckBoxPreference
102   - android:key="calendarHabits"
103 115 android:defaultValue="true"
104 116 android:dependency="calendarEnabled"
  117 + android:key="calendarHabits"
105 118 android:summary="@string/preference_calendar_show_habits_summary"
106 119 android:title="@string/preference_calendar_show_habits" />
107 120 <CheckBoxPreference
108   - android:key="calendarReminder"
109 121 android:dependency="calendarEnabled"
  122 + android:key="calendarReminder"
110 123 android:summary="@string/preference_calendar_reminder_summary"
111 124 android:title="@string/preference_calendar_reminder" />
  125 +
112 126 <EditTextPreference
  127 + android:dependency="calendarReminder"
113 128 android:key="calendarReminderInterval"
114 129 android:maxLength="3"
115   - android:dependency="calendarReminder"
116 130 android:numeric="integer"
117 131 android:summary="@string/preference_calendar_reminder_interval_summary"
118 132 android:title="@string/preference_calendar_reminder_interval" />
119   -
120 133 </PreferenceCategory>
121   -
122 134 <PreferenceCategory android:title="@string/preference_other" >
123   - <!-- <PreferenceScreen
  135 +
  136 + <!--
  137 + <PreferenceScreen
124 138 android:key="Widget"
125 139 android:summary="@string/preferences_widget_summary"
126 140 android:title="@string/preference_widget_title" >
127   - </PreferenceScreen> -->
  141 + </PreferenceScreen>
  142 + -->
128 143 <PreferenceScreen
129 144 android:key="VersionDisp"
130 145 android:summary="0.8.4"
27 src/com/matburt/mobileorg/Gui/NodeViewActivity.java
@@ -129,7 +129,8 @@ private String convertToHTML() {
129 129 text = text.replaceAll("\\n(\\s*\\d+[\\)\\.])", "<br/>\n$1"); // wrap ordered lists
130 130
131 131 text = text.replaceAll("((\\s*\\|[^\\n]*\\|\\s*(?:<br/>)?\\n)+)", "<pre>$1</pre>");
132   -
  132 +
  133 + Log.d("MobileOrg", text);
133 134 text = "<html><body>" + text + "</body></html>";
134 135 } else {
135 136 text = text.replaceAll("\\n", "<br/>\n");
@@ -138,7 +139,6 @@ private String convertToHTML() {
138 139
139 140 return text;
140 141 }
141   -
142 142
143 143 private String convertLinks(String text) {
144 144 Pattern linkPattern = Pattern.compile("\\[\\[([^\\]]*)\\]\\[([^\\]]*)\\]\\]");
@@ -229,12 +229,33 @@ private String nodeToHTML(NodeWrapper node, int headingLevel) {
229 229 result.append("</b></font> <hr />");
230 230
231 231 if (!node.getCleanedPayload(appInst.getDB()).equals("")) {
232   - result.append(node.getCleanedPayload(appInst.getDB()));
  232 + String payload = node.getCleanedPayload(appInst.getDB());
  233 + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
  234 + "viewApplyFormating", true))
  235 + payload = applyFormating(payload);
  236 + result.append(payload);
233 237 result.append("\n<br/>\n");
234 238 }
235 239
236 240 result.append("<br/>\n");
237 241 return result.toString();
238 242 }
  243 +
  244 + private String getFormatingRegex(String character, String tag, String text) {
  245 + return text.replaceAll(
  246 + "(\\s)\\" + character +
  247 + "(\\S[\\S\\s]*\\S)" +
  248 + "\\" + character + "(\\s)"
  249 + , "$1<" + tag + ">$2</" + tag + ">$3");
  250 + }
  251 +
  252 + private String applyFormating(String text) {
  253 + text = getFormatingRegex("*", "b", text);
  254 + text = getFormatingRegex("/", "i", text);
  255 + text = getFormatingRegex("_", "u", text);
  256 + text = getFormatingRegex("+", "strike", text);
  257 +
  258 + return text;
  259 + }
239 260
240 261 }
16 src/com/matburt/mobileorg/Gui/OutlineActivity.java
@@ -444,12 +444,18 @@ public void onItemClick(AdapterView<?> parent, View v, int position,
444 444 return;
445 445 }
446 446
447   - Long node_id = listView.getItemIdAtPosition(position);
  447 + Long clicked_node_id = listView.getItemIdAtPosition(position);
448 448 lastSelection = position;
449   - if (appInst.getDB().hasNodeChildren(node_id))
450   - runExpandSelection(node_id);
451   - else
452   - runEditNodeActivity(node_id);
  449 + if (appInst.getDB().hasNodeChildren(clicked_node_id) || node_id == -1)
  450 + runExpandSelection(clicked_node_id);
  451 + else {
  452 + if (PreferenceManager.getDefaultSharedPreferences(
  453 + parent.getContext())
  454 + .getBoolean("viewDefaultEdit", true))
  455 + runEditNodeActivity(clicked_node_id);
  456 + else
  457 + runViewNodeActivity(clicked_node_id);
  458 + }
453 459 }
454 460 };
455 461
6 src/com/matburt/mobileorg/Parsing/NodeWrapper.java
@@ -127,7 +127,11 @@ public String getTags() {
127 127 if(tagsColumn == -1)
128 128 return "";
129 129
130   - return cursor.getString(tagsColumn);
  130 + String tags = cursor.getString(tagsColumn);
  131 + if(tags == null)
  132 + return "";
  133 +
  134 + return tags;
131 135 }
132 136
133 137 /**

0 comments on commit c76ee75

Please sign in to comment.
Something went wrong with that request. Please try again.