Show alert when task repeat value changed

pull/14/head
Sam Bosley 13 years ago
parent c277c50c7e
commit bc17b23e81

@ -36,6 +36,7 @@ import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.ui.NumberPicker;
import com.todoroo.astrid.ui.NumberPickerDialog;
import com.todoroo.astrid.ui.NumberPickerDialog.OnNumberPickedListener;
@ -324,6 +325,9 @@ public class RepeatControlSet extends PopupControlSet {
result = rrule.toIcal();
}
if (!result.equals(task.getValue(Task.RECURRENCE)))
task.putTransitory(TaskService.TRANS_REPEAT_CHANGED, true);
task.setValue(Task.RECURRENCE, result);
switch(type.getSelectedItemPosition()) {

@ -163,6 +163,13 @@
<string name="TLA_quickadd_confirm_hide_helpers">Don\'t display future confirmations</string>
<!-- Title for alert on new repeating task. %s-> task title -->
<string name="TLA_repeat_scheduled_title">New repeating task %s</string>
<!-- Speech bubble for when a new repeating task scheduled. %s->repeat interval -->
<string name="TLA_repeat_scheduled_speech_bubble">I\'ll remind you about this %s.</string>
<string-array name="TLA_priority_strings">
<item>highest priority</item>
<item>high priority</item>

@ -89,6 +89,7 @@ import com.todoroo.astrid.tags.TagsControlSet;
import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet;
import com.todoroo.astrid.timers.TimerActionControlSet;
import com.todoroo.astrid.timers.TimerControlSet;
import com.todoroo.astrid.ui.DateChangedAlerts;
import com.todoroo.astrid.ui.DeadlineControlSet;
import com.todoroo.astrid.ui.EditNotesControlSet;
import com.todoroo.astrid.ui.EditTitleControlSet;
@ -168,6 +169,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
public static final String TOKEN_ASSIGNED_TO = "task_assigned_to"; //$NON-NLS-1$
public static final String TOKEN_TAGS_CHANGED = "tags_changed"; //$NON-NLS-1$
public static final String TOKEN_NEW_REPEATING_TASK = "new_repeating"; //$NON-NLS-1$
// --- services
@ -812,16 +814,21 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
taskService.save(model);
if (!onPause && !cancelFinish) {
boolean setActivityResult = (getActivity() instanceof TaskEditActivity);
boolean taskEditActivity = (getActivity() instanceof TaskEditActivity);
boolean isAssignedToMe = peopleControlSet.isAssignedToMe();
boolean showRepeatAlert = model.getTransitory(TaskService.TRANS_REPEAT_CHANGED) != null
&& !TextUtils.isEmpty(model.getValue(Task.RECURRENCE));
String assignedTo = peopleControlSet.getAssignedToString();
if (setActivityResult) {
if (taskEditActivity) {
Intent data = new Intent();
if (!isAssignedToMe) {
data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true);
data.putExtra(TOKEN_ASSIGNED_TO,
assignedTo);
}
if (showRepeatAlert) {
data.putExtra(TOKEN_NEW_REPEATING_TASK, model);
}
data.putExtra(TOKEN_TAGS_CHANGED, tagsChanged);
getActivity().setResult(Activity.RESULT_OK, data);
@ -831,6 +838,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
TaskListActivity tla = (TaskListActivity) getActivity();
if (!isAssignedToMe)
tla.switchToAssignedFilter(assignedTo);
else if (showRepeatAlert)
DateChangedAlerts.showRepeatChangedDialog(tla, model);
if (tagsChanged)
tla.tagsChanged();
tla.refreshTaskList();

@ -33,9 +33,11 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.reminders.NotificationFragment;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.ui.DateChangedAlerts;
import com.todoroo.astrid.ui.FragmentPopover;
import com.todoroo.astrid.ui.MainMenuPopover;
import com.todoroo.astrid.ui.MainMenuPopover.MainMenuListener;
@ -390,6 +392,9 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO);
switchToAssignedFilter(assignedTo);
} else if (data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK) != null) {
Task repeating = data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK);
DateChangedAlerts.showRepeatChangedDialog(this, repeating);
}
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TAGS_CHANGED, false))
tagsChanged(true);

@ -44,6 +44,8 @@ public class TaskService {
public static final String TRANS_QUICK_ADD_MARKUP = "markup"; //$NON-NLS-1$
public static final String TRANS_REPEAT_CHANGED = "repeat_changed"; //$NON-NLS-1$
@Autowired
private TaskDao taskDao;

@ -53,9 +53,9 @@ public class DateChangedAlerts {
d.setContentView(R.layout.astrid_reminder_view);
Button okButton = (Button) d.findViewById(R.id.reminder_complete);
okButton.setText(R.string.DLG_ok);
d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE);
okButton.setText(R.string.DLG_ok);
((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_quickadd_confirm_title, originalText));
Spanned speechBubbleText = constructSpeechBubbleTextForQuickAdd(activity, task);
@ -77,6 +77,31 @@ public class DateChangedAlerts {
d.show();
}
public static void showRepeatChangedDialog(final AstridActivity activity, Task task) {
if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true))
return;
final Dialog d = new Dialog(activity, R.style.ReminderDialog);
d.setContentView(R.layout.astrid_reminder_view);
Button okButton = (Button) d.findViewById(R.id.reminder_complete);
okButton.setText(R.string.DLG_ok);
d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE);
d.findViewById(R.id.reminder_edit).setVisibility(View.GONE);
((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_repeat_scheduled_title, task.getValue(Task.TITLE)));
String speechBubbleText = constructSpeechBubbleTextForRepeat(activity, task);
((TextView) d.findViewById(R.id.reminder_message)).setText(speechBubbleText);
setupOkAndDismissButtons(d);
setupHideCheckbox(d);
d.setOwnerActivity(activity);
d.show();
}
public static final Property<?>[] REPEAT_RESCHEDULED_PROPERTIES =
new Property<?>[] {
@ -190,6 +215,11 @@ public class DateChangedAlerts {
return Html.fromHtml(fullString);
}
private static String constructSpeechBubbleTextForRepeat(Context context, Task task) {
String recurrence = getRecurrenceString(context, task);
return context.getString(R.string.TLA_repeat_scheduled_speech_bubble, recurrence);
}
@SuppressWarnings("nls")
private static String getRelativeDateAndTimeString(Context context, long date) {
String dueString = date > 0 ? DateUtilities.getRelativeDay(context, date, false) : "";

@ -287,6 +287,8 @@ public class QuickAddBar extends LinearLayout {
Uri calendarUri = GCalHelper.createTaskEvent(task,
activity.getContentResolver(), new ContentValues());
task.setValue(Task.CALENDAR_URI, calendarUri.toString());
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
Flags.set(Flags.GTASKS_SUPPRESS_SYNC);
taskService.save(task);
}
@ -301,6 +303,8 @@ public class QuickAddBar extends LinearLayout {
fragment.selectCustomId(task.getId());
if (task.getTransitory(TaskService.TRANS_QUICK_ADD_MARKUP) != null) {
showAlertForMarkupTask((AstridActivity) activity, task, title);
} else if (!TextUtils.isEmpty(task.getValue(Task.RECURRENCE))) {
showAlertForRepeatingTask((AstridActivity) activity, task);
}
}
@ -317,6 +321,10 @@ public class QuickAddBar extends LinearLayout {
DateChangedAlerts.showQuickAddMarkupDialog(activity, task, originalText);
}
private static void showAlertForRepeatingTask(AstridActivity activity, Task task) {
DateChangedAlerts.showRepeatChangedDialog(activity, task);
}
// --- instance methods
public EditText getQuickAddBox() {

Loading…
Cancel
Save