diff --git a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java
index 76f3bef57..bafb95142 100644
--- a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java
+++ b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java
@@ -68,29 +68,19 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
long oldDueDate = task.getValue(Task.DUE_DATE);
long repeatUntil = task.getValue(Task.REPEAT_UNTIL);
- if (repeatUntil > 0 && newDueDate >= repeatUntil) {
- Intent repeatFinished = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_REPEAT_FINISHED);
- repeatFinished.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
- repeatFinished.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, oldDueDate);
- repeatFinished.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate);
- context.sendOrderedBroadcast(repeatFinished, null);
- return;
- }
- long hideUntil = task.getValue(Task.HIDE_UNTIL);
- if(hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) {
- hideUntil += newDueDate - task.getValue(Task.DUE_DATE);
+ boolean repeatFinished = repeatUntil > 0 && newDueDate >= repeatUntil;
+ if (repeatFinished) {
+ Intent repeatFinishedIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_REPEAT_FINISHED);
+ repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
+ repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, oldDueDate);
+ repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate);
+ context.sendOrderedBroadcast(repeatFinishedIntent, null);
+ System.err.println("SENDING BROADCAST");
+ return;
}
- // update repeat time when it repeats on the server
- task.setValue(Task.COMPLETION_DATE, 0L);
- task.setValue(Task.DUE_DATE, newDueDate);
- task.setValue(Task.HIDE_UNTIL, hideUntil);
- task.putTransitory(TaskService.TRANS_REPEAT_COMPLETE, true);
-
- ContentResolver cr = ContextManager.getContext().getContentResolver();
- GCalHelper.rescheduleRepeatingTask(task, cr);
- PluginServices.getTaskService().save(task);
+ rescheduleTask(task, newDueDate);
// send a broadcast
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED);
@@ -103,6 +93,22 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
}
}
+ public static void rescheduleTask(Task task, long newDueDate) {
+ long hideUntil = task.getValue(Task.HIDE_UNTIL);
+ if(hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) {
+ hideUntil += newDueDate - task.getValue(Task.DUE_DATE);
+ }
+
+ task.setValue(Task.COMPLETION_DATE, 0L);
+ task.setValue(Task.DUE_DATE, newDueDate);
+ task.setValue(Task.HIDE_UNTIL, hideUntil);
+ task.putTransitory(TaskService.TRANS_REPEAT_COMPLETE, true);
+
+ ContentResolver cr = ContextManager.getContext().getContentResolver();
+ GCalHelper.rescheduleRepeatingTask(task, cr);
+ PluginServices.getTaskService().save(task);
+ }
+
/** Compute next due date */
public static long computeNextDueDate(Task task, String recurrence) throws ParseException {
boolean repeatAfterCompletion = task.getFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION);
diff --git a/astrid/res/values/strings-repeat.xml b/astrid/res/values/strings-repeat.xml
index 4694fb85a..737e0e42d 100644
--- a/astrid/res/values/strings-repeat.xml
+++ b/astrid/res/values/strings-repeat.xml
@@ -58,6 +58,8 @@
Repeat until...
+ Keep going
+
- from due date
@@ -85,13 +87,18 @@
Rescheduling task \"%s\"
-
+
+
+ Completed repeating task \"%s\"
+
%1$s I\'ve rescheduled this repeating task from %2$s to %3$s
%1$s I\'ve rescheduled this repeating task to %2$s
+
+ You had this repeating until %1$s, and now you\'re all done. %2$s
@@ -100,5 +107,12 @@
- I love when you\'re productive!
- Doesn\'t it feel good to check something off?
+
+
+
+ - Good job!
+ - I\'m so proud of you!
+ - I love when you\'re productive!
+
diff --git a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java
index ada115403..f3aab0073 100644
--- a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java
@@ -109,9 +109,11 @@ public class AstridActivity extends FragmentActivity
Notifications.BROADCAST_IN_APP_NOTIFY);
reminderIntentFilter.setPriority(1);
registerReceiver(reminderReceiver, reminderIntentFilter);
- registerReceiver(repeatConfirmationReceiver,
- new android.content.IntentFilter(
- AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED));
+
+ android.content.IntentFilter repeatFilter = new android.content.IntentFilter(
+ AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED);
+ repeatFilter.addAction(AstridApiConstants.BROADCAST_EVENT_TASK_REPEAT_FINISHED);
+ registerReceiver(repeatConfirmationReceiver, repeatFilter);
}
@Override
@@ -383,8 +385,10 @@ public class AstridActivity extends FragmentActivity
DateChangedAlerts.REPEAT_RESCHEDULED_PROPERTIES);
try {
+ boolean lastTime = AstridApiConstants.BROADCAST_EVENT_TASK_REPEAT_FINISHED.equals(intent.getAction());
DateChangedAlerts.showRepeatTaskRescheduledDialog(
- AstridActivity.this, task, oldDueDate, newDueDate);
+ AstridActivity.this, task, oldDueDate, newDueDate, lastTime);
+
} catch (BadTokenException e) { // Activity not running when tried to show dialog--rebroadcast
new Thread() {
@Override
diff --git a/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java b/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java
index 8ff132422..5c2f50c8f 100644
--- a/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java
+++ b/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java
@@ -29,6 +29,8 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task;
+import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
+import com.todoroo.astrid.ui.DateAndTimeDialog.DateAndTimeDialogListener;
import com.todoroo.astrid.utility.Flags;
/**
@@ -114,10 +116,12 @@ public class DateChangedAlerts {
Task.ID,
Task.TITLE,
Task.DUE_DATE,
- Task.HIDE_UNTIL
+ Task.HIDE_UNTIL,
+ Task.REPEAT_UNTIL
};
- public static void showRepeatTaskRescheduledDialog(final AstridActivity activity, final Task task, final long oldDueDate, final long newDueDate) {
+ public static void showRepeatTaskRescheduledDialog(final AstridActivity activity, final Task task,
+ final long oldDueDate, final long newDueDate, final boolean lastTime) {
if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true))
return;
@@ -128,18 +132,54 @@ public class DateChangedAlerts {
Button okButton = (Button) d.findViewById(R.id.reminder_complete);
Button undoButton = (Button) d.findViewById(R.id.reminder_edit);
- d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE);
+ Button keepGoing = (Button) d.findViewById(R.id.reminder_snooze);
+ if (!lastTime) {
+ keepGoing.setVisibility(View.GONE);
+ } else {
+ keepGoing.setText(R.string.repeat_keep_going);
+ keepGoing.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ long startDate = 0;
+ DateAndTimeDialog picker = new DateAndTimeDialog(activity, startDate, R.layout.repeat_until_dialog, R.string.repeat_until_title);
+ picker.setDateAndTimeDialogListener(new DateAndTimeDialogListener() {
+ @Override
+ public void onDateAndTimeSelected(long date) {
+ d.dismiss();
+ task.setValue(Task.REPEAT_UNTIL, date);
+ RepeatTaskCompleteListener.rescheduleTask(task, newDueDate);
+ Flags.set(Flags.REFRESH);
+ }
+
+ @Override
+ public void onDateAndTimeCancelled() {
+ //
+ }
+ });
+ picker.show();
+ }
+ });
+ }
+
okButton.setText(R.string.DLG_ok);
undoButton.setText(R.string.DLG_undo);
- ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.repeat_rescheduling_dialog_title, task.getValue(Task.TITLE)));
+
+ int titleResource = lastTime ? R.string.repeat_rescheduling_dialog_title_last_time : R.string.repeat_rescheduling_dialog_title;
+ ((TextView) d.findViewById(R.id.reminder_title)).setText(
+ activity.getString(titleResource, task.getValue(Task.TITLE)));
String oldDueDateString = getRelativeDateAndTimeString(activity, oldDueDate);
String newDueDateString = getRelativeDateAndTimeString(activity, newDueDate);
- String[] encouragements = activity.getResources().getStringArray(R.array.repeat_encouragement);
+ String repeatUntilDateString = getRelativeDateAndTimeString(activity, task.getValue(Task.REPEAT_UNTIL));
+
+ int encouragementResource = lastTime ? R.array.repeat_encouragement_last_time : R.array.repeat_encouragement;
+ String[] encouragements = activity.getResources().getStringArray(encouragementResource);
String encouragement = encouragements[(int) (Math.random()*encouragements.length)];
String speechBubbleText;
- if (!TextUtils.isEmpty(oldDueDateString))
+ if (lastTime)
+ speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble_last_time, repeatUntilDateString, encouragement);
+ else if (!TextUtils.isEmpty(oldDueDateString))
speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble, encouragement, oldDueDateString, newDueDateString);
else
speechBubbleText = activity.getString(R.string.repeat_rescheduling_dialog_bubble_no_date, encouragement, newDueDateString);
@@ -154,6 +194,7 @@ public class DateChangedAlerts {
public void onClick(View v) {
d.dismiss();
task.setValue(Task.DUE_DATE, oldDueDate);
+ task.setValue(Task.COMPLETION_DATE, 0L);
long hideUntil = task.getValue(Task.HIDE_UNTIL);
if (hideUntil > 0)
task.setValue(Task.HIDE_UNTIL, hideUntil - (newDueDate - oldDueDate));