Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/188'
Browse files Browse the repository at this point in the history
* 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
matburt committed Mar 16, 2012
2 parents 71723f0 + d1e1a37 commit c76ee75
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 23 deletions.
43 changes: 29 additions & 14 deletions res/xml/preferences.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,14 +38,24 @@
android:summary="@string/summary_agenda_title" android:summary="@string/summary_agenda_title"
android:title="@string/title_agenda_title" /> android:title="@string/title_agenda_title" />
<CheckBoxPreference <CheckBoxPreference
android:key="combineBlockAgendas"
android:dependency="useAgendaTitle" android:dependency="useAgendaTitle"
android:key="combineBlockAgendas"
android:summary="@string/preference_combine_block_agenda_summary" android:summary="@string/preference_combine_block_agenda_summary"
android:title="@string/preference_combine_block_agenda_title" /> android:title="@string/preference_combine_block_agenda_title" />
<CheckBoxPreference <CheckBoxPreference
android:key="viewWrapLines" android:key="viewWrapLines"
android:summary="@string/summary_view_wrap_lines" android:summary="@string/summary_view_wrap_lines"
android:title="@string/title_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 <ListPreference
android:defaultValue="0" android:defaultValue="0"
Expand All @@ -56,14 +66,16 @@
android:title="@string/preference_recursion_level_title" /> android:title="@string/preference_recursion_level_title" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/preference_storage" > <PreferenceCategory android:title="@string/preference_storage" >
<!-- <ListPreference
<!--
<ListPreference
android:defaultValue="internal" android:defaultValue="internal"
android:entries="@array/storageModes" android:entries="@array/storageModes"
android:entryValues="@array/storageModesVals" android:entryValues="@array/storageModesVals"
android:key="storageMode" android:key="storageMode"
android:summary="@string/preference_storage_summary" android:summary="@string/preference_storage_summary"
android:title="@string/preference_storage_title" /> android:title="@string/preference_storage_title" />
--> -->
<CheckBoxPreference <CheckBoxPreference
android:key="captureWithTimestamp" android:key="captureWithTimestamp"
android:summary="@string/summary_capture_with_timestamp" android:summary="@string/summary_capture_with_timestamp"
Expand All @@ -85,46 +97,49 @@
android:key="calendarEnabled" android:key="calendarEnabled"
android:summary="@string/preference_calendar_synch" android:summary="@string/preference_calendar_synch"
android:title="@string/preference_calendar_synch_title" /> android:title="@string/preference_calendar_synch_title" />

<ListPreference <ListPreference
android:defaultValue="" android:defaultValue=""
android:key="calendarName"
android:dependency="calendarEnabled" android:dependency="calendarEnabled"
android:key="calendarName"
android:summary="@string/preference_calendar_name_summary" android:summary="@string/preference_calendar_name_summary"
android:title="@string/preference_calendar_name" /> android:title="@string/preference_calendar_name" />

<CheckBoxPreference <CheckBoxPreference
android:key="calendarShowDone"
android:defaultValue="true" android:defaultValue="true"
android:dependency="calendarEnabled" android:dependency="calendarEnabled"
android:key="calendarShowDone"
android:summary="@string/preference_calendar_show_done_summary" android:summary="@string/preference_calendar_show_done_summary"
android:title="@string/preference_calendar_show_done" /> android:title="@string/preference_calendar_show_done" />
<CheckBoxPreference <CheckBoxPreference
android:key="calendarHabits"
android:defaultValue="true" android:defaultValue="true"
android:dependency="calendarEnabled" android:dependency="calendarEnabled"
android:key="calendarHabits"
android:summary="@string/preference_calendar_show_habits_summary" android:summary="@string/preference_calendar_show_habits_summary"
android:title="@string/preference_calendar_show_habits" /> android:title="@string/preference_calendar_show_habits" />
<CheckBoxPreference <CheckBoxPreference
android:key="calendarReminder"
android:dependency="calendarEnabled" android:dependency="calendarEnabled"
android:key="calendarReminder"
android:summary="@string/preference_calendar_reminder_summary" android:summary="@string/preference_calendar_reminder_summary"
android:title="@string/preference_calendar_reminder" /> android:title="@string/preference_calendar_reminder" />

<EditTextPreference <EditTextPreference
android:dependency="calendarReminder"
android:key="calendarReminderInterval" android:key="calendarReminderInterval"
android:maxLength="3" android:maxLength="3"
android:dependency="calendarReminder"
android:numeric="integer" android:numeric="integer"
android:summary="@string/preference_calendar_reminder_interval_summary" android:summary="@string/preference_calendar_reminder_interval_summary"
android:title="@string/preference_calendar_reminder_interval" /> android:title="@string/preference_calendar_reminder_interval" />

</PreferenceCategory> </PreferenceCategory>

<PreferenceCategory android:title="@string/preference_other" > <PreferenceCategory android:title="@string/preference_other" >
<!-- <PreferenceScreen
<!--
<PreferenceScreen
android:key="Widget" android:key="Widget"
android:summary="@string/preferences_widget_summary" android:summary="@string/preferences_widget_summary"
android:title="@string/preference_widget_title" > android:title="@string/preference_widget_title" >
</PreferenceScreen> --> </PreferenceScreen>
-->
<PreferenceScreen <PreferenceScreen
android:key="VersionDisp" android:key="VersionDisp"
android:summary="0.8.4" android:summary="0.8.4"
Expand Down
27 changes: 24 additions & 3 deletions src/com/matburt/mobileorg/Gui/NodeViewActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ private String convertToHTML() {
text = text.replaceAll("\\n(\\s*\\d+[\\)\\.])", "<br/>\n$1"); // wrap ordered lists text = text.replaceAll("\\n(\\s*\\d+[\\)\\.])", "<br/>\n$1"); // wrap ordered lists


text = text.replaceAll("((\\s*\\|[^\\n]*\\|\\s*(?:<br/>)?\\n)+)", "<pre>$1</pre>"); text = text.replaceAll("((\\s*\\|[^\\n]*\\|\\s*(?:<br/>)?\\n)+)", "<pre>$1</pre>");


Log.d("MobileOrg", text);
text = "<html><body>" + text + "</body></html>"; text = "<html><body>" + text + "</body></html>";
} else { } else {
text = text.replaceAll("\\n", "<br/>\n"); text = text.replaceAll("\\n", "<br/>\n");
Expand All @@ -138,7 +139,6 @@ private String convertToHTML() {


return text; return text;
} }



private String convertLinks(String text) { private String convertLinks(String text) {
Pattern linkPattern = Pattern.compile("\\[\\[([^\\]]*)\\]\\[([^\\]]*)\\]\\]"); Pattern linkPattern = Pattern.compile("\\[\\[([^\\]]*)\\]\\[([^\\]]*)\\]\\]");
Expand Down Expand Up @@ -229,12 +229,33 @@ private String nodeToHTML(NodeWrapper node, int headingLevel) {
result.append("</b></font> <hr />"); result.append("</b></font> <hr />");


if (!node.getCleanedPayload(appInst.getDB()).equals("")) { 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("\n<br/>\n");
} }


result.append("<br/>\n"); result.append("<br/>\n");
return result.toString(); 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;
}


} }
16 changes: 11 additions & 5 deletions src/com/matburt/mobileorg/Gui/OutlineActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -444,12 +444,18 @@ public void onItemClick(AdapterView<?> parent, View v, int position,
return; return;
} }


Long node_id = listView.getItemIdAtPosition(position); Long clicked_node_id = listView.getItemIdAtPosition(position);
lastSelection = position; lastSelection = position;
if (appInst.getDB().hasNodeChildren(node_id)) if (appInst.getDB().hasNodeChildren(clicked_node_id) || node_id == -1)
runExpandSelection(node_id); runExpandSelection(clicked_node_id);
else else {
runEditNodeActivity(node_id); if (PreferenceManager.getDefaultSharedPreferences(
parent.getContext())
.getBoolean("viewDefaultEdit", true))
runEditNodeActivity(clicked_node_id);
else
runViewNodeActivity(clicked_node_id);
}
} }
}; };


Expand Down
6 changes: 5 additions & 1 deletion src/com/matburt/mobileorg/Parsing/NodeWrapper.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ public String getTags() {
if(tagsColumn == -1) if(tagsColumn == -1)
return ""; return "";


return cursor.getString(tagsColumn); String tags = cursor.getString(tagsColumn);
if(tags == null)
return "";

return tags;
} }


/** /**
Expand Down

0 comments on commit c76ee75

Please sign in to comment.