Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #285 from matburt/expandable_outline

Expandable outline bug fixes & theme support
  • Loading branch information...
commit 2c6075cb7dfae900423e94be946fea2426eb4ad3 2 parents 5c61e34 + 68bc4e0
@matburt authored
Showing with 467 additions and 223 deletions.
  1. +1 −1  AndroidManifest.xml
  2. +1 −0  res/drawable/border.xml
  3. +13 −0 res/drawable/outline_item_selected.xml
  4. +0 −5 res/drawable/outline_selection.xml
  5. +0 −1  res/layout/edit.xml
  6. +1 −0  res/layout/edit_payload.xml
  7. +26 −21 res/layout/timeclock_notification.xml
  8. +5 −0 res/menu/outline_file.xml
  9. +6 −1 res/values/arrays.xml
  10. +1 −4 res/values/strings.xml
  11. +15 −2 res/values/themes.xml
  12. +7 −5 res/xml/preferences.xml
  13. +1 −1  src/com/matburt/mobileorg/Gui/Capture/DatesFragment.java
  14. +19 −3 src/com/matburt/mobileorg/Gui/Capture/EditActivity.java
  15. +10 −1 src/com/matburt/mobileorg/Gui/Capture/HeadingFragment.java
  16. +20 −11 src/com/matburt/mobileorg/Gui/Capture/PayloadFragment.java
  17. +1 −1  src/com/matburt/mobileorg/Gui/Capture/TagsFragment.java
  18. +2 −0  src/com/matburt/mobileorg/Gui/CertificateConflictActivity.java
  19. +1 −0  src/com/matburt/mobileorg/Gui/Outline/OutlineActivity.java
  20. +7 −1 src/com/matburt/mobileorg/Gui/Outline/OutlineAdapter.java
  21. +1 −1  src/com/matburt/mobileorg/Gui/Outline/OutlineItem.java
  22. +34 −14 src/com/matburt/mobileorg/Gui/Outline/OutlineListView.java
  23. +12 −4 src/com/matburt/mobileorg/Gui/SearchActivity.java
  24. +20 −3 src/com/matburt/mobileorg/Gui/Theme/DefaultTheme.java
  25. +4 −2 src/com/matburt/mobileorg/Gui/Theme/MonoTheme.java
  26. +4 −0 src/com/matburt/mobileorg/Gui/Theme/WhiteTheme.java
  27. +1 −0  src/com/matburt/mobileorg/Gui/ViewActivity.java
  28. +9 −2 src/com/matburt/mobileorg/Gui/ViewFragment.java
  29. +18 −26 src/com/matburt/mobileorg/OrgData/OrgFileParser.java
  30. +0 −57 src/com/matburt/mobileorg/OrgData/OrgNode.java
  31. +74 −0 src/com/matburt/mobileorg/OrgData/OrgNodeParser.java
  32. +17 −17 src/com/matburt/mobileorg/Services/CalendarSyncService.java
  33. +1 −0  src/com/matburt/mobileorg/Settings/SettingsActivity.java
  34. +2 −0  src/com/matburt/mobileorg/Settings/WizardActivity.java
  35. +8 −4 src/com/matburt/mobileorg/util/OrgNode2Html.java
  36. +30 −5 src/com/matburt/mobileorg/util/OrgUtils.java
  37. +20 −0 tests/src/com/matburt/mobileorg/test/OrgData/OrgFileParserTest.java
  38. +61 −27 tests/src/com/matburt/mobileorg/test/OrgData/OrgNodeParserTest.java
  39. +14 −3 tests/src/com/matburt/mobileorg/test/util/OrgTestFiles.java
View
2  AndroidManifest.xml
@@ -18,7 +18,7 @@
android:debuggable="true"
android:icon="@drawable/icon"
android:label="MobileOrg"
- android:theme="@style/Theme.Styled" >
+ android:theme="@style/Theme.MobileOrg.Dark" >
<meta-data
android:name="android.app.default_searchable"
android:value=".Gui.SearchActivity" />
View
1  res/drawable/border.xml
@@ -2,4 +2,5 @@
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="#ADADAD" />
<corners android:radius="5dp" />
+ <solid android:color="@android:color/transparent" />
</shape>
View
13 res/drawable/outline_item_selected.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle" >
+
+ <stroke
+ android:width="1px"
+ android:color="#ADADAD" />
+
+ <corners android:radius="2px" />
+
+ <solid android:color="@android:color/transparent" />
+
+</shape>
View
5 res/drawable/outline_selection.xml
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
- <stroke android:width="1px" android:color="#ADADAD" />
- <corners android:radius="2px" />
-</shape>
View
1  res/layout/edit.xml
@@ -4,7 +4,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:background="#00000000"
android:scrollbars="vertical" >
<LinearLayout
View
1  res/layout/edit_payload.xml
@@ -15,6 +15,7 @@
android:id="@+id/edit_payload_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_below="@+id/edit_payload_save"
android:visibility="gone" >
</EditText>
View
47 res/layout/timeclock_notification.xml
@@ -1,32 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="@+id/timeclock_notification_icon"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_alignParentLeft="true" />
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_alignParentLeft="true"
+ android:layout_marginRight="5dp"
+ android:contentDescription="Icon"
+ android:scaleType="fitCenter"
+ android:src="@drawable/icon"
+ tools:ignore="HardcodedText" />
- <RelativeLayout
+ <TextView
+ android:id="@+id/timeclock_notification_text"
+ style="@android:style/TextAppearance.Small"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_toRightOf="@id/timeclock_notification_icon" >
-
- <TextView
- android:id="@+id/timeclock_notification_text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true" />
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_marginRight="5dp"
+ android:layout_marginTop="3dp"
+ android:layout_toRightOf="@id/timeclock_notification_icon" />
- <TextView
- android:id="@+id/timeclock_notification_time"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentRight="true" />
- </RelativeLayout>
+ <TextView
+ android:id="@+id/timeclock_notification_time"
+ style="@android:style/TextAppearance.Small"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true" />
</RelativeLayout>
View
5 res/menu/outline_file.xml
@@ -23,6 +23,11 @@
android:showAsAction="ifRoom"
android:title="@string/menu_delete_file"/>
<item
+ android:id="@+id/menu_clockin"
+ android:icon="@drawable/ic_menu_today"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_clockin"/>
+ <item
android:id="@+id/menu_recover"
android:icon="@drawable/ic_menu_archive"
android:showAsAction="ifRoom"
View
7 res/values/arrays.xml
@@ -61,5 +61,10 @@
<item>3 levels of recursion</item>
<item>4 levels of recursion</item>
</string-array>
+ <string-array name="themes">
+ <item>Light</item>
+ <item>Dark</item>
+ <item>Monochrome</item>
+ </string-array>
-</resources>
+</resources>
View
5 res/values/strings.xml
@@ -169,8 +169,7 @@
<string name="preference_calendar_show_habits">Show habits</string>
<string name="preference_calendar_show_done_summary">Show done items in the calendar</string>
<string name="preference_calendar_show_done">Show done</string>
- <string name="preference_fullscreen_title">Fullscreen</string>
- <string name="preference_fullscreen_summary">Toggle fullscreen.</string>
+ <string name="preference_theme_title">Theme</string>
<string name="preference_capture_advanced_title">Advanced capture</string>
<string name="preference_capture_advanced">Advanced capturing mechanism that allows capturing files under arbitrary headings.</string>
<string name="edit_date_start">Start</string>
@@ -184,8 +183,6 @@
<string name="example_webURL">http://example.com/index.org</string>
<string name="rerun_setup_wizard">Re-run setup wizard</string>
<string name="configure_synchronizer_settings">Synchronizer settings</string>
- <string name="summary_view_default_edit">When checked, the default behaviour for long clicking on nodes will be editing. If disabled, the default behavior will be viewing.</string>
- <string name="title_view_default_edit">Edit on long click</string>
<string name="summary_view_apply_formatting">Apply formatting of orgmode emphasis, bold, underline and strike-through when viewing.</string>
<string name="title_view_apply_formatting">Apply view formatting</string>
<string name="title_scp_host">Host</string>
View
17 res/values/themes.xml
@@ -1,11 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="Theme.Styled" parent="Theme.Sherlock">
+
+ <style name="Theme.MobileOrg.Dark" parent="Theme.Sherlock">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
- <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
+ <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>
+
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar.Solid">
<item name="background">@drawable/actionbar_background</item>
<item name="android:background">@drawable/actionbar_background</item>
</style>
+
+ <style name="Theme.MobileOrg.Light" parent="Theme.Sherlock.Light.DarkActionBar">
+ <item name="actionBarStyle">@style/Widget.Styled.ActionBar.Light</item>
+ <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar.Light</item>
+ </style>
+
+ <style name="Widget.Styled.ActionBar.Light" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
+ <item name="background">@drawable/actionbar_background</item>
+ <item name="android:background">@drawable/actionbar_background</item>
+ </style>
+
</resources>
View
12 res/xml/preferences.xml
@@ -33,6 +33,13 @@
android:title="@string/title_auto_sync_interval" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/preference_viewing" >
+ <ListPreference
+ android:defaultValue="Dark"
+ android:entries="@array/themes"
+ android:entryValues="@array/themes"
+ android:key="theme"
+ android:title="@string/preference_theme_title" />
+
<CheckBoxPreference
android:key="combineBlockAgendas"
android:summary="@string/preference_combine_block_agenda_summary"
@@ -43,11 +50,6 @@
android:title="@string/title_view_wrap_lines" />
<CheckBoxPreference
android:defaultValue="true"
- android:key="viewDefaultEdit"
- android:summary="@string/summary_view_default_edit"
- android:title="@string/title_view_default_edit" />
- <CheckBoxPreference
- android:defaultValue="true"
android:key="viewApplyFormatting"
android:summary="@string/summary_view_apply_formatting"
android:title="@string/title_view_apply_formatting" />
View
2  src/com/matburt/mobileorg/Gui/Capture/DatesFragment.java
@@ -68,7 +68,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
else
setupDates();
- setModifable(editActivity.isNodeModifiable());
+ setModifable(editActivity.isPayloadEditable());
editActivity.invalidateOptionsMenu();
}
View
22 src/com/matburt/mobileorg/Gui/Capture/EditActivity.java
@@ -13,6 +13,7 @@
import com.actionbarsherlock.view.MenuItem;
import com.matburt.mobileorg.R;
import com.matburt.mobileorg.OrgData.OrgEdit;
+import com.matburt.mobileorg.OrgData.OrgFile;
import com.matburt.mobileorg.OrgData.OrgNode;
import com.matburt.mobileorg.OrgData.OrgProviderUtils;
import com.matburt.mobileorg.Services.SyncService;
@@ -40,9 +41,11 @@
@Override
public void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
-
setContentView(R.layout.edit);
+ getSupportActionBar().setTitle(R.string.menu_capture);
+
this.resolver = getContentResolver();
SyncService.stopAlarm(this); // Don't run background sync while editing node
@@ -123,10 +126,23 @@ public OrgNode getOrgNode() {
return this.node;
}
- public boolean isNodeModifiable() {
+ public String getActionMode() {
+ return this.actionMode;
+ }
+
+ public boolean isNodeEditable() {
return getOrgNode().isNodeEditable(resolver);
}
+ public boolean isPayloadEditable() {
+ OrgNode node = getOrgNode();
+
+ if(node.level == 0 && !node.name.equals(OrgFile.AGENDA_FILE_ALIAS))
+ return true;
+ else
+ return isNodeEditable();
+ }
+
public boolean isNodeRefilable() {
if(this.actionMode.equals(ACTIONMODE_CREATE))
return false;
@@ -138,7 +154,7 @@ public boolean isNodeRefilable() {
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.edit, menu);
- if(isNodeModifiable() == false)
+ if(isNodeEditable() == false)
menu.findItem(R.id.nodeedit_save).setVisible(false);
return super.onCreateOptionsMenu(menu);
View
11 src/com/matburt/mobileorg/Gui/Capture/HeadingFragment.java
@@ -5,6 +5,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
@@ -55,7 +56,15 @@ public void onActivityCreated(Bundle savedInstanceState) {
else
updateDisplay(this.node);
- setModifiable(activity.isNodeModifiable());
+ setModifiable(activity.isNodeEditable());
+
+ String actionMode = activity.getActionMode();
+
+ if(actionMode.equals(EditActivity.ACTIONMODE_ADDCHILD) || actionMode.equals(EditActivity.ACTIONMODE_CREATE)) {
+ this.titleView.requestFocus();
+ getActivity().getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
}
@Override
View
31 src/com/matburt/mobileorg/Gui/Capture/PayloadFragment.java
@@ -1,10 +1,12 @@
package com.matburt.mobileorg.Gui.Capture;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.EditText;
@@ -29,12 +31,6 @@
private OnPayloadModifiedListener mListener;
- public interface OnPayloadModifiedListener {
- public void onPayloadStartedEdit();
- public void onPayloadEndedEdit();
- public void onPayloadModified();
- }
-
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
@@ -89,8 +85,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
else
switchToView();
- if(editActivity.isNodeModifiable() == false)
- setUnmodifiable();
+ setModifiable(editActivity.isPayloadEditable());
}
@Override
@@ -112,8 +107,11 @@ public void restoreInstanceState(Bundle savedInstanceState) {
}
}
- public void setUnmodifiable() {
- this.editButton.setVisibility(View.GONE);
+ public void setModifiable(boolean enabled) {
+ if(enabled)
+ this.editButton.setVisibility(View.VISIBLE);
+ else
+ this.editButton.setVisibility(View.GONE);
}
public void setPayload(String payload) {
@@ -132,9 +130,9 @@ private void switchToEdit(String payloadString) {
if(payloadString != null)
payloadEdit.setText(payloadString);
- payloadEdit.setVisibility(View.VISIBLE);
cancelButton.setVisibility(View.VISIBLE);
saveButton.setVisibility(View.VISIBLE);
+ payloadEdit.setVisibility(View.VISIBLE);
mListener.onPayloadStartedEdit();
}
@@ -158,6 +156,10 @@ public void switchToView() {
public void onClick(View v) {
switchToEdit();
payloadEdit.requestFocus();
+ payloadEdit.setSelection(payloadEdit.length());
+ InputMethodManager keyboard = (InputMethodManager)
+ getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ keyboard.showSoftInput(payloadEdit, 0);
}
};
@@ -179,4 +181,11 @@ public void onClick(View v) {
webView.requestFocus();
}
};
+
+
+ public interface OnPayloadModifiedListener {
+ public void onPayloadStartedEdit();
+ public void onPayloadEndedEdit();
+ public void onPayloadModified();
+ }
}
View
2  src/com/matburt/mobileorg/Gui/Capture/TagsFragment.java
@@ -52,7 +52,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
setupTagEntries(node.getTags());
}
- setModifiable(activity.isNodeModifiable());
+ setModifiable(activity.isNodeEditable());
activity.invalidateOptionsMenu();
}
View
2  src/com/matburt/mobileorg/Gui/CertificateConflictActivity.java
@@ -10,6 +10,7 @@
import android.widget.TextView;
import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.util.OrgUtils;
public class CertificateConflictActivity extends Activity {
@@ -19,6 +20,7 @@
private Button deny_button;
public void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.certconflict);
View
1  src/com/matburt/mobileorg/Gui/Outline/OutlineActivity.java
@@ -40,6 +40,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
View
8 src/com/matburt/mobileorg/Gui/Outline/OutlineAdapter.java
@@ -27,7 +27,7 @@ public OutlineAdapter(Context context) {
super(context, R.layout.outline_item);
this.resolver = context.getContentResolver();
- this.theme = new DefaultTheme();
+ this.theme = DefaultTheme.getTheme(context);
init();
}
@@ -131,6 +131,12 @@ public void remove(OrgNode node) {
super.remove(node);
}
+ public boolean getExpanded(int position) {
+ if(position < 0 || position > this.expanded.size())
+ return false;
+
+ return this.expanded.get(position);
+ }
public void collapseExpand(int position) {
if(position >= getCount() || position >= this.expanded.size() || position < 0)
View
2  src/com/matburt/mobileorg/Gui/Outline/OutlineItem.java
@@ -166,7 +166,7 @@ public boolean isChecked() {
@Override
public void setChecked(boolean checked) {
if(checked)
- setBackgroundResource(R.drawable.outline_selection);
+ setBackgroundResource(R.drawable.outline_item_selected);
else
setBackgroundResource(0);
}
View
48 src/com/matburt/mobileorg/Gui/Outline/OutlineListView.java
@@ -29,10 +29,16 @@ public OutlineListView(Context context, AttributeSet atts) {
setOnItemClickListener(outlineClickListener);
setOnItemLongClickListener(outlineLongClickListener);
this.actionMode = new OutlineActionMode(context);
- this.adapter = new OutlineAdapter(context);
- setAdapter(adapter);
+ setAdapter(new OutlineAdapter(context));
}
+
+ public void setAdapter(OutlineAdapter adapter) {
+ this.adapter = adapter;
+ super.setAdapter(adapter);
+ }
+
+
public void setActivity(SherlockActivity activity) {
this.activity = activity;
this.context = activity;
@@ -100,21 +106,35 @@ private void setParentChecked(int position) {
public void collapseCurrent() {
int position = getCheckedItemPosition();
-
- if(position != ListView.INVALID_POSITION) {
- if(adapter.getItem(position).level == 0) {
+
+ if (position == ListView.INVALID_POSITION)
+ return;
+
+ if (adapter.getExpanded(position)) // Item is expanded, collapse it
+ adapter.collapseExpand(position);
+ else {
+ if(adapter.getItem(position).level == 0) { // Top level, collapse all entries
adapter.init();
setItemChecked(position, false);
- return;
- }
-
- int parent = adapter.findParent(position);
-
- if(parent >= 0) {
- adapter.collapseExpand(parent);
- setItemChecked(parent, true);
- setSelection(parent - 2);
+ } else { // Collapse parent
+ int parent = adapter.findParent(position);
+
+ if (parent >= 0) {
+ adapter.collapseExpand(parent);
+ setItemChecked(parent, true);
+ }
}
}
+
+ ensureCheckedItemVisible();
+ }
+
+ public void ensureCheckedItemVisible() {
+ int position = getCheckedItemPosition();
+ if(position == ListView.INVALID_POSITION)
+ return;
+
+ if(!(getLastVisiblePosition() >= position && getFirstVisiblePosition() <= position))
+ setSelection(position - 2);
}
}
View
16 src/com/matburt/mobileorg/Gui/SearchActivity.java
@@ -13,6 +13,7 @@
import com.matburt.mobileorg.Gui.Outline.OutlineListView;
import com.matburt.mobileorg.OrgData.OrgNode;
import com.matburt.mobileorg.OrgData.OrgProviderUtils;
+import com.matburt.mobileorg.util.OrgUtils;
public class SearchActivity extends SherlockActivity {
@@ -21,11 +22,14 @@
@Override
public void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
this.listView = (OutlineListView) findViewById(R.id.search_list);
this.listAdapter = (OutlineAdapter) listView.getAdapter();
+ listAdapter.clear();
+
listView.setActivity(this);
Intent intent = getIntent();
handleIntent(intent);
@@ -51,11 +55,15 @@ private void doSearch(String query) {
ArrayList<OrgNode> data = OrgProviderUtils
.orgDataCursorToArrayList(result);
- listAdapter.clear();
- listAdapter.addAll(data);
-
- getSupportActionBar().setTitle(
+ if(result.getCount() == 0) {
+ getSupportActionBar().setTitle(
+ "No results found for " + " \"" + query.trim()
+ + "\"");
+ } else {
+ listAdapter.insertAll(data, 0);
+ getSupportActionBar().setTitle(
getString(R.string.search_results_for) + " \"" + query.trim()
+ "\"");
+ }
}
}
View
23 src/com/matburt/mobileorg/Gui/Theme/DefaultTheme.java
@@ -1,5 +1,8 @@
package com.matburt.mobileorg.Gui.Theme;
+import com.matburt.mobileorg.util.OrgUtils;
+
+import android.content.Context;
import android.graphics.Color;
public class DefaultTheme {
@@ -23,7 +26,21 @@
public int ceLCyan = Color.rgb(0x00, 0xff, 0xff);
public int cfLWhite = Color.rgb(0xff, 0xff, 0xff);
- public final int[] levelColors = new int[] { ccLBlue, c3Yellow, ceLCyan,
- c2Green, c5Purple, ccLBlue, c2Green, ccLBlue, c3Yellow,
- ceLCyan };
+ public int[] levelColors;
+
+ public DefaultTheme() {
+ levelColors = new int[] { ccLBlue, c3Yellow, ceLCyan, c2Green,
+ c5Purple, ccLBlue, c2Green, ccLBlue, c3Yellow, ceLCyan };
+ }
+
+
+ public static DefaultTheme getTheme(Context context) {
+ final String themeName = OrgUtils.getThemeName(context);
+ if(themeName.equals("Light"))
+ return new WhiteTheme();
+ else if(themeName.equals("Monochrome"))
+ return new MonoTheme();
+ else
+ return new DefaultTheme();
+ }
}
View
6 src/com/matburt/mobileorg/Gui/Theme/MonoTheme.java
@@ -7,7 +7,7 @@
public MonoTheme() {
super();
c0Black = Color.rgb(0xff, 0xff, 0xff);
- c1Red = Color.rgb(0x00, 0x00, 0x00);
+ c1Red = Color.rgb(0xd0, 0x00, 0x00);
c2Green = Color.rgb(0x00, 0x00, 0x00);
c3Yellow = Color.rgb(0x00, 0x00, 0x00);
c4Blue = Color.rgb(0x00, 0x00, 0x00);
@@ -16,11 +16,13 @@ public MonoTheme() {
c7White = Color.rgb(0x00, 0x00, 0x00);
c9LRed = Color.rgb(0x00, 0x00, 0x00);
- caLGreen = Color.rgb(0x00, 0x00, 0x00);
+ caLGreen = Color.rgb(0x77, 0xff, 0x77);
cbLYellow = Color.rgb(0x00, 0x00, 0x00);
ccLBlue = Color.rgb(0x00, 0x00, 0x00);
cdLPurple = Color.rgb(0x00, 0x00, 0x00);
ceLCyan = Color.rgb(0x00, 0x00, 0x00);
cfLWhite = Color.rgb(0x00, 0x00, 0x00);
+
+ levelColors = new int[] { cfLWhite };
}
}
View
4 src/com/matburt/mobileorg/Gui/Theme/WhiteTheme.java
@@ -22,5 +22,9 @@ public WhiteTheme() {
cdLPurple = Color.rgb(0x80, 0x00, 0x80);
ceLCyan = Color.rgb(0x00, 0x80, 0x80);
cfLWhite = Color.rgb(0x00, 0x00, 0x00);
+
+ levelColors = new int[] { ccLBlue, c3Yellow, ceLCyan, c2Green,
+ c5Purple, ccLBlue, c2Green, ccLBlue, c3Yellow, ceLCyan };
+
}
}
View
1  src/com/matburt/mobileorg/Gui/ViewActivity.java
@@ -24,6 +24,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
View
11 src/com/matburt/mobileorg/Gui/ViewFragment.java
@@ -62,13 +62,20 @@ public void displayPayload(OrgNode node) {
public void display(OrgNode node, int levelOfRecursion, ContentResolver resolver) {
OrgNode2Html htmlNode = new OrgNode2Html(resolver);
- htmlNode.setupConfig(getActivity());
+ htmlNode.setupConfig(getActivity(), getFontColor());
String html = htmlNode.toHTML(node, levelOfRecursion);
displayHtml(html);
}
+ private String getFontColor() {
+ if(OrgUtils.isThemeLight(getActivity()))
+ return "black";
+ else
+ return "white";
+ }
+
public void displayError() {
- String html = "<html><body><font color='white'>"
+ String html = "<html><body><font color='" + getFontColor() + "'>"
+ getString(R.string.node_view_error_loading_node)
+ "</font></body></html>";
displayHtml(html);
View
44 src/com/matburt/mobileorg/OrgData/OrgFileParser.java
@@ -4,20 +4,19 @@
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;
-import com.matburt.mobileorg.OrgData.OrgContract.OrgData;
-import com.matburt.mobileorg.util.OrgFileNotFoundException;
-import com.matburt.mobileorg.util.OrgUtils;
-
import android.content.ContentResolver;
import android.content.Context;
import android.text.TextUtils;
import android.util.Pair;
+import com.matburt.mobileorg.OrgData.OrgContract.OrgData;
+import com.matburt.mobileorg.util.OrgFileNotFoundException;
+import com.matburt.mobileorg.util.OrgUtils;
+
public class OrgFileParser {
private ContentResolver resolver;
@@ -28,7 +27,7 @@
private ParseStack parseStack;
private StringBuilder payload;
private OrgFile orgFile;
- private HashSet<String> todos;
+ private OrgNodeParser orgNodeParser;
public OrgFileParser(OrgDatabase db, ContentResolver resolver) {
this.db = db;
@@ -42,10 +41,11 @@ private void init(OrgFile orgFile) {
this.parseStack = new ParseStack();
this.parseStack.add(0, orgFile.nodeId);
-
- this.todos = new HashSet<String>(OrgProviderUtils.getTodos(resolver));
this.payload = new StringBuilder();
+
+ this.orgNodeParser = new OrgNodeParser(
+ OrgProviderUtils.getTodos(resolver));
}
public void parse(OrgFile orgFile, BufferedReader breader, Context context) {
@@ -89,7 +89,6 @@ private void parseLine(String line) {
}
}
-
private void parseHeading(String thisLine, int numstars) {
if (numstars == parseStack.getCurrentLevel()) { // Node on same level
parseStack.pop();
@@ -98,30 +97,22 @@ private void parseHeading(String thisLine, int numstars) {
parseStack.pop();
}
- final OrgNode node = new OrgNode();
- node.parseLine(thisLine, numstars, this.todos);
+ OrgNode node = this.orgNodeParser.parseLine(thisLine, numstars);
node.fileId = orgFile.id;
node.parentId = parseStack.getCurrentNodeId();
long newId = db.fastInsertNode(node);
parseStack.add(numstars, newId);
}
- // TODO Replace with Regex matching
+ private static final Pattern starPattern = Pattern.compile("^(\\**)");
private static int numberOfStars(String thisLine) {
- int numstars = 0;
- int lineLength = thisLine.length();
-
- for (int idx = 0; idx < lineLength; idx++) {
- if (thisLine.charAt(idx) != '*')
- break;
- numstars++;
- }
-
- if (numstars >= lineLength || thisLine.charAt(numstars) != ' ')
- numstars = 0;
-
- return numstars;
+ Matcher matcher = starPattern.matcher(thisLine);
+ if(matcher.find()) {
+ return matcher.end(1) - matcher.start(1);
+ } else
+ return 0;
}
+
private class ParseStack {
private Stack<Pair<Integer, Long>> parseStack;
@@ -146,7 +137,8 @@ public long getCurrentNodeId() {
return parseStack.peek().second;
}
}
-
+
+
public static final String BLOCK_SEPARATOR_PREFIX = "#HEAD#";
private void combineBlockAgendas() throws OrgFileNotFoundException {
OrgNode agendaFile = OrgProviderUtils.getOrgNodeFromFilename(
View
57 src/com/matburt/mobileorg/OrgData/OrgNode.java
@@ -1,16 +1,13 @@
package com.matburt.mobileorg.OrgData;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
-import android.util.Log;
import com.matburt.mobileorg.Gui.Outline.OutlineItem;
import com.matburt.mobileorg.OrgData.OrgContract.OrgData;
@@ -500,60 +497,6 @@ public void generateApplyWriteEdits(OrgNode newNode, String olpPath, ContentReso
return edits;
}
-
-
- public void parseLine(String thisLine, int numstars, HashSet<String> todos) {
- String heading = thisLine.substring(numstars+1);
- this.level = numstars;
-
- Matcher matcher = titlePattern.matcher(heading);
- if (matcher.find()) {
- if (matcher.group(TODO_GROUP) != null) {
- if (todos.contains(matcher.group(TODO_GROUP)))
- todo = matcher.group(TODO_GROUP);
- else
- name = matcher.group(TODO_GROUP);
- }
-
- if (matcher.group(PRIORITY_GROUP) != null)
- priority = matcher.group(PRIORITY_GROUP);
-
- // TODO This should be done in regex
- if(TextUtils.isEmpty(name) && matcher.group(TITLE_GROUP).length() > 1)
- name = matcher.group(TITLE_GROUP).substring(1);
- else
- name += matcher.group(TITLE_GROUP);
-
-
- if(matcher.group(AFTER_GROUP) != null)
- name = matcher.group(AFTER_GROUP).trim() + ">" + name.trim();
-
- tags = matcher.group(TAGS_GROUP);
- if (tags == null)
- tags = "";
-
- } else {
- Log.w("MobileOrg", "Title not matched: " + heading);
- name = heading;
- }
- }
-
- private static final int TODO_GROUP = 1;
- private static final int PRIORITY_GROUP = 2;
- private static final int TITLE_GROUP = 3;
- private static final int TAGS_GROUP = 4;
- private static final int AFTER_GROUP = 7;
-
- private static final Pattern titlePattern = Pattern
- .compile("^\\s?([\\w_]+)?" + // Todo keyword
- "(?:\\[\\#([^]]+)\\])?" + // Priority
- "(.*?)" + // Title
- "\\s*" + "(?::([^\\s]+):)?" + // Tags (without trailing spaces)
- "(\\s*[!\\*])*" + // Habits
- "(<before>.*</before>)?" + // Before
- "(?:<after>.*TITLE:(.*)</after>)?" + // After
- "$"); // End of line
-
public String toString() {
StringBuilder result = new StringBuilder();
View
74 src/com/matburt/mobileorg/OrgData/OrgNodeParser.java
@@ -0,0 +1,74 @@
+package com.matburt.mobileorg.OrgData;
+
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import android.util.Log;
+
+public class OrgNodeParser {
+ private static final int TODO_GROUP = 1;
+ private static final int PRIORITY_GROUP = 2;
+ private static final int NAME_GROUP = 3;
+ private static final int TAGS_GROUP = 4;
+ private static final int AFTER_GROUP = 5;
+
+ private Pattern pattern;
+
+ private static final String patternStart = "^\\s?";
+ private static final String patternEnd = "(?:\\[\\#([^]]+)\\]\\s)?" + // Priority
+ "(.*?)" + // Title
+ "\\s*" + "(?::([^\\s]+):)?" + // Tags (without trailing spaces)
+ "(?:\\s*[!\\*])*" + // Habits
+ "(?:<before>.*</before>)?" + // Before
+ "(?:<after>.*TITLE:(.*)</after>)?" + // After
+ "$"; // End of line
+
+ public OrgNodeParser(ArrayList<String> todos) {
+ final String patternString = patternStart + "(?:("
+ + getTodoRegex(todos) + ")\\s)?" + patternEnd;
+ this.pattern = Pattern.compile(patternString);
+ }
+
+ private String getTodoRegex(ArrayList<String> todos) {
+ if (todos.isEmpty())
+ return "";
+
+ StringBuilder result = new StringBuilder();
+ for (String todo : todos)
+ result.append(todo).append("|");
+ result.deleteCharAt(result.length() - 1);
+
+ return result.toString();
+ }
+
+ public OrgNode parseLine(final String line, int numberOfStars) {
+ OrgNode node = new OrgNode();
+ node.level = numberOfStars;
+
+ Matcher matcher = pattern.matcher(line);
+ matcher.region(numberOfStars + 1, line.length());
+ if (matcher.find()) {
+ if (matcher.group(TODO_GROUP) != null)
+ node.todo = matcher.group(TODO_GROUP);
+
+ node.name = matcher.group(NAME_GROUP);
+
+ if (matcher.group(PRIORITY_GROUP) != null)
+ node.priority = matcher.group(PRIORITY_GROUP);
+
+ if (matcher.group(TAGS_GROUP) != null)
+ node.tags = matcher.group(TAGS_GROUP);
+
+ if (matcher.group(AFTER_GROUP) != null)
+ node.name = matcher.group(AFTER_GROUP).trim()
+ + ">" + node.name.trim();
+
+ } else {
+ Log.w("MobileOrg", "Title not matched: " + line);
+ node.name = line;
+ }
+
+ return node;
+ }
+}
View
34 src/com/matburt/mobileorg/Services/CalendarSyncService.java
@@ -57,13 +57,16 @@ public CalendarSyncService(ContentResolver resolver, Context context) {
}
private void refreshPreferences() {
- String intervalString = sharedPreferences.getString("calendarReminderInterval", null);
- if(intervalString == null)
- throw new IllegalArgumentException("Invalid calendar reminder interval");
- this.reminderTime = Integer.valueOf(intervalString);
-
this.reminderEnabled = sharedPreferences.getBoolean(
"calendarReminder", false);
+
+ if(reminderEnabled) {
+ String intervalString = sharedPreferences.getString("calendarReminderInterval", "0");
+ if(intervalString == null)
+ throw new IllegalArgumentException("Invalid calendar reminder interval");
+ this.reminderTime = Integer.valueOf(intervalString);
+ }
+
this.showDone = sharedPreferences.getBoolean("calendarShowDone", true);
this.showHabits = sharedPreferences.getBoolean("calendarHabits", true);
this.calendarName = PreferenceManager
@@ -105,7 +108,8 @@ public int deleteFileEntries(String filename, Context context) {
public CharSequence[] getCalendars(Context context) {
- CharSequence[] result;
+ CharSequence[] result = new CharSequence[1];
+ result[0] = context.getString(R.string.error_setting_no_calendar);
try {
Cursor cursor = context.getContentResolver().query(
@@ -113,28 +117,24 @@ public int deleteFileEntries(String filename, Context context) {
new String[] { intCalendars._ID,
intCalendars.CALENDAR_DISPLAY_NAME }, null, null,
null);
-
+ if(cursor == null)
+ return result;
+
if (cursor.getCount() == 0) {
- result = new CharSequence[1];
- result[0] = context
- .getString(R.string.error_setting_no_calendar);
cursor.close();
return result;
}
- result = new CharSequence[cursor.getCount()];
-
- if (cursor != null && cursor.moveToFirst()) {
+ if (cursor.moveToFirst()) {
+ result = new CharSequence[cursor.getCount()];
+
for (int i = 0; i < cursor.getCount(); i++) {
result[i] = cursor.getString(1);
cursor.moveToNext();
}
}
cursor.close();
- } catch (SQLException e) {
- result = new CharSequence[1];
- result[0] = context.getString(R.string.error_setting_no_calendar);
- }
+ } catch (SQLException e) {}
return result;
}
View
1  src/com/matburt/mobileorg/Settings/SettingsActivity.java
@@ -42,6 +42,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
Intent prefsIntent = getIntent();
View
2  src/com/matburt/mobileorg/Settings/WizardActivity.java
@@ -39,6 +39,7 @@
import com.matburt.mobileorg.Synchronizers.UbuntuOneSynchronizer;
import com.matburt.mobileorg.Synchronizers.WebDAVSynchronizer;
import com.matburt.mobileorg.Views.PageFlipView;
+import com.matburt.mobileorg.util.OrgUtils;
public class WizardActivity extends Activity {
@@ -120,6 +121,7 @@ public void handleMessage(Message msg)
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
+ OrgUtils.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.wizard);
wizard = (PageFlipView) findViewById(R.id.wizard_parent);
View
12 src/com/matburt/mobileorg/util/OrgNode2Html.java
@@ -16,15 +16,19 @@
public boolean wrapLines = false;
public boolean viewApplyFormating = true;
+ private String fontColor = "white";
+
public OrgNode2Html(ContentResolver resolver) {
this.resolver = resolver;
}
- public void setupConfig(Context context) {
+ public void setupConfig(Context context, String fontColor) {
this.wrapLines = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean("viewWrapLines", false);
this.viewApplyFormating = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"viewApplyFormating", true);
+
+ this.fontColor = fontColor;
}
public String toHTML(OrgNode node) {
@@ -46,7 +50,7 @@ public String payloadToHTML(OrgNode node) {
private String convertToHTML(String text) {
if(text == null || text.trim().equals(""))
- return "<html><body><font color='white'><pre>" + text + "</pre></font></body></html>";
+ return "<html><body><font color='" + fontColor + "'><pre>" + text + "</pre></font></body></html>";
text = convertLinks(text);
@@ -58,10 +62,10 @@ private String convertToHTML(String text) {
text = text.replaceAll("((\\s*\\|[^\\n]*\\|\\s*(?:<br/>)?\\n)+)", "<pre>$1</pre>");
- text = "<html><body><font color='white'>" + text + "</font></body></html>";
+ text = "<html><body><font color='" + fontColor + "'>" + text + "</font></body></html>";
} else {
text = text.replaceAll("\\n", "<br/>\n");
- text = "<html><body><font color='white'><pre>" + text + "</pre></font></body></html>";
+ text = "<html><body><font color='" + fontColor + "'><pre>" + text + "</pre></font></body></html>";
}
return text;
View
35 src/com/matburt/mobileorg/util/OrgUtils.java
@@ -9,11 +9,7 @@
import java.util.Comparator;
import java.util.Date;
-import com.matburt.mobileorg.R;
-import com.matburt.mobileorg.OrgData.OrgFile;
-import com.matburt.mobileorg.OrgData.OrgNode;
-import com.matburt.mobileorg.Synchronizers.Synchronizer;
-
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -24,6 +20,11 @@
import android.widget.ArrayAdapter;
import android.widget.Spinner;
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.OrgData.OrgFile;
+import com.matburt.mobileorg.OrgData.OrgNode;
+import com.matburt.mobileorg.Synchronizers.Synchronizer;
+
public class OrgUtils {
public static String getTimestamp() {
@@ -185,4 +186,28 @@ public int compare(Object o1, Object o2) {
return s1.toLowerCase().compareTo(s2.toLowerCase());
}
}
+
+ public static String getThemeName(Context context) {
+ SharedPreferences appSettings =
+ PreferenceManager.getDefaultSharedPreferences(context);
+ return appSettings.getString("theme", "Dark");
+ }
+
+ public static void setTheme(Activity activity) {
+ String themeName = getThemeName(activity);
+
+ if(themeName.equals("Dark"))
+ activity.setTheme(R.style.Theme_MobileOrg_Dark);
+ else
+ activity.setTheme(R.style.Theme_MobileOrg_Light);
+ }
+
+ public static boolean isThemeLight(Context context) {
+ String themeName = getThemeName(context);
+
+ if(themeName.equals("Dark"))
+ return false;
+ else
+ return true;
+ }
}
View
20 tests/src/com/matburt/mobileorg/test/OrgData/OrgFileParserTest.java
@@ -18,6 +18,7 @@
import com.matburt.mobileorg.OrgData.OrgProvider;
import com.matburt.mobileorg.OrgData.OrgProviderUtils;
import com.matburt.mobileorg.test.util.OrgTestFiles;
+import com.matburt.mobileorg.test.util.OrgTestFiles.OrgIndexWithFileDirectorySpaces;
import com.matburt.mobileorg.test.util.OrgTestFiles.SimpleOrgFiles;
import com.matburt.mobileorg.test.util.OrgTestUtils;
import com.matburt.mobileorg.util.OrgNodeNotFoundException;
@@ -111,6 +112,25 @@ public void testGetFilesFromIndex() {
}
}
+ public void testGetFilesFromIndexWithSpaces() {
+ final String filename = OrgIndexWithFileDirectorySpaces.filename;
+ final String fileAlias = OrgIndexWithFileDirectorySpaces.fileAlias;
+ HashMap<String,String> files = OrgFileParser.getFilesFromIndex(OrgIndexWithFileDirectorySpaces.indexFile);
+
+ assertTrue(files.containsKey(filename));
+ String retrievedFileAlias = files.get(filename);
+ assertEquals(fileAlias, retrievedFileAlias);
+ }
+
+ public void testGetFilesFromIndexWithSpacesWithoutAlias() {
+ final String filename = OrgIndexWithFileDirectorySpaces.filenameWithoutAlias;
+ HashMap<String,String> files = OrgFileParser.getFilesFromIndex(OrgIndexWithFileDirectorySpaces.indexFile);
+
+ assertTrue(files.containsKey(filename));
+ String retrievedFileAlias = files.get(filename);
+ assertEquals(filename, retrievedFileAlias);
+ }
+
public void testGetTodosFromIndex() {
ArrayList<String> tagsFromIndex = OrgFileParser.getTagsFromIndex(SimpleOrgFiles.indexFile);
View
88 tests/src/com/matburt/mobileorg/test/OrgData/OrgNodeParserTest.java
@@ -1,10 +1,11 @@
package com.matburt.mobileorg.test.OrgData;
-import java.util.HashSet;
+import java.util.ArrayList;
import android.test.AndroidTestCase;
import com.matburt.mobileorg.OrgData.OrgNode;
+import com.matburt.mobileorg.OrgData.OrgNodeParser;
public class OrgNodeParserTest extends AndroidTestCase {
public void testParseLineIntoNodeSimple() {
@@ -12,10 +13,10 @@ public void testParseLineIntoNodeSimple() {
node.name = "my simple test";
node.todo = "";
node.level = 3;
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** my simple test";
- HashSet<String> todos = new HashSet<String>();
- parsedNode.parseLine(testHeading, 3, todos);
+
+ OrgNodeParser orgNodeParser = new OrgNodeParser( new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
assertEquals(node.todo, parsedNode.todo);
assertEquals(node.name, parsedNode.name);
@@ -26,27 +27,29 @@ public void testParseLineIntoNodeWithTodo() {
node.name = "my simple test";
node.todo = "TODO";
node.level = 3;
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** TODO my simple test";
- HashSet<String> todos = new HashSet<String>();
+
+ ArrayList<String> todos = new ArrayList<String>();
todos.add(node.todo);
- parsedNode.parseLine(testHeading, 3, todos);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(todos);
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
assertEquals(node.todo, parsedNode.todo);
assertEquals(node.name, parsedNode.name);
}
-
+
public void testParseLineIntoNodeInvalidTodo() {
OrgNode node = new OrgNode();
node.name = "BLA my simple test";
node.todo = "";
node.level = 3;
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** BLA my simple test";
- HashSet<String> todos = new HashSet<String>();
- parsedNode.parseLine(testHeading, 3, todos);
- assertTrue(node.equals(parsedNode));
+ OrgNodeParser orgNodeParser = new OrgNodeParser( new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
+
+ assertEquals(node.todo, parsedNode.todo);
+ assertEquals(node.name, parsedNode.name);
}
public void testParseLineIntoNodeComplicatedTodo() {
@@ -54,14 +57,47 @@ public void testParseLineIntoNodeComplicatedTodo() {
node.name = "my simple test";
node.todo = "find_me";
node.level = 3;
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** find_me my simple test";
- HashSet<String> todos = new HashSet<String>();
+
+ ArrayList<String> todos = new ArrayList<String>();
+ todos.add(node.todo);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(todos);
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
+
+ assertEquals(node.todo, parsedNode.todo);
+ assertEquals(node.name, parsedNode.name);
+ }
+
+ public void testParseLineIntoNodeLinkTitle() {
+ OrgNode node = new OrgNode();
+ node.name = "[[MobileOrg][MobileOrg]]";
+ node.todo = "";
+ node.level = 3;
+ final String testHeading = "*** [[MobileOrg][MobileOrg]]";
+
+ OrgNodeParser orgNodeParser = new OrgNodeParser(new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
+
+ assertEquals(node.todo, parsedNode.todo);
+ assertEquals(node.name, parsedNode.name);
+ }
+
+ public void testParseLineIntoNodePriority() {
+ OrgNode node = new OrgNode();
+ node.name = "my todo";
+ node.todo = "TODO";
+ node.priority = "A";
+ node.level = 3;
+ final String testHeading = "*** TODO [#A] my todo";
+
+ ArrayList<String> todos = new ArrayList<String>();
todos.add(node.todo);
- parsedNode.parseLine(testHeading, 3, todos);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(todos);
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
assertEquals(node.todo, parsedNode.todo);
assertEquals(node.name, parsedNode.name);
+ assertEquals(node.priority, parsedNode.priority);
}
public void testParseLineIntoNodeTags() {
@@ -69,10 +105,10 @@ public void testParseLineIntoNodeTags() {
node.name = "Archive";
node.level = 3;
node.tags = "tag1:tag2";
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** Archive :tag1:tag2:";
- HashSet<String> todos = new HashSet<String>();
- parsedNode.parseLine(testHeading, 3, todos);
+
+ OrgNodeParser orgNodeParser = new OrgNodeParser(new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
assertEquals(node.todo, parsedNode.todo);
assertEquals(node.tags, parsedNode.tags);
@@ -85,11 +121,11 @@ public void testParseLineIntoNodeWithSimpleScheduled() {
node.name = "my simple test";
node.todo = "TODO";
node.level = 3;
- OrgNode parsedNode = new OrgNode();
final String testHeading = "*** TODO my simple test";
- HashSet<String> todos = new HashSet<String>();
+ ArrayList<String> todos = new ArrayList<String>();
todos.add(node.todo);
- parsedNode.parseLine(testHeading, 3, todos);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(todos);
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 3);
assertEquals(node.todo, parsedNode.todo);
assertEquals(node.name, parsedNode.name);
@@ -98,10 +134,9 @@ public void testParseLineIntoNodeWithSimpleScheduled() {
public void testParseLineIntoNodeAgendaTitle() {
final String expectedTitle = "Home Core>Home";
final String testHeading = "* Home <after>KEYS=h#2 TITLE: Home Core</after>";
- HashSet<String> todos = new HashSet<String>();
- OrgNode parsedNode = new OrgNode();
- parsedNode.parseLine(testHeading, 1, todos);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 1);
assertEquals(expectedTitle, parsedNode.name);
}
@@ -109,10 +144,9 @@ public void testParseLineIntoNodeAgendaTitle() {
public void testParseLineIntoNodeAgendaTitleWithoutSpace() {
final String expectedTitle = "Home Core>Agenda";
final String testHeading = "* Agenda<after>KEYS=h#2 TITLE: Home Core</after>";
- HashSet<String> todos = new HashSet<String>();
- OrgNode parsedNode = new OrgNode();
- parsedNode.parseLine(testHeading, 1, todos);
+ OrgNodeParser orgNodeParser = new OrgNodeParser(new ArrayList<String>());
+ OrgNode parsedNode = orgNodeParser.parseLine(testHeading, 1);
assertEquals(expectedTitle, parsedNode.name);
}
View
17 tests/src/com/matburt/mobileorg/test/util/OrgTestFiles.java
@@ -33,9 +33,8 @@
+ "#+TODO: TODO NEXT PLAN RSCH GOAL DEFERRED WAIT | SOMEDAY CANC DONE\n"
+ "#+TAGS: { Home Computer Online Phone Errands } { Agenda Read Listen Watch Code }\n"
+ "#+ALLPRIORITIES: A B C\n"
- + "* [[file:agendas.org][Agenda Views]]\n"
- + "* [[file:GTD.org][GTD.org]]\n";
-
+ + "* [[file:agendas.org][Agenda Views]]\n";
+
public static final String checksumsFile = "25aade750f6b60aa1df155fcbb357191 index.org\n"
+ "42055316a0808ad634d7981653cf4400faddb91f GTD.org\n"
+ "c864f7e1d6df18434738276a45c896cb agendas.org";
@@ -43,4 +42,16 @@
public static final String orgFile = "* new\n** test";
public static final String agendasFile = "* new 1\n** test2";
}
+
+ public static class OrgIndexWithFileDirectorySpaces {
+ public static final String fileAlias = "Mixed Todo.org";
+ public static final String filename = "Mixed Activities/Mixed Todo.org";
+ public static final String filenameWithoutAlias = "Mixed Activities/Mixed Todo.org";
+ public static final String indexFile = "#+READONLY\n"
+ + "#+TODO: TODO | DONE\n"
+ + "#+TAGS: { Home Computer Errands } \n"
+ + "#+ALLPRIORITIES: A B C\n"
+ + "* [[file:" + filename + "][" + fileAlias + "]]\n"
+ + "* [[file:" + filenameWithoutAlias + "][" + filenameWithoutAlias + "]]";
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.