From 59e39304dd4eb8519e8af20a881d1d3784178a01 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 27 Jun 2017 12:24:26 +0200 Subject: [PATCH] use DND instead of XA when phone is silent --- .../services/XmppConnectionService.java | 12 ++++++------ .../siacs/conversations/ui/SettingsActivity.java | 3 ++- src/main/res/values/defaults.xml | 2 ++ src/main/res/values/strings.xml | 6 +++--- src/main/res/xml/preferences.xml | 14 +++++++------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index a0173bd8d..38031d056 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -682,7 +682,7 @@ public class XmppConnectionService extends Service { sendReadMarker(c); break; case AudioManager.RINGER_MODE_CHANGED_ACTION: - if (xaOnSilentMode()) { + if (dndOnSilentMode()) { refreshAllPresences(); } break; @@ -860,8 +860,8 @@ public class XmppConnectionService extends Service { } } - private boolean xaOnSilentMode() { - return getPreferences().getBoolean("xa_on_silent_mode", false); + private boolean dndOnSilentMode() { + return getPreferences().getBoolean(SettingsActivity.DND_ON_SILENT_MODE, getResources().getBoolean(R.bool.dnd_on_silent_mode)); } private boolean manuallyChangePresence() { @@ -869,7 +869,7 @@ public class XmppConnectionService extends Service { } private boolean treatVibrateAsSilent() { - return getPreferences().getBoolean(SettingsActivity.TREAT_VIBRATE_AS_SILENT, false); + return getPreferences().getBoolean(SettingsActivity.TREAT_VIBRATE_AS_SILENT, getResources().getBoolean(R.bool.treat_vibrate_as_silent)); } private boolean awayWhenScreenOff() { @@ -881,8 +881,8 @@ public class XmppConnectionService extends Service { } private Presence.Status getTargetPresence() { - if (xaOnSilentMode() && isPhoneSilenced()) { - return Presence.Status.XA; + if (dndOnSilentMode() && isPhoneSilenced()) { + return Presence.Status.DND; } else if (awayWhenScreenOff() && !isInteractive()) { return Presence.Status.AWAY; } else { diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 28a167a3b..5aabc01dc 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -42,6 +42,7 @@ public class SettingsActivity extends XmppActivity implements public static final String KEEP_FOREGROUND_SERVICE = "enable_foreground_service"; public static final String AWAY_WHEN_SCREEN_IS_OFF = "away_when_screen_off"; public static final String TREAT_VIBRATE_AS_SILENT = "treat_vibrate_as_silent"; + public static final String DND_ON_SILENT_MODE = "dnd_on_silent_mode"; public static final String MANUALLY_CHANGE_PRESENCE = "manually_change_presence"; public static final String BLIND_TRUST_BEFORE_VERIFICATION = "btbv"; public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion"; @@ -332,7 +333,7 @@ public class SettingsActivity extends XmppActivity implements public void onSharedPreferenceChanged(SharedPreferences preferences, String name) { final List resendPresence = Arrays.asList( "confirm_messages", - "xa_on_silent_mode", + DND_ON_SILENT_MODE, AWAY_WHEN_SCREEN_IS_OFF, "allow_message_correction", TREAT_VIBRATE_AS_SILENT, diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 66601cfee..c58942c88 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -5,4 +5,6 @@ false false false + false + false diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index f27ad0d3d..a372a297f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -558,10 +558,10 @@ Presence Away when screen is off Marks your resource as away when the screen is turned off - Not available in silent mode - Marks your resource as not available when device is in silent mode + “Do not disturb” in silent mode + Marks your resource as “Do not disturb” when device is in silent mode Treat vibrate as silent mode - Marks your resource as not available when device is on vibrate + Marks your resource as “Do not disturb” when device is on vibrate Extended connection settings Show hostname and port settings when setting up an account xmpp.example.com diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 861e8a154..4efd609d6 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -256,17 +256,17 @@ android:title="@string/pref_away_when_screen_off" android:dependency="manually_change_presence"/> + android:summary="@string/pref_treat_vibrate_as_dnd_summary"/>