|
|
|
@ -383,12 +383,11 @@ public class Notifications extends BroadcastReceiver {
|
|
|
|
controller.close();
|
|
|
|
controller.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// quiet hours? only for periodic reminders
|
|
|
|
// quiet hours? disabled if alarm clock
|
|
|
|
boolean quietHours = false;
|
|
|
|
boolean quietHours = false;
|
|
|
|
Integer quietHoursStart = Preferences.getQuietHourStart(context);
|
|
|
|
Integer quietHoursStart = Preferences.getQuietHourStart(context);
|
|
|
|
Integer quietHoursEnd = Preferences.getQuietHourEnd(context);
|
|
|
|
Integer quietHoursEnd = Preferences.getQuietHourEnd(context);
|
|
|
|
if(quietHoursStart != null && quietHoursEnd != null &&
|
|
|
|
if(quietHoursStart != null && quietHoursEnd != null && nonstopMode) {
|
|
|
|
(flags & FLAG_PERIODIC) > 0) {
|
|
|
|
|
|
|
|
int hour = new Date().getHours();
|
|
|
|
int hour = new Date().getHours();
|
|
|
|
if(quietHoursStart < quietHoursEnd) {
|
|
|
|
if(quietHoursStart < quietHoursEnd) {
|
|
|
|
if(hour >= quietHoursStart && hour < quietHoursEnd)
|
|
|
|
if(hour >= quietHoursStart && hour < quietHoursEnd)
|
|
|
|
@ -456,17 +455,10 @@ public class Notifications extends BroadcastReceiver {
|
|
|
|
audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0);
|
|
|
|
audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// quiet hours = no sound
|
|
|
|
if(quietHours) {
|
|
|
|
if(quietHours) {
|
|
|
|
notification.vibrate = null;
|
|
|
|
|
|
|
|
notification.sound = null;
|
|
|
|
notification.sound = null;
|
|
|
|
} else {
|
|
|
|
} 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);
|
|
|
|
Uri notificationSound = Preferences.getNotificationRingtone(context);
|
|
|
|
if(audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
|
|
|
|
if(audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
|
|
|
|
notification.sound = null;
|
|
|
|
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)
|
|
|
|
if(Constants.DEBUG)
|
|
|
|
Log.w("Astrid", "Logging notification: " + reminder);
|
|
|
|
Log.w("Astrid", "Logging notification: " + reminder);
|
|
|
|
nm.notify((int)id, notification);
|
|
|
|
nm.notify((int)id, notification);
|
|
|
|
|