Fixed bugs with snooze not overriding other reminders correctly

pull/14/head
Sam Bosley 12 years ago
parent dc2b6ca15f
commit b2a8f1954f

@ -19,14 +19,12 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TimePicker;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.activity.DisposableTaskListFragment;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.repeats.RepeatControlSet;
import com.todoroo.astrid.service.StatisticsConstants;
@ -40,7 +38,7 @@ import com.todoroo.astrid.ui.NumberPicker;
* @author timsu
*
*/
public class NotificationFragment extends DisposableTaskListFragment implements OnTimeSetListener, SnoozeCallback {
public class NotificationFragment extends DisposableTaskListFragment {
// --- constants
@ -160,24 +158,4 @@ public class NotificationFragment extends DisposableTaskListFragment implements
}
}
/** on time dialog return set */
@Override
public void onTimeSet(TimePicker picker, int hours, int minutes) {
Date alarmTime = new Date();
alarmTime.setHours(hours);
alarmTime.setMinutes(minutes);
if(alarmTime.getTime() < DateUtilities.now())
alarmTime.setDate(alarmTime.getDate() + 1);
snoozeForTime(alarmTime.getTime());
}
public void snoozeForTime(long time) {
Task task = new Task();
task.setId(taskId);
task.setValue(Task.REMINDER_SNOOZE, time);
PluginServices.getTaskService().save(task);
getActivity().finish();
StatisticsService.reportEvent(StatisticsConstants.TASK_SNOOZE);
}
}

@ -193,8 +193,10 @@ public final class ReminderService {
}
}
// Make sure no alarms are scheduled other than the next one. When that one is shown, it
// will schedule the next one after it, and so on and so forth.
clearAllAlarms(task);
if(task.isCompleted() || task.isDeleted() || task.getValue(Task.USER_ID) != 0) {
clearAllAlarms(task);
return;
}
@ -223,16 +225,21 @@ public final class ReminderService {
whenRandom = NO_ALARM;
// snooze trumps all
if(whenSnooze != NO_ALARM)
if(whenSnooze != NO_ALARM) {
scheduler.createAlarm(task, whenSnooze, TYPE_SNOOZE);
else if(whenRandom < whenDueDate && whenRandom < whenOverdue)
}
else if(whenRandom < whenDueDate && whenRandom < whenOverdue) {
scheduler.createAlarm(task, whenRandom, TYPE_RANDOM);
else if(whenDueDate < whenOverdue)
}
else if(whenDueDate < whenOverdue) {
scheduler.createAlarm(task, whenDueDate, TYPE_DUE);
else if(whenOverdue != NO_ALARM)
}
else if(whenOverdue != NO_ALARM) {
scheduler.createAlarm(task, whenOverdue, TYPE_OVERDUE);
else
}
else {
scheduler.createAlarm(task, 0, 0);
}
}
/**

@ -85,6 +85,8 @@ public class DeadlineControlSet extends PopupControlSet {
@Override
protected String writeToModelAfterInitialized(Task task) {
long dueDate = dateAndTimePicker.constructDueDate();
if (dueDate != task.getValue(Task.DUE_DATE)) // Clear snooze if due date has changed
task.setValue(Task.REMINDER_SNOOZE, 0L);
task.setValue(Task.DUE_DATE, dueDate);
return null;
}

@ -120,8 +120,6 @@ public class ReminderControlSet extends PopupControlSet {
@Override
protected String writeToModelAfterInitialized(Task task) {
task.setValue(Task.REMINDER_FLAGS, getValue());
// clear snooze if task is being edited
task.setValue(Task.REMINDER_SNOOZE, 0L);
randomControlSet.writeToModel(task);
alarmControl.writeToModel(task);

Loading…
Cancel
Save