Add setting to never notify of upcoming alarms
This commit is contained in:
parent
a9589a1742
commit
012c8fb425
@ -78,13 +78,16 @@ public final class AlarmController {
|
||||
// to handle that yourself by using a wakelock, etc..
|
||||
// We use a WAKEUP alarm to send the upcoming alarm notification so it goes off even if the
|
||||
// device is asleep. Otherwise, it will not go off until the device is turned back on.
|
||||
long ringAt = alarm.isSnoozed() ? alarm.snoozingUntil() : alarm.ringsAt();
|
||||
int hoursToNotifyInAdvance = AlarmPreferences.hoursBeforeUpcoming(mAppContext);
|
||||
long upcomingAt = ringAt - HOURS.toMillis(hoursToNotifyInAdvance);
|
||||
// If snoozed, upcoming note posted immediately.
|
||||
am.set(AlarmManager.RTC_WAKEUP, upcomingAt, notifyUpcomingAlarmIntent(alarm, false));
|
||||
final long ringAt = alarm.isSnoozed() ? alarm.snoozingUntil() : alarm.ringsAt();
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, ringAt, alarmIntent(alarm, false));
|
||||
|
||||
final int hoursToNotifyInAdvance = AlarmPreferences.hoursBeforeUpcoming(mAppContext);
|
||||
if (hoursToNotifyInAdvance > 0 || alarm.isSnoozed()) {
|
||||
// If snoozed, upcoming note posted immediately.
|
||||
long upcomingAt = ringAt - HOURS.toMillis(hoursToNotifyInAdvance);
|
||||
am.set(AlarmManager.RTC_WAKEUP, upcomingAt, notifyUpcomingAlarmIntent(alarm, false));
|
||||
}
|
||||
|
||||
if (showSnackbar) {
|
||||
String message = mAppContext.getString(R.string.alarm_set_for,
|
||||
DurationUtils.toString(mAppContext, alarm.ringsIn(), false /*abbreviate?*/));
|
||||
@ -120,12 +123,12 @@ public final class AlarmController {
|
||||
// Does nothing if it's not posted.
|
||||
removeUpcomingAlarmNotification(alarm);
|
||||
|
||||
int hoursToNotifyInAdvance = AlarmPreferences.hoursBeforeUpcoming(mAppContext);
|
||||
final int hoursToNotifyInAdvance = AlarmPreferences.hoursBeforeUpcoming(mAppContext);
|
||||
// TOneverDO: Place block after making value changes to the alarm.
|
||||
if (showSnackbar
|
||||
if ((hoursToNotifyInAdvance > 0 && showSnackbar
|
||||
// TODO: Consider showing the snackbar for non-upcoming alarms too;
|
||||
// then, we can remove these checks.
|
||||
&& alarm.ringsWithinHours(hoursToNotifyInAdvance) || alarm.isSnoozed()) {
|
||||
&& alarm.ringsWithinHours(hoursToNotifyInAdvance)) || alarm.isSnoozed()) {
|
||||
long time = alarm.isSnoozed() ? alarm.snoozingUntil() : alarm.ringsAt();
|
||||
String msg = mAppContext.getString(R.string.upcoming_alarm_dismissed,
|
||||
formatTime(mAppContext, time));
|
||||
|
||||
@ -275,8 +275,8 @@ public abstract class BaseAlarmViewHolder extends BaseViewHolder<Alarm> {
|
||||
}
|
||||
|
||||
private void bindDismissButton(Alarm alarm) {
|
||||
int hoursBeforeUpcoming = AlarmPreferences.hoursBeforeUpcoming(getContext());
|
||||
boolean upcoming = alarm.ringsWithinHours(hoursBeforeUpcoming);
|
||||
final int hoursBeforeUpcoming = AlarmPreferences.hoursBeforeUpcoming(getContext());
|
||||
boolean upcoming = hoursBeforeUpcoming > 0 && alarm.ringsWithinHours(hoursBeforeUpcoming);
|
||||
boolean snoozed = alarm.isSnoozed();
|
||||
boolean visible = alarm.isEnabled() && (upcoming || snoozed);
|
||||
String buttonText = snoozed
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
<string name="key_notify_me_of_upcoming_alarms">key_notify_me_of_upcoming_alarms</string>
|
||||
<string name="title_notify_me_of_upcoming_alarms">Notify me of upcoming alarms</string>
|
||||
<string-array name="entries_notify_me_of_upcoming_alarms">
|
||||
<item>Never</item>
|
||||
<item>1 hour before</item>
|
||||
<item>2 hours before</item>
|
||||
<item>3 hours before</item>
|
||||
@ -60,6 +61,7 @@
|
||||
<item>8 hours before</item>
|
||||
</string-array>
|
||||
<string-array name="values_notify_me_of_upcoming_alarms">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user