Dismissing snoozed alarm now shows Toast confirmation
This commit is contained in:
parent
e2449bb11e
commit
938f1a62a7
@ -80,6 +80,7 @@ public class EditAlarmActivity extends BaseActivity implements AlarmNumpad.KeyLi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
// TODO: Snooze menu item when alarm is ringing.
|
||||||
mPresenter.onPrepareOptionsMenu();
|
mPresenter.onPrepareOptionsMenu();
|
||||||
return super.onPrepareOptionsMenu(menu);
|
return super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
@ -89,9 +90,12 @@ public class EditAlarmActivity extends BaseActivity implements AlarmNumpad.KeyLi
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_dismiss_now:
|
case R.id.action_dismiss_now:
|
||||||
mPresenter.dismissNow();
|
mPresenter.dismissNow();
|
||||||
|
item.setVisible(false);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_done_snoozing:
|
case R.id.action_done_snoozing:
|
||||||
mPresenter.stopSnoozing();
|
mPresenter.stopSnoozing();
|
||||||
|
item.setVisible(false);
|
||||||
|
getSupportActionBar().setDisplayShowTitleEnabled(false); // TODO: Move to presenter?
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|||||||
@ -102,12 +102,13 @@ public class EditAlarmPresenter implements EditAlarmContract.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void dismissNow() {
|
public void dismissNow() {
|
||||||
mAlarmUtilsHelper.cancelAlarm(checkNotNull(mAlarm));
|
mAlarmUtilsHelper.cancelAlarm(checkNotNull(mAlarm));
|
||||||
|
// cancelAlarm() should have turned off this alarm if appropriate
|
||||||
|
mView.showEnabled(mAlarm.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopSnoozing() {
|
public void stopSnoozing() {
|
||||||
dismissNow(); // MUST be first, see AlarmUtils.notifyUpcomingAlarmIntent()
|
dismissNow(); // MUST be first, see AlarmUtils.notifyUpcomingAlarmIntent()
|
||||||
|
|
||||||
// AlarmUtils.cancelAlarm() does this for you if snoozed
|
// AlarmUtils.cancelAlarm() does this for you if snoozed
|
||||||
/*
|
/*
|
||||||
mAlarm.stopSnoozing(); // TOneverDO: before dismissNow()
|
mAlarm.stopSnoozing(); // TOneverDO: before dismissNow()
|
||||||
@ -140,6 +141,9 @@ public class EditAlarmPresenter implements EditAlarmContract.Presenter {
|
|||||||
public void onPrepareOptionsMenu() {
|
public void onPrepareOptionsMenu() {
|
||||||
if (mAlarm != null && mAlarm.isEnabled()) {
|
if (mAlarm != null && mAlarm.isEnabled()) {
|
||||||
int hoursBeforeUpcoming = mSharedPreferencesHelper.getInt(R.string.key_notify_me_of_upcoming_alarms, 2);
|
int hoursBeforeUpcoming = mSharedPreferencesHelper.getInt(R.string.key_notify_me_of_upcoming_alarms, 2);
|
||||||
|
// TODO: Schedule task with handler to show the menu item when it is time. Handler is fine because
|
||||||
|
// the task only needs to be done if the activity is being viewed. (I think) if the process of this
|
||||||
|
// app is killed, then the handler is also killed.
|
||||||
if ((mAlarm.ringsWithinHours(hoursBeforeUpcoming))) {
|
if ((mAlarm.ringsWithinHours(hoursBeforeUpcoming))) {
|
||||||
mView.showCanDismissNow();
|
mView.showCanDismissNow();
|
||||||
} else if (mAlarm.isSnoozed()) {
|
} else if (mAlarm.isSnoozed()) {
|
||||||
@ -178,9 +182,6 @@ public class EditAlarmPresenter implements EditAlarmContract.Presenter {
|
|||||||
mView.showLabel(mAlarm.label());
|
mView.showLabel(mAlarm.label());
|
||||||
mView.showRingtone(mAlarm.ringtone());
|
mView.showRingtone(mAlarm.ringtone());
|
||||||
mView.showVibrates(mAlarm.vibrates());
|
mView.showVibrates(mAlarm.vibrates());
|
||||||
if (mAlarm.isSnoozed()) {
|
|
||||||
mView.showSnoozed(new Date(mAlarm.snoozingUntil()));
|
|
||||||
}
|
|
||||||
// Editing so don't show
|
// Editing so don't show
|
||||||
mView.showNumpad(false);
|
mView.showNumpad(false);
|
||||||
mView.showTimeTextFocused(false);
|
mView.showTimeTextFocused(false);
|
||||||
|
|||||||
@ -92,8 +92,8 @@ public final class AlarmUtils {
|
|||||||
save(c);
|
save(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.ringsIn() <= HOURS.toMillis(hoursBeforeUpcoming(c))) {
|
if (a.ringsIn() <= HOURS.toMillis(hoursBeforeUpcoming(c)) || a.isSnoozed()) {
|
||||||
String time = formatTime(c, a.ringsAt());
|
String time = formatTime(c, a.isSnoozed() ? a.snoozingUntil() : a.ringsAt());
|
||||||
String text = c.getString(R.string.upcoming_alarm_dismissed, time);
|
String text = c.getString(R.string.upcoming_alarm_dismissed, time);
|
||||||
Toast.makeText(c, text, Toast.LENGTH_LONG).show();
|
Toast.makeText(c, text, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user