summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Pasanen <dan.pasanen@gmail.com>2018-01-25 08:39:16 -0600
committerMichael Bestas <mkbestas@lineageos.org>2018-02-11 02:36:11 +0200
commitc0552a2b5644326332e3c9778070a6bd57138e72 (patch)
tree33452acc85806594e2a4b0972460d4833ffc9be5
parent9885999b493aa54369849d64cfcdd108e362f213 (diff)
downloadandroid_packages_apps_DeskClock-staging/lineage-15.1.tar.gz
android_packages_apps_DeskClock-staging/lineage-15.1.tar.bz2
android_packages_apps_DeskClock-staging/lineage-15.1.zip
DeskClock: introduce low priority alarm notification channelstaging/lineage-15.1
* Low priority alarms such as an upcoming alarm or snooze notification shouldn't make noise, vibrate or be intrusive. * In addition, set them as ongoing notifications (preventing a user from swiping them away) since they should have to intentionally cancel the alarm. Change-Id: I84ba2919dce39ecd4b002f501a397e2edf8ebd3c
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/deskclock/Utils.java9
-rw-r--r--src/com/android/deskclock/alarms/AlarmNotifications.java3
3 files changed, 13 insertions, 2 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 86686f8f1..a9ff8f550 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1055,6 +1055,7 @@
<string name="stopwatch_channel_name">Stopwatch</string>
<!-- The user visible name of the timers channel. -->
<string name="timer_channel_name">Timers</string>
- <!-- The user visible name of the alarms channel. -->
+ <!-- The user visible names of the alarm channels. -->
<string name="alarm_channel_name">Alarms</string>
+ <string name="alarm_channel_low_priority_name">Alarm information</string>
</resources>
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index fb31bfd4f..02d3ed333 100644
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -639,6 +639,10 @@ public class Utils {
NotificationChannel channel = new NotificationChannel(id, name, importance);
+ if (ALARM_CHANNEL_LOW_PRIORITY.equals(name)) {
+ channel.setVibrationPattern(null);
+ }
+
manager.createNotificationChannel(channel);
}
@@ -647,6 +651,8 @@ public class Utils {
public static final String STOPWATCH_CHANNEL = "stopwatch_notification_channel";
public static final String TIMER_CHANNEL = "timer_notification_channel";
public static final String ALARM_CHANNEL = "alarm_notification_channel";
+ public static final String ALARM_CHANNEL_LOW_PRIORITY =
+ "alarm_notification_channel_low_priority";
public static void createNotificationChannelsIfNeeded(Context context) {
if (areNotificationChannelsCreated) {
@@ -664,5 +670,8 @@ public class Utils {
createNotificationChannel(context, ALARM_CHANNEL,
context.getString(R.string.alarm_channel_name),
NotificationManager.IMPORTANCE_HIGH);
+ createNotificationChannel(context, ALARM_CHANNEL_LOW_PRIORITY,
+ context.getString(R.string.alarm_channel_low_priority_name),
+ NotificationManager.IMPORTANCE_MIN);
}
}
diff --git a/src/com/android/deskclock/alarms/AlarmNotifications.java b/src/com/android/deskclock/alarms/AlarmNotifications.java
index b867717b8..34850d930 100644
--- a/src/com/android/deskclock/alarms/AlarmNotifications.java
+++ b/src/com/android/deskclock/alarms/AlarmNotifications.java
@@ -87,7 +87,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(context);
Notification.Builder builder = new Notification.Builder(context,
- Utils.ALARM_CHANNEL)
+ Utils.ALARM_CHANNEL_LOW_PRIORITY)
.setShowWhen(false)
.setContentTitle(context.getString(
R.string.alarm_alert_predismiss_title))
@@ -98,6 +98,7 @@ final class AlarmNotifications {
.setSortKey(createSortKey(instance))
.setCategory(Notification.CATEGORY_ALARM)
.setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setOngoing(true)
.setLocalOnly(true);
if (Utils.isNOrLater()) {