diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-03-01 19:00:18 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-03-01 19:00:18 +0100 |
commit | aaf64732b0e04d0b95407c5420da08c8c1752ec6 (patch) | |
tree | 5522e5795ca359d0e3272cf6f9d3eb5ac006e8d5 /src/main/java/eu/siacs/conversations | |
parent | 15a1873d97b49293d025be09d9b135c6871a6da5 (diff) |
expert option to treat vibrate as silent mode for XA. fixes #1530
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 10 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/SettingsActivity.java | 15 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 85eb479fd..07a7e10b8 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -611,6 +611,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return getPreferences().getBoolean("xa_on_silent_mode", false); } + private boolean treatVibrateAsSilent() { + return getPreferences().getBoolean("treat_vibrate_as_silent", false); + } + private boolean awayWhenScreenOff() { return getPreferences().getBoolean("away_when_screen_off", false); } @@ -645,7 +649,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa private boolean isPhoneSilenced() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); - return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; + if (treatVibrateAsSilent()) { + return audioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; + } else { + return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; + } } private void resetAllAttemptCounts(boolean reallyAll) { diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index c028d0d69..750a74212 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -21,6 +21,7 @@ import java.security.KeyStoreException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Locale; import de.duenndns.ssl.MemorizingTrustManager; @@ -154,8 +155,13 @@ public class SettingsActivity extends XmppActivity implements } @Override - public void onSharedPreferenceChanged(SharedPreferences preferences, - String name) { + public void onSharedPreferenceChanged(SharedPreferences preferences, String name) { + final List<String> resendPresence = Arrays.asList( + "confirm_messages", + "xa_on_silent_mode", + "away_when_screen_off", + "allow_message_correction", + "treat_vibrate_as_silent"); if (name.equals("resource")) { String resource = preferences.getString("resource", "mobile") .toLowerCase(Locale.US); @@ -174,10 +180,7 @@ public class SettingsActivity extends XmppActivity implements } } else if (name.equals("keep_foreground_service")) { xmppConnectionService.toggleForegroundService(); - } else if (name.equals("confirm_messages") - || name.equals("xa_on_silent_mode") - || name.equals("away_when_screen_off") - || name.equals("allow_message_correction")) { + } else if (resendPresence.contains(name)) { if (xmppConnectionServiceBound) { if (name.equals("away_when_screen_off")) { xmppConnectionService.toggleScreenEventReceiver(); |