From e9be1bff6a7345dd194999997f044afda06c9f9d Mon Sep 17 00:00:00 2001 From: Tim Su Date: Wed, 28 Apr 2010 21:47:31 -0700 Subject: [PATCH] Updated the logic for quiet hours to be a little more sensical. If you have a non-alarm-clock-mode alarm, then quiet mode affects your ringer. If you aren't in periodic mode, you will still vibrate. --- .../timsu/astrid/utilities/Notifications.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/com/timsu/astrid/utilities/Notifications.java b/src/com/timsu/astrid/utilities/Notifications.java index e7fe8d32c..ea3fccb7f 100644 --- a/src/com/timsu/astrid/utilities/Notifications.java +++ b/src/com/timsu/astrid/utilities/Notifications.java @@ -383,12 +383,11 @@ public class Notifications extends BroadcastReceiver { controller.close(); } - // quiet hours? only for periodic reminders + // quiet hours? disabled if alarm clock boolean quietHours = false; Integer quietHoursStart = Preferences.getQuietHourStart(context); Integer quietHoursEnd = Preferences.getQuietHourEnd(context); - if(quietHoursStart != null && quietHoursEnd != null && - (flags & FLAG_PERIODIC) > 0) { + if(quietHoursStart != null && quietHoursEnd != null && nonstopMode) { int hour = new Date().getHours(); if(quietHoursStart < quietHoursEnd) { if(hour >= quietHoursStart && hour < quietHoursEnd) @@ -456,17 +455,10 @@ public class Notifications extends BroadcastReceiver { audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); } + // quiet hours = no sound if(quietHours) { - notification.vibrate = null; notification.sound = null; } else { - if (Preferences.shouldVibrate(context) - && audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) { - notification.vibrate = new long[] {0, 1000, 500, 1000, 500, 1000}; - } else { - notification.vibrate = null; - } - Uri notificationSound = Preferences.getNotificationRingtone(context); if(audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) { notification.sound = null; @@ -478,6 +470,18 @@ public class Notifications extends BroadcastReceiver { } } + // quiet hours + periodic = no vibrate + if(quietHours && (flags & FLAG_PERIODIC) > 0) { + notification.vibrate = null; + } else { + if (Preferences.shouldVibrate(context) + && audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) { + notification.vibrate = new long[] {0, 1000, 500, 1000, 500, 1000}; + } else { + notification.vibrate = null; + } + } + if(Constants.DEBUG) Log.w("Astrid", "Logging notification: " + reminder); nm.notify((int)id, notification);