Permalink
Browse files

Merge pull request #186 from matburt/edit

Edit improvements
  • Loading branch information...
2 parents 00c5fbf + d11c8c1 commit 57779350a2fb79e499af0f7ddde04384002cbaad @matburt committed Mar 11, 2012
View
5 res/layout/edit_details.xml
@@ -29,21 +29,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:contentDescription=""
+ android:contentDescription="@string/todo_state"
android:src="@drawable/ic_menu_agenda" />
<Spinner
android:id="@+id/todo_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
+ android:layout_marginTop="0dp"
android:prompt="@string/todo_state" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:contentDescription=""
+ android:contentDescription="@string/todo_state"
android:src="@drawable/ic_menu_star" />
<Spinner
View
8 res/layout/edit_spinner_layout.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/spinnerTarget"
+ style="?android:attr/dropDownItemStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="40dp"
+ android:color="#000000" />
View
3 res/layout/edit_tagsrow.xml
@@ -7,11 +7,12 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:contentDescription=""
+ android:contentDescription="@string/tags"
android:src="@drawable/ic_menu_tag" />
<Spinner
android:id="@+id/editnode_tag_list"
+ android:prompt="@string/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="" />
View
1 res/menu/outline_contextmenu.xml
@@ -12,7 +12,6 @@
android:title="@string/contextmenu_delete"/>
<item
android:id="@+id/contextmenu_capturechild"
- android:visible="false"
android:title="Capture child"/>
<item
android:id="@+id/contextmenu_node_delete"
View
1 res/menu/outline_menu.xml
@@ -18,7 +18,6 @@
<item
android:id="@+id/menu_capturechild"
android:icon="@drawable/ic_menu_add"
- android:visible="false"
android:title="Capture node as child"/>
<item
android:id="@+id/menu_search"
View
7 setup.sh
@@ -0,0 +1,7 @@
+git submodule init
+git submodule update
+
+android update project --path . --library libs/ActionBarSherlock/library/ -l libs/locale/
+
+android update lib-project --path libs/locale/
+android update lib-project --path libs/ActionBarSherlock/library/
View
12 src/com/matburt/mobileorg/Gui/Capture/DateTableRow.java
@@ -218,16 +218,18 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
int startTimeOfDay = timeDateContainer.startTimeOfDay;
int startMinute = timeDateContainer.startMinute;
- if ((timeOfDay == -1 || minute == -1)
- && (startTimeOfDay != -1 && startMinute != -1)) {
+ if ((timeOfDay == -1 || minute == -1)) {
+ if (startTimeOfDay != -1 && startMinute != -1) {
timeOfDay = startTimeOfDay + 1;
minute = startMinute;
if(timeOfDay > 23)
timeOfDay = 0;
- } else {
- timeOfDay = 12;
- minute = 0;
+ }
+ else {
+ timeOfDay = 12;
+ minute = 0;
+ }
}
return new TimePickerDialog(getActivity(), callback, timeOfDay,
View
88 src/com/matburt/mobileorg/Gui/Capture/EditActivity.java
@@ -3,8 +3,6 @@
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -16,7 +14,6 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
-import android.text.TextUtils;
import android.view.MenuInflater;
import com.matburt.mobileorg.R;
@@ -69,9 +66,9 @@ public void onCreate(Bundle savedInstanceState) {
}
init();
+
setupActionbarTabs(savedInstanceState);
}
-
@Override
protected void onSaveInstanceState(Bundle outState) {
@@ -100,7 +97,11 @@ private void init() {
if (this.actionMode == null) {
String subject = intent
.getStringExtra("android.intent.extra.SUBJECT");
+ if(subject == null)
+ subject = "";
String text = intent.getStringExtra("android.intent.extra.TEXT");
+ if(text == null)
+ text = "";
node = new NodeWrapper(null);
this.detailsFragment.init(this.node, this.actionMode, defaultTodo, subject);
@@ -198,6 +199,7 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
+ doCancel();
return true;
case R.id.nodeedit_save:
@@ -242,36 +244,11 @@ public void onClick(DialogInterface dialog, int id) {
});
builder.create().show();
}
-
- private StringBuilder insertOrReplace(StringBuilder payloadResidue,
- String key, String value) {
- final Pattern schedulePattern = Pattern.compile(key + "\\s*<[^>]+>");
- Matcher matcher = schedulePattern.matcher(payloadResidue);
-
- if (matcher.find()) {
- if (TextUtils.isEmpty(value))
- payloadResidue.delete(matcher.start(), matcher.end());
- else
- payloadResidue.replace(matcher.start(), matcher.end(), value);
- }
- else if(TextUtils.isEmpty(value) == false)
- payloadResidue.insert(0, value).append("\n");
-
- return payloadResidue;
- }
- private StringBuilder getNewPayloadResidue() {
- StringBuilder result = new StringBuilder();
-
- StringBuilder originalPayloadResidue = new StringBuilder(node.getPayloadResidue(orgDB));
-
- String newScheduled = this.detailsFragment.getScheduled();
- String newDeadline = this.detailsFragment.getDeadline();
-
- result = insertOrReplace(originalPayloadResidue, "SCHEDULED:", newScheduled);
- result = insertOrReplace(result, "DEADLINE:", newDeadline);
-
- return result;
+
+ private void insertChangesIntoPayloadResidue() {
+ node.getPayload(orgDB).insertOrReplace("SCHEDULED:", detailsFragment.getScheduled());
+ node.getPayload(orgDB).insertOrReplace("DEADLINE:", detailsFragment.getDeadline());
}
private void save() {
@@ -280,7 +257,8 @@ private void save() {
String newPriority = this.detailsFragment.getPriority();
String newTags = this.detailsFragment.getTags();
StringBuilder newCleanedPayload = new StringBuilder(this.payloadFragment.getText());
- StringBuilder newPayloadResidue = getNewPayloadResidue();
+ insertChangesIntoPayloadResidue();
+ String newPayloadResidue = node.getPayload(orgDB).getNewPayloadResidue();
if (this.actionMode.equals(ACTIONMODE_CREATE)) {
MobileOrgApplication appInst = (MobileOrgApplication) this.getApplication();
@@ -294,7 +272,11 @@ private void save() {
if(addTimestamp)
newCleanedPayload.append("\n").append(getTimestamp()).append("\n");
- orgDB.addNodePayload(node_id, newCleanedPayload.toString() + newPayloadResidue.toString());
+ orgDB.addNodePayload(node_id, newCleanedPayload.toString() + newPayloadResidue);
+
+ if(PreferenceManager.getDefaultSharedPreferences(
+ this).getBoolean("calendarEnabled", false))
+ appInst.getCalendarSyncService().insertNode(node_id);
} else if (this.actionMode.equals(ACTIONMODE_ADDCHILD)) {
MobileOrgApplication appInst = (MobileOrgApplication) this.getApplication();
@@ -308,14 +290,18 @@ private void save() {
if(addTimestamp)
newCleanedPayload.append("\n").append(getTimestamp()).append("\n");
- orgDB.addNodePayload(node_id, newCleanedPayload.toString() + newPayloadResidue.toString());
+ orgDB.addNodePayload(node_id, newCleanedPayload.toString() + newPayloadResidue);
+
+ makeNewheadingEditNode(node_id, new NodeWrapper(parent, orgDB));
- } else if (this.actionMode.equals(ACTIONMODE_EDIT)) {
+ if(PreferenceManager.getDefaultSharedPreferences(
+ this).getBoolean("calendarEnabled", false))
+ appInst.getCalendarSyncService().insertNode(node_id);
+ } else if (this.actionMode.equals(ACTIONMODE_EDIT)) {
try {
- editNode(newTitle, newTodo, newPriority,
- newCleanedPayload.toString(),
- newPayloadResidue.toString(), newTags);
+ makeEditNodes(newTitle, newTodo, newPriority,
+ newCleanedPayload.toString(), newTags);
} catch (IOException e) {
}
}
@@ -325,13 +311,23 @@ private void save() {
sendBroadcast(intent);
}
+ private void makeNewheadingEditNode(long node_id, NodeWrapper parent) {
+ boolean generateEdits = !parent.getFileName(orgDB).equals(OrgFile.CAPTURE_FILE);
+ if(generateEdits == false)
+ return;
+
+ // Add new heading nodes need the entire content of node without star headings
+ String newContent = orgDB.nodeToString(node_id, 1).replaceFirst("[\\*]*", "");
+ orgDB.addEdit("newheading", parent.getNodeId(orgDB), parent.getName(), "", newContent);
+ }
+
/**
* Takes a Node and five strings, representing edits to the node.
* This function will generate a new edit entry for each value that was
* changed.
*/
- private void editNode(String newTitle, String newTodo,
- String newPriority, String newCleanedPayload, String newPayloadResidue, String newTags) throws IOException {
+ private void makeEditNodes(String newTitle, String newTodo,
+ String newPriority, String newCleanedPayload, String newTags) throws IOException {
boolean generateEdits = !node.getFileName(orgDB).equals(OrgFile.CAPTURE_FILE);
if (!node.getName().equals(newTitle)) {
@@ -351,9 +347,11 @@ private void editNode(String newTitle, String newTodo,
node.setPriority(newPriority, orgDB);
}
if (!node.getCleanedPayload(orgDB).equals(newCleanedPayload)
- || !node.getPayloadResidue(orgDB).equals(newPayloadResidue)) {
- String newRawPayload = newPayloadResidue + newCleanedPayload;
-
+ || !node.getPayload(orgDB).getPayloadResidue()
+ .equals(node.getPayload(orgDB).getNewPayloadResidue())) {
+ String newRawPayload = node.getPayload(orgDB)
+ .getNewPayloadResidue() + newCleanedPayload;
+
if (generateEdits)
orgDB.addEdit("body", node.getNodeId(orgDB), newTitle, node.getRawPayload(orgDB), newRawPayload);
node.setPayload(newRawPayload, orgDB);
View
56 src/com/matburt/mobileorg/Gui/Capture/EditDetailsFragment.java
@@ -41,6 +41,8 @@
private String defaultTodo;
private DateTableRow scheduledEntry = null;
private DateTableRow deadlineEntry = null;
+
+ private ArrayList<String> tagsToRestore = null;
public void init(NodeWrapper node, String actionMode, String defaultTodo, String title) {
init(node, actionMode, defaultTodo);
@@ -70,9 +72,41 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
setHasOptionsMenu(true);
initDisplay();
+
+ if (savedInstanceState != null) {
+ setupScheduled(savedInstanceState.getString("scheduled"));
+ setupDeadline(savedInstanceState.getString("deadline"));
+ tagsToRestore = savedInstanceState.getStringArrayList("tags");
+ }
+
return view;
}
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ if(tagsToRestore != null) {
+ tagsView.removeAllViews();
+ tagEntries.clear();
+ setupTags(tagsToRestore);
+ tagsToRestore = null;
+ }
+ }
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString("scheduled", getScheduled());
+ outState.putString("deadline", getDeadline());
+
+ ArrayList<String> tags = new ArrayList<String>();
+ for(TagTableRow tag: tagEntries) {
+ tags.add(tag.getSelection());
+ }
+ outState.putStringArrayList("tags", tags);
+ }
+
private void initDisplay() {
if(this.actionMode == null) {
this.actionMode = EditActivity.ACTIONMODE_CREATE;
@@ -86,7 +120,7 @@ else if (this.actionMode.equals(EditActivity.ACTIONMODE_EDIT)) {
titleView.setText(node.getName());
titleView.setSelection(node.getName().length());
- setupTags(orgDB.getTags());
+ setupTags(node.getTagList());
setupDates();
setupSpinner(getActivity(), todoStateView, orgDB.getTodos(), node.getTodo());
setupSpinner(getActivity(), priorityView, orgDB.getPriorities(), node.getPriority());
@@ -99,7 +133,7 @@ else if (this.actionMode.equals(EditActivity.ACTIONMODE_EDIT)) {
}
private void setupTags(ArrayList<String> tagList) {
- for(String tag: node.getTagList()) {
+ for(String tag: tagList) {
if(TextUtils.isEmpty(tag)) {
// NodeWrapper found a :: entry, meaning all tags so far where unmodifiable
for(TagTableRow entry: tagEntries)
@@ -112,9 +146,19 @@ private void setupTags(ArrayList<String> tagList) {
}
}
+ private void setupScheduled(String scheduled) {
+ if(scheduled != null)
+ this.scheduledEntry = setupDate(scheduled, "SCHEDULED", scheduledRemoveListener);
+ }
+
+ private void setupDeadline(String deadline) {
+ if(deadline != null)
+ this.deadlineEntry = setupDate(deadline, "DEADLINE", deadlineRemoveListener);
+ }
+
private void setupDates() {
- this.scheduledEntry = setupDate(node.getScheduled(this.orgDB), "SCHEDULED", scheduledRemoveListener);
- this.deadlineEntry = setupDate(node.getDeadline(this.orgDB), "DEADLINE", deadlineRemoveListener);
+ this.scheduledEntry = setupDate(node.getPayload(this.orgDB).getScheduled(), "SCHEDULED", scheduledRemoveListener);
+ this.deadlineEntry = setupDate(node.getPayload(this.orgDB).getDeadline(), "DEADLINE", deadlineRemoveListener);
}
private DateTableRow setupDate(String date, String title, View.OnClickListener removeListener) {
@@ -282,13 +326,13 @@ public String getPriority() {
return priorityView.getSelectedItem().toString();
}
- static void setupSpinner(Context context, Spinner view, ArrayList<String> data,
+ public static void setupSpinner(Context context, Spinner view, ArrayList<String> data,
String selection) {
data.add("");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_spinner_item, data);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ adapter.setDropDownViewResource(R.layout.edit_spinner_layout);
view.setAdapter(adapter);
int pos = data.indexOf(selection);
if (pos < 0) {
View
12 src/com/matburt/mobileorg/Gui/Capture/TagTableRow.java
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import android.content.Context;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.Spinner;
@@ -27,11 +26,8 @@ public TagTableRow(Context context, TableLayout parent,
this.parent = parent;
this.activity = activity;
- LayoutInflater layoutInflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- TableRow row = (TableRow) layoutInflater.inflate(
- R.layout.edit_tagsrow, this);
-
+ View.inflate(context, R.layout.edit_tagsrow, this);
+
button = (Button) findViewById(R.id.editnode_tag_remove);
button.setOnClickListener(removeListener);
@@ -40,8 +36,8 @@ public TagTableRow(Context context, TableLayout parent,
selection = selection.replace(":", "");
}
- spinner = (Spinner) row.findViewById(R.id.editnode_tag_list);
- EditDetailsFragment.setupSpinner(context, spinner, tags, selection);
+ spinner = (Spinner) findViewById(R.id.editnode_tag_list);
+ EditDetailsFragment.setupSpinner(this.getContext(), spinner, tags, selection);
}
public void setUnmodifiable() {
View
3 src/com/matburt/mobileorg/Gui/NodeViewActivity.java
@@ -84,6 +84,9 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
@Override
public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
case R.id.viewmenu_edit:
runEditNodeActivity();
break;
View
23 src/com/matburt/mobileorg/Gui/OutlineActivity.java
@@ -146,16 +146,20 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.outline_menu, menu);
- if(this.node_id != -1 && new NodeWrapper(this.node_id, appInst.getDB()).getFileName(
- appInst.getDB()).equals(OrgFile.CAPTURE_FILE))
- menu.findItem(R.id.menu_capturechild).setVisible(true);
+ if(this.node_id == -1 || isNodeInFile(this.node_id, "agendas.org"))
+ menu.findItem(R.id.menu_capturechild).setVisible(false);
return true;
}
@Override
public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
switch (item.getItemId()) {
+ case android.R.id.home:
+ if(this.node_id != -1)
+ finish();
+ return true;
+
case R.id.menu_sync:
runSync();
return true;
@@ -201,16 +205,23 @@ public void onCreateContextMenu(ContextMenu menu, View v,
menu.findItem(R.id.contextmenu_edit).setVisible(false);
menu.findItem(R.id.contextmenu_capturechild).setVisible(false);
} else {
- if (new NodeWrapper(clicked_node_id, appInst.getDB()).getFileName(
- appInst.getDB()).equals(OrgFile.CAPTURE_FILE)) {
+ if (isNodeInFile(clicked_node_id, OrgFile.CAPTURE_FILE)) {
menu.findItem(R.id.contextmenu_node_delete).setVisible(true);
- menu.findItem(R.id.contextmenu_capturechild).setVisible(true);
+ }
+
+ if(isNodeInFile(clicked_node_id, "agendas.org")) {
+ menu.findItem(R.id.contextmenu_capturechild).setVisible(false);
}
menu.findItem(R.id.contextmenu_delete).setVisible(false);
}
}
+ private boolean isNodeInFile(long node_id, String filename) {
+ return new NodeWrapper(node_id, appInst.getDB()).getFileName(
+ appInst.getDB()).equals(filename);
+ }
+
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
View
9 src/com/matburt/mobileorg/Parsing/MobileOrgApplication.java
@@ -4,10 +4,12 @@
import android.preference.PreferenceManager;
import android.text.TextUtils;
+import com.matburt.mobileorg.Services.CalendarSyncService;
import com.matburt.mobileorg.Services.SyncService;
public class MobileOrgApplication extends Application {
private OrgDatabase appdb;
+ private CalendarSyncService calendarSyncService;
@Override
public void onCreate() {
@@ -26,6 +28,13 @@ public OrgDatabase getDB() {
return this.appdb;
}
+ public CalendarSyncService getCalendarSyncService() {
+ if(this.calendarSyncService == null)
+ this.calendarSyncService = new CalendarSyncService(getDB(), this);
+
+ return this.calendarSyncService;
+ }
+
public boolean isSyncConfigured() {
String syncSource = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
.getString("syncSource", "");
View
43 src/com/matburt/mobileorg/Parsing/NodePayload.java
@@ -5,10 +5,12 @@
import android.text.TextUtils;
-class NodePayload {
+public class NodePayload {
private StringBuilder payload = new StringBuilder();
/** These are the remains of the cleaned payload. */
private StringBuilder payloadResidue = new StringBuilder();
+ private StringBuilder newPayloadResidue = null;
+
private String content = null;
private String scheduled = null;
@@ -41,9 +43,16 @@ public String getContent() {
public String getPayloadResidue() {
if(this.content == null)
cleanPayload();
-
+
return this.payloadResidue.toString();
}
+
+ public String getNewPayloadResidue() {
+ if(this.newPayloadResidue == null)
+ return this.payloadResidue.toString();
+ else
+ return this.newPayloadResidue.toString();
+ }
public String getId() {
if(this.id == null)
@@ -159,19 +168,21 @@ public String getDeadline() {
return this.deadline;
}
+
+ public void insertOrReplace(String key, String value) {
+ if(newPayloadResidue == null)
+ newPayloadResidue = new StringBuilder(payloadResidue);
+
+ final Pattern schedulePattern = Pattern.compile(key + "\\s*<[^>]+>");
+ Matcher matcher = schedulePattern.matcher(newPayloadResidue);
-// public String datesToString() {
-// String dateInfo = "";
-//
-// try{
-// SimpleDateFormat formatter = new SimpleDateFormat("<yyyy-MM-dd EEE>");
-// if (this.deadline != null && this.deadline.length() > 0)
-// dateInfo += "DEADLINE: " + formatter.format(this.deadline) + " ";
-//
-// if (this.scheduled != null && this.scheduled.length() > 0)
-// dateInfo += "SCHEDULED: " + formatter.format(this.scheduled) + " ";
-// } catch(IllegalArgumentException e) { dateInfo = "";}
-//
-// return dateInfo;
-// }
+ if (matcher.find()) {
+ if (TextUtils.isEmpty(value))
+ newPayloadResidue.delete(matcher.start(), matcher.end());
+ else
+ newPayloadResidue.replace(matcher.start(), matcher.end(), value);
+ }
+ else if(TextUtils.isEmpty(value) == false)
+ newPayloadResidue.insert(0, value).append("\n");
+ }
}
View
19 src/com/matburt/mobileorg/Parsing/NodeWrapper.java
@@ -94,9 +94,9 @@ private void preparePayload(OrgDatabase db) {
}
}
- public String getPayloadResidue(OrgDatabase db) {
+ public NodePayload getPayload(OrgDatabase db) {
preparePayload(db);
- return payload.getPayloadResidue();
+ return this.payload;
}
public String getCleanedPayload(OrgDatabase db) {
@@ -290,20 +290,5 @@ public void close() {
if(cursor != null)
this.cursor.close();
}
-
- public String getDate(OrgDatabase db) {
- preparePayload(db);
- return payload.getDate();
- }
-
- public String getScheduled(OrgDatabase db) {
- preparePayload(db);
- return payload.getScheduled();
- }
-
- public String getDeadline(OrgDatabase db) {
- preparePayload(db);
- return payload.getDeadline();
- }
}
View
11 src/com/matburt/mobileorg/Parsing/OrgDatabase.java
@@ -152,7 +152,7 @@ public String getFilename(Long file_id) {
}
- public long getFileId(String filename) {
+ public long getFilenameId(String filename) {
Cursor cursor = db.query("files", new String[] { "_id" },
"filename=?", new String[] {filename}, null, null, null);
@@ -172,7 +172,7 @@ public void removeFile(String filename) {
OrgFile orgfile = new OrgFile(filename, context);
orgfile.remove();
- Long file_id = this.getFileId(filename);
+ Long file_id = this.getFilenameId(filename);
db.delete("orgdata", "file_id = ?", new String[] { file_id.toString() });
db.delete("files", "filename = ?", new String[] { filename });
@@ -195,7 +195,7 @@ public void removeFile(Long node_id) {
}
public long addOrUpdateFile(String filename, String name, String checksum, boolean includeInOutline) {
- long file_id = this.getFileId(filename);
+ long file_id = this.getFilenameId(filename);
if(file_id >= 0)
return file_id;
@@ -403,7 +403,7 @@ public void cloneNode(Long node_id, Long parent_id, Long target_file_id) {
}
public Cursor getFileSchedule(String filename) {
- long file_id = this.getFileId(filename);
+ long file_id = this.getFilenameId(filename);
String whereQuery = "file_id=? AND (payload LIKE '%SCHEDULED:%' OR payload LIKE '%DEADLINE:%')";
@@ -423,7 +423,6 @@ public Cursor getFileSchedule(String filename) {
public void addEdit(String edittype, String nodeId, String nodeTitle,
String oldValue, String newValue) {
-
ContentValues values = new ContentValues();
values.put("type", edittype);
values.put("data_id", nodeId);
@@ -460,7 +459,7 @@ private StringBuilder nodesToString(long node_id, long level) {
return result;
}
- private String nodeToString(long node_id, long level) {
+ public String nodeToString(long node_id, long level) {
// TODO Maybe add payload of file node
if(level == 0) // This is a file node
return "";
View
6 src/com/matburt/mobileorg/Parsing/OrgFileParser.java
@@ -138,7 +138,7 @@ private void combineBlockAgendas() {
if(blockTitle.equals(previousBlockTitle) == false) { // Create new node to contain block agenda
previousBlockNode = db.addNode(agendaFileNodeID, blockTitle,
- "", "", "", db.getFileId(filename));
+ "", "", "", db.getFilenameId(filename));
}
String blockEntryName = name.substring(name.indexOf(">") + 1);
@@ -187,12 +187,12 @@ private void combineBlockAgendas() {
private void cloneChildren(Cursor children, long previousBlockNode,
Long agendaNodeFileID, String blockEntryName, String filename) {
db.addNode(previousBlockNode, BLOCK_SEPARATOR_PREFIX
- + blockEntryName, "", "", "", db.getFileId(filename));
+ + blockEntryName, "", "", "", db.getFilenameId(filename));
while(children.isAfterLast() == false) {
db.cloneNode(
children.getLong(children.getColumnIndex("_id")),
- previousBlockNode, db.getFileId("agendas.org"));
+ previousBlockNode, db.getFilenameId("agendas.org"));
children.moveToNext();
}
}
View
9 src/com/matburt/mobileorg/Services/CalendarSyncService.java
@@ -176,10 +176,15 @@ private Date getTimeInMs(String time) throws ParseException {
return formatter.parse(time);
}
+ public void insertNode(long node_id) {
+ NodeWrapper node = new NodeWrapper(this.db.getNode(node_id));
+ insertNode(node, node.getFileName(db));
+ }
+
private void insertNode(NodeWrapper node, String filename) throws IllegalArgumentException {
final Pattern schedulePattern = Pattern
.compile("(\\d{4}-\\d{2}-\\d{2})(?:[^\\d]*)(\\d{1,2}\\:\\d{2})?\\-?(\\d{1,2}\\:\\d{2})?");
- Matcher propm = schedulePattern.matcher(node.getDate(db));
+ Matcher propm = schedulePattern.matcher(node.getPayload(db).getDate());
long beginTime;
long endTime;
@@ -213,7 +218,7 @@ private void insertNode(NodeWrapper node, String filename) throws IllegalArgumen
filename);
} catch (ParseException e) {
- Log.w("MobileOrg", "Unable to parse schedule of: " + node.getName() + " " + node.getDate(db));
+ Log.w("MobileOrg", "Unable to parse schedule of: " + node.getName() + " " + node.getPayload(db).getDate());
}
} else
Log.w("MobileOrg", "Unable to find time entry in schedule of: "
View
4 src/com/matburt/mobileorg/Settings/SettingsActivity.java
@@ -106,9 +106,7 @@ public void onClick(DialogInterface dialog,
};
private CalendarSyncService getCalendarSyncService() {
- return new CalendarSyncService(
- ((MobileOrgApplication) getApplication()).getDB(),
- getApplicationContext());
+ return ((MobileOrgApplication) getApplication()).getCalendarSyncService();
}
private boolean isCalendarEnabled() {

0 comments on commit 5777935

Please sign in to comment.