Changed gcal behavior for repeated tasks--don't delete old events

pull/14/head
Sam Bosley 13 years ago
parent 016ef6b5f8
commit 7ff70ade9b

@ -440,7 +440,7 @@
</intent-filter>
</receiver>
<receiver android:name="com.todoroo.astrid.repeats.RepeatTaskCompleteListener">
<intent-filter>
<intent-filter android:priority="1">
<action android:name="com.todoroo.astrid.TASK_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
@ -454,7 +454,7 @@
<!-- calendar -->
<receiver android:name="com.todoroo.astrid.gcal.GCalTaskCompleteListener">
<intent-filter>
<intent-filter android:priority="2">
<action android:name="com.todoroo.astrid.TASK_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

@ -35,20 +35,28 @@ public class GCalHelper {
}
public static void createTaskEventIfEnabled(Task t) {
createTaskEventIfEnabled(t, true);
}
public static void createTaskEventIfEnabled(Task t, boolean deleteEventIfExists) {
boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null
&& !Preferences.getStringValue(R.string.gcal_p_default).equals("-1"); //$NON-NLS-1$
if (gcalCreateEventEnabled) {
ContentResolver cr = ContextManager.getContext().getContentResolver();
Uri calendarUri = GCalHelper.createTaskEvent(t, cr, new ContentValues());
Uri calendarUri = GCalHelper.createTaskEvent(t, cr, new ContentValues(), deleteEventIfExists);
if (calendarUri != null)
t.setValue(Task.CALENDAR_URI, calendarUri.toString());
}
}
public static Uri createTaskEvent(Task task, ContentResolver cr, ContentValues values) {
return createTaskEvent(task, cr, values, true);
}
public static Uri createTaskEvent(Task task, ContentResolver cr, ContentValues values, boolean deleteEventIfExists) {
String eventuri = getTaskEventUri(task);
if(!TextUtils.isEmpty(eventuri)) {
if(!TextUtils.isEmpty(eventuri) && deleteEventIfExists) {
deleteTaskEvent(task);
}

@ -76,6 +76,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
task.setValue(Task.DUE_DATE, newDueDate);
task.setValue(Task.HIDE_UNTIL, hideUntil);
task.putTransitory("repeat-complete", true); //$NON-NLS-1$
GCalHelper.createTaskEventIfEnabled(task, false);
PluginServices.getTaskService().save(task);
return;
}
@ -93,7 +94,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
clone.setValue(Task.REMINDER_LAST, 0L);
clone.setValue(Task.CALENDAR_URI, ""); //$NON-NLS-1$
GCalHelper.createTaskEventIfEnabled(clone);
GCalHelper.createTaskEventIfEnabled(clone, false);
PluginServices.getTaskService().save(clone);
// clear recurrence from completed task so it can be re-completed

@ -287,13 +287,16 @@ public final class TaskEditActivity extends Activity {
GCalControlSet gcalControl = new GCalControlSet(TaskEditActivity.this,
R.layout.control_set_gcal, R.layout.control_set_gcal_display,
R.string.gcal_TEA_addToCalendar_label);
controls.add(gcalControl);
//The deadline control set contains the repeat controls and the calendar controls.
//NOTE: we add the gcalControl to the list AFTER the deadline control, because
//otherwise the correct date may not be written to the calendar event. Order matters!
DeadlineControlSet deadlineControl = new DeadlineControlSet(
TaskEditActivity.this, R.layout.control_set_deadline,
R.layout.control_set_deadline_display, repeatControls.getDisplayView(), gcalControl.getDisplayView());
controls.add(deadlineControl);
controlSetMap.put(getString(R.string.TEA_ctrl_when_pref), deadlineControl);
controls.add(gcalControl);
ImportanceControlSet importanceControl = new ImportanceControlSet(
TaskEditActivity.this, R.layout.control_set_importance);

Loading…
Cancel
Save