Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fb70dc1 authored by Sam Blitzstein's avatar Sam Blitzstein
Browse files

Change text of auto-silenced alarm notification.

Show "Missed Alarm" as the title.

Bug: 10516179
Change-Id: I860cbab622df0be7c4c8e0763c3e6be231f8a09f
parent 58f5304c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,8 @@
    <!-- Alarm Alert screen: this message is shown after an alarm rung
         unattended for a number of minutes.  It tells the user that
         the alarm has been silenced.-->
    <string name="alarm_alert_alert_silenced">Alarm silenced after <xliff:g id="minutes">%d</xliff:g> minutes.</string>
    <string name="alarm_missed_title">Missed alarm</string>
    <string name="alarm_missed_text"><xliff:g id="alarm_time">%s</xliff:g> - <xliff:g id="alarm_label">%s</xliff:g></string>

    <!-- Button labels on the alarm dialog: Snooze -->
    <string name="alarm_alert_snooze_text">Snooze</string>
+17 −7
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import android.os.PowerManager.WakeLock;
import android.text.TextUtils;

import com.android.deskclock.provider.Alarm;

@@ -235,13 +236,22 @@ public class AlarmReceiver extends BroadcastReceiver {

        // Update the notification to indicate that the alert has been
        // silenced.
        String label = alarm.getLabelOrDefault(context);
        Notification n = new Notification(R.drawable.stat_notify_alarm,
                label, alarm.calculateAlarmTime());
        n.setLatestEventInfo(context, label,
                context.getString(R.string.alarm_alert_alert_silenced, timeout),
                intent);
        n.flags |= Notification.FLAG_AUTO_CANCEL;
        String title = context.getString(R.string.alarm_missed_title);
        String label = alarm.label;
        String alarmTime = Alarms.formatTime(context, alarm.calculateAlarmCalendar());
        // If the label is null, just show the alarm time. If not, show "time - label".
        String text = TextUtils.isEmpty(label)? alarmTime :
            context.getString(R.string.alarm_missed_text, alarmTime, label);

        Notification n = new Notification.Builder(context)
        .setContentTitle(title)
        .setContentText(text)
        .setSmallIcon(R.drawable.stat_notify_alarm)
        .setAutoCancel(true)
        .setPriority(Notification.PRIORITY_HIGH)
        .setDefaults(Notification.DEFAULT_ALL)
        .build();
        n.contentIntent = intent;
        // We have to cancel the original notification since it is in the
        // ongoing section and we want the "killed" notification to be a plain
        // notification.
+6 −1
Original line number Diff line number Diff line
@@ -287,6 +287,11 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
    }

    public long calculateAlarmTime() {
        Calendar c = calculateAlarmCalendar();
        return c.getTimeInMillis();
    }

    public Calendar calculateAlarmCalendar() {
        // start with now
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(System.currentTimeMillis());
@@ -307,7 +312,7 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
        if (addDays > 0) {
            c.add(Calendar.DAY_OF_WEEK, addDays);
        }
        return c.getTimeInMillis();
        return c;
    }

    @Override