Add notification priority option

pull/384/head
Alex Baker 10 years ago
parent e7efefb88d
commit 947276856a

@ -12,6 +12,7 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import org.tasks.time.DateTime; import org.tasks.time.DateTime;
import org.tasks.R; import org.tasks.R;
@ -45,8 +46,10 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
addPreferencesFromResource(R.xml.preferences_reminders); addPreferencesFromResource(R.xml.preferences_reminders);
PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preJellybean()) { if (preJellybean()) {
getPreferenceScreen().removePreference(findPreference(getString(R.string.p_rmd_notif_actions_enabled))); preferenceScreen.removePreference(findPreference(getString(R.string.p_rmd_notif_actions_enabled)));
preferenceScreen.removePreference(findPreference(getString(R.string.p_notification_priority)));
} }
if (deviceInfo.supportsLocationServices()) { if (deviceInfo.supportsLocationServices()) {
@ -54,7 +57,7 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
setExtraOnChange(R.string.p_geofence_responsiveness, RESET_GEOFENCES); setExtraOnChange(R.string.p_geofence_responsiveness, RESET_GEOFENCES);
setExtraOnChange(R.string.p_geofence_reminders_enabled, TOGGLE_GEOFENCES); setExtraOnChange(R.string.p_geofence_reminders_enabled, TOGGLE_GEOFENCES);
} else { } else {
getPreferenceScreen().removePreference(findPreference(getString(R.string.geolocation_reminders))); preferenceScreen.removePreference(findPreference(getString(R.string.geolocation_reminders)));
} }
initializeRingtonePreference(); initializeRingtonePreference();

@ -43,6 +43,7 @@ import java.io.InputStream;
import javax.inject.Inject; import javax.inject.Inject;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean;
import static org.tasks.time.DateTimeUtils.currentTimeMillis; import static org.tasks.time.DateTimeUtils.currentTimeMillis;
public class Notifier { public class Notifier {
@ -58,7 +59,7 @@ public class Notifier {
private final TelephonyManager telephonyManager; private final TelephonyManager telephonyManager;
private final AudioManager audioManager; private final AudioManager audioManager;
private final VoiceOutputAssistant voiceOutputAssistant; private final VoiceOutputAssistant voiceOutputAssistant;
private Preferences preferences; private final Preferences preferences;
@Inject @Inject
public Notifier(@ForApplication Context context, TaskDao taskDao, public Notifier(@ForApplication Context context, TaskDao taskDao,
@ -279,6 +280,20 @@ public class Notifier {
notification.defaults = Notification.DEFAULT_LIGHTS; notification.defaults = Notification.DEFAULT_LIGHTS;
} }
if (atLeastJellybean()) {
switch (preferences.getNotificationPriority()) {
case 0:
notification.priority = NotificationCompat.PRIORITY_DEFAULT;
break;
case -1:
notification.priority = NotificationCompat.PRIORITY_LOW;
break;
default:
notification.priority = NotificationCompat.PRIORITY_HIGH;
break;
}
}
boolean voiceReminder = preferences.getBoolean(R.string.p_voiceRemindersEnabled, false) && !isNullOrEmpty(text); boolean voiceReminder = preferences.getBoolean(R.string.p_voiceRemindersEnabled, false) && !isNullOrEmpty(text);
// if multi-ring is activated and the setting p_rmd_maxvolume allows it, 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

@ -96,6 +96,10 @@ public class Preferences {
return defaultCalendar != null && !defaultCalendar.equals("-1") && !defaultCalendar.equals("0"); return defaultCalendar != null && !defaultCalendar.equals("-1") && !defaultCalendar.equals("0");
} }
public int getNotificationPriority() {
return getInt(R.string.p_notification_priority, 1);
}
public String getDefaultCalendar() { public String getDefaultCalendar() {
return getStringValue(R.string.gcal_p_default); return getStringValue(R.string.gcal_p_default);
} }

@ -240,6 +240,7 @@
<string name="p_show_completed_tasks">show_completed_tasks</string> <string name="p_show_completed_tasks">show_completed_tasks</string>
<string name="p_reverse_sort">reverse_sort</string> <string name="p_reverse_sort">reverse_sort</string>
<string name="p_manual_sort">manual_sort</string> <string name="p_manual_sort">manual_sort</string>
<string name="p_notification_priority">notification_priority</string>
<string-array name="TEA_control_sets_prefs"> <string-array name="TEA_control_sets_prefs">
<item>@string/TEA_ctrl_when_pref</item> <item>@string/TEA_ctrl_when_pref</item>
@ -261,4 +262,16 @@
<item>@string/ring_nonstop</item> <item>@string/ring_nonstop</item>
</string-array> </string-array>
<string-array name="notification_priority_entries">
<item>@string/high_priority</item>
<item>@string/default_priority</item>
<item>@string/low_priority</item>
</string-array>
<string-array name="notification_priority_values">
<item>1</item>
<item>0</item>
<item>-1</item>
</string-array>
</resources> </resources>

@ -123,6 +123,10 @@
<string name="get_plugins">Get Plug-ins</string> <string name="get_plugins">Get Plug-ins</string>
<string name="no_application_found">No application found to open attachment</string> <string name="no_application_found">No application found to open attachment</string>
<string name="add_attachment">Add attachment</string> <string name="add_attachment">Add attachment</string>
<string name="high_priority">High</string>
<string name="default_priority">Default</string>
<string name="low_priority">Low</string>
<string name="notification_priority">Notification Priority</string>
<string-array name="sync_SPr_interval_entries"> <string-array name="sync_SPr_interval_entries">
<!-- sync_SPr_interval_entries: Synchronization Intervals --> <!-- sync_SPr_interval_entries: Synchronization Intervals -->

@ -12,6 +12,13 @@
android:defaultValue="true" android:defaultValue="true"
android:key="@string/p_rmd_enabled" android:key="@string/p_rmd_enabled"
android:title="@string/enabled" /> android:title="@string/enabled" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="1"
android:dependency="@string/p_rmd_enabled"
android:entries="@array/notification_priority_entries"
android:entryValues="@array/notification_priority_values"
android:key="@string/p_notification_priority"
android:title="@string/notification_priority" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:dependency="@string/p_rmd_enabled" android:dependency="@string/p_rmd_enabled"

Loading…
Cancel
Save