From 37513df3a8b1f25b38b58b158baac1b29991a595 Mon Sep 17 00:00:00 2001 From: Arne Jans Date: Mon, 11 Jul 2011 22:31:20 +0200 Subject: [PATCH] Fix for 13186807. New setting default is to behave as before, max-out the volumefor multiple rings. Discussion about behaviour of new setting during silent-mode is still open (see flowdock-history for this from 7/11/2011 --- .../astrid/reminders/Notifications.java | 23 +++++++++++++------ .../astrid/reminders/ReminderPreferences.java | 5 ++++ astrid/res/values-de/strings.xml | 9 +++++++- astrid/res/values/keys.xml | 3 +++ astrid/res/values/strings-reminders.xml | 7 ++++++ astrid/res/xml/preferences_reminders.xml | 4 ++++ 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java b/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java index 0fb7012dc..ad6786198 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java @@ -226,13 +226,18 @@ public class Notifications extends BroadcastReceiver { boolean voiceReminder = Preferences.getBoolean(R.string.p_voiceRemindersEnabled, false); - // if multi-ring is activated, set up the flags for insistent + // if multi-ring is activated and the setting p_rmd_maxvolume allows it, set up the flags for insistent // notification, and increase the volume to full volume, so the user // will actually pay attention to the alarm - if(ringTimes != 1 && (type != ReminderService.TYPE_RANDOM)) { + boolean maxOutVolumeForMultipleRingReminders = Preferences.getBoolean(R.string.p_rmd_maxvolume, true); + // remember it to set it to the old value after the alarm + int previousAlarmVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM); + if (ringTimes != 1 && (type != ReminderService.TYPE_RANDOM)) { notification.audioStreamType = AudioManager.STREAM_ALARM; - audioManager.setStreamVolume(AudioManager.STREAM_ALARM, - audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); + if (maxOutVolumeForMultipleRingReminders) { + audioManager.setStreamVolume(AudioManager.STREAM_ALARM, + audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); + } // insistent rings until notification is disabled if(ringTimes < 0) { @@ -251,7 +256,7 @@ public class Notifications extends BroadcastReceiver { voiceReminder = false; } else { String notificationPreference = Preferences.getStringValue(R.string.p_rmd_ringtone); - if(audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) { + if(audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) { notification.sound = null; voiceReminder = false; } else if(notificationPreference != null) { @@ -288,7 +293,7 @@ public class Notifications extends BroadcastReceiver { AndroidUtilities.sleepDeep(500); } - if (voiceReminder) { + if (voiceReminder || maxOutVolumeForMultipleRingReminders) { AndroidUtilities.sleepDeep(2000); for(int i = 0; i < 50; i++) { AndroidUtilities.sleepDeep(500); @@ -296,7 +301,11 @@ public class Notifications extends BroadcastReceiver { break; } try { - VoiceOutputService.getVoiceOutputInstance().queueSpeak(text); + // first reset the Alarm-volume to the value before it was eventually maxed out + if (maxOutVolumeForMultipleRingReminders) + audioManager.setStreamVolume(AudioManager.STREAM_ALARM, previousAlarmVolume, 0); + if (voiceReminder) + VoiceOutputService.getVoiceOutputInstance().queueSpeak(text); } catch (VerifyError e) { // unavailable } diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReminderPreferences.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReminderPreferences.java index 62f5769a1..00f3c395c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/ReminderPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/ReminderPreferences.java @@ -68,6 +68,11 @@ public class ReminderPreferences extends TodorooPreferenceActivity { preference.setSummary(r.getString(R.string.rmd_EPr_persistent_desc_true)); else preference.setSummary(r.getString(R.string.rmd_EPr_persistent_desc_false)); + } else if(r.getString(R.string.p_rmd_maxvolume).equals(preference.getKey())) { + if((Boolean)value) + preference.setSummary(r.getString(R.string.rmd_EPr_multiple_maxvolume_desc_true)); + else + preference.setSummary(r.getString(R.string.rmd_EPr_multiple_maxvolume_desc_false)); } else if(r.getString(R.string.p_rmd_vibrate).equals(preference.getKey())) { if((Boolean)value) preference.setSummary(r.getString(R.string.rmd_EPr_vibrate_desc_true)); diff --git a/astrid/res/values-de/strings.xml b/astrid/res/values-de/strings.xml index 64d60f0fa..3439742d9 100644 --- a/astrid/res/values-de/strings.xml +++ b/astrid/res/values-de/strings.xml @@ -1472,12 +1472,19 @@ Achtung: diese Aufgaben sind unwiederbringlich verloren, wenn Sie kein Backup ge Astrid\'s Notification Bar Icon auswählen + + Lautstärke hoch bei wdh. Alarm + + Astrid wird bei mehrfach alarmierenden Aufgaben laut sein + + Astrid verwendet die Lautstärke der Systemeinstellung + Vibrieren beim Alarm Astrid wird bei Benachrichtigungen vibrieren - Astrid wird bei Erinnerungen nicht vibrieren + Astrid wird bei Benachrichtigungen nicht vibrieren Astrid Ermutigungen diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 44692a983..6434e9b81 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -19,6 +19,9 @@ notif_annoy + + notif_maxvol + notif_vibrate diff --git a/astrid/res/values/strings-reminders.xml b/astrid/res/values/strings-reminders.xml index 9f2c7ab12..d6e30c821 100644 --- a/astrid/res/values/strings-reminders.xml +++ b/astrid/res/values/strings-reminders.xml @@ -97,6 +97,13 @@ Choose Astrid\'s notification bar icon + + Max volume for multiple-ring reminders + + Astrid will max out the volume for multiple-ring reminders + + Astrid will use the system-setting for the volume + Vibrate on Alert diff --git a/astrid/res/xml/preferences_reminders.xml b/astrid/res/xml/preferences_reminders.xml index ce4ad756e..61478a51a 100644 --- a/astrid/res/xml/preferences_reminders.xml +++ b/astrid/res/xml/preferences_reminders.xml @@ -21,6 +21,10 @@ +