Commit 01c3369e authored by Michael W's avatar Michael W
Browse files

DeskClock: Remove notification sound from firing and snoozing channels

* Firing alarms and timers needs high priority but we don't need a
  notification sound, as the alarm / timer already bring their own sound
* This has been lost in the rework of notification channels
  -> Needs another channel recreation

* Snoozing was lowered in priority in commit
  22b6cf2f
  but I didn't give it a new id, so existing installations are left with
  notification sound when snoozing - who would want that?

Change-Id: I5c7fc96b657e966950414b40fb61c829040ece9f
parent fbaedef9
......@@ -52,12 +52,12 @@ public class NotificationUtils {
/**
* Notification channel containing all snooze notifications.
*/
public static final String ALARM_SNOOZE_NOTIFICATION_CHANNEL_ID = "alarmSnoozeNotification";
public static final String ALARM_SNOOZE_NOTIFICATION_CHANNEL_ID = "alarmSnoozingNotification";
/**
* Notification channel containing all firing alarm and timer notifications.
*/
public static final String FIRING_NOTIFICATION_CHANNEL_ID = "firingAlarmsTimersNotification";
public static final String FIRING_NOTIFICATION_CHANNEL_ID = "firingAlarmsAndTimersNotification";
/**
* Notification channel containing all TimerModel notifications.
......@@ -69,6 +69,13 @@ public class NotificationUtils {
*/
public static final String STOPWATCH_NOTIFICATION_CHANNEL_ID = "stopwatchNotification";
/**
* Values used to bitmask certain channel defaults
*/
private static final int PLAY_SOUND = 0x01;
private static final int ENABLE_LIGHTS = 0x02;
private static final int ENABLE_VIBRATION = 0x04;
private static Map<String, int[]> CHANNEL_PROPS = new HashMap<String, int[]>();
static {
CHANNEL_PROPS.put(ALARM_MISSED_NOTIFICATION_CHANNEL_ID, new int[]{
......@@ -85,7 +92,8 @@ public class NotificationUtils {
});
CHANNEL_PROPS.put(FIRING_NOTIFICATION_CHANNEL_ID, new int[]{
R.string.firing_alarms_timers_channel,
IMPORTANCE_HIGH
IMPORTANCE_HIGH,
ENABLE_LIGHTS
});
CHANNEL_PROPS.put(STOPWATCH_NOTIFICATION_CHANNEL_ID, new int[]{
R.string.stopwatch_channel,
......@@ -112,6 +120,14 @@ public class NotificationUtils {
int importance = properties[1];
NotificationChannel channel = new NotificationChannel(
id, context.getString(nameId), importance);
if (properties.length >= 3) {
int bits = properties[2];
channel.enableLights((bits & ENABLE_LIGHTS) != 0);
channel.enableVibration((bits & ENABLE_VIBRATION) != 0);
if ((bits & PLAY_SOUND) == 0) {
channel.setSound(null, null);
}
}
NotificationManagerCompat nm = NotificationManagerCompat.from(context);
nm.createNotificationChannel(channel);
}
......@@ -144,6 +160,8 @@ public class NotificationUtils {
deleteChannel(nm, "StopwatchNotification");
deleteChannel(nm, "alarmNotification");
deleteChannel(nm, "TimerModelNotification");
deleteChannel(nm, "firingAlarmsTimersNotification");
deleteChannel(nm, "alarmSnoozeNotification");
// We recreate all existing channels so any language change or our name changes propagate
// to the actual channels
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment