Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added setting to exclude specified tags.

  • Loading branch information...
commit ddfba55648fd99cce07195b81b73308975905f7f 1 parent 11190d6
Henning Weiss hdweiss authored
2  res/values/strings.xml
View
@@ -153,6 +153,8 @@
<string name="preference_ubuntuone_path_summary">UbuntuOne path to index.org file</string>
<string name="preference_clear_db_dialog_title">Clear DB?</string>
<string name="preference_clear_db_dialog_message">Are you sure want to clear DB?</string>
+ <string name="preference_exclude_tags">Exclude tags inheritance</string>
+ <string name="preference_exclude_tags_summary">Tags separated by \":\" to exclude from inheritance.</string>
<string name="preference_combine_block_agenda_summary">Combines block agendas into one node, with separators. Needs resync of agenda file to take effect</string>
<string name="preference_combine_block_agenda_title">Combine block agendas</string>
<string name="preference_calendar">Calendar</string>
8 res/xml/preferences.xml
View
@@ -2,8 +2,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/preference_synchronization" >
- <Preference
- android:title="@string/rerun_setup_wizard" >
+ <Preference android:title="@string/rerun_setup_wizard" >
<intent android:action="com.matburt.mobileorg.Settings.SETUP_WIZARD" />
</Preference>
@@ -57,6 +56,11 @@
android:entryValues="@array/viewRecursionLevelsVals"
android:key="viewRecursionMax"
android:title="@string/preference_recursion_level_title" />
+
+ <EditTextPreference
+ android:key="excludeTagsInheritance"
+ android:summary="@string/preference_exclude_tags_summary"
+ android:title="@string/preference_exclude_tags" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/preference_storage" >
<CheckBoxPreference
24 src/com/matburt/mobileorg/OrgData/OrgFileParser.java
View
@@ -4,6 +4,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -28,6 +29,7 @@
private StringBuilder payload;
private OrgFile orgFile;
private OrgNodeParser orgNodeParser;
+ private HashSet<String> excludedTags;
public OrgFileParser(OrgDatabase db, ContentResolver resolver) {
this.db = db;
@@ -50,6 +52,8 @@ private void init(OrgFile orgFile) {
public void parse(OrgFile orgFile, BufferedReader breader, Context context) {
this.combineAgenda = OrgUtils.getCombineBlockAgendas(context);
+ this.excludedTags = OrgUtils.getExcludedTags(context);
+
parse(orgFile, breader);
}
@@ -126,7 +130,25 @@ public ParseStack() {
public void add(int level, long nodeId, String tags) {
parseStack.push(new Pair<Integer, Long>(level, nodeId));
- tagStack.push(tags);
+ tagStack.push(stripTags(tags));
+ }
+
+ private String stripTags(String tags) {
+ if (excludedTags == null || TextUtils.isEmpty(tags))
+ return tags;
+
+ StringBuilder result = new StringBuilder();
+ for (String tag: tags.split(":")) {
+ if (excludedTags.contains(tag) == false) {
+ result.append(tag);
+ result.append(":");
+ }
+ }
+
+ if(!TextUtils.isEmpty(result))
+ result.deleteCharAt(result.lastIndexOf(":"));
+
+ return result.toString();
}
public void pop() {
17 src/com/matburt/mobileorg/util/OrgUtils.java
View
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
+import java.util.HashSet;
import android.app.Activity;
import android.content.ContentResolver;
@@ -64,6 +65,22 @@ public static boolean isSyncConfigured(Context context) {
return true;
}
+ public static HashSet<String> getExcludedTags(Context context) {
+ String tags = PreferenceManager.getDefaultSharedPreferences(context).getString(
+ "excludeTagsInheritance", null);
+
+ if (tags == null)
+ return null;
+
+ HashSet<String> tagsSet = new HashSet<String>();
+ for (String tag: tags.split(":")) {
+ if(TextUtils.isEmpty(tag) == false)
+ tagsSet.add(tag);
+ }
+
+ return tagsSet;
+ }
+
public static boolean getCombineBlockAgendas(Context context) {
try {
return PreferenceManager.getDefaultSharedPreferences(context)
Please sign in to comment.
Something went wrong with that request. Please try again.