expert option to treat vibrate as silent mode for XA. fixes #1530
This commit is contained in:
parent
15a1873d97
commit
aaf64732b0
|
@ -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,8 +649,12 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
|
||||
private boolean isPhoneSilenced() {
|
||||
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
if (treatVibrateAsSilent()) {
|
||||
return audioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
|
||||
} else {
|
||||
return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT;
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAllAttemptCounts(boolean reallyAll) {
|
||||
Log.d(Config.LOGTAG, "resetting all attepmt counts");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -536,6 +536,8 @@
|
|||
<string name="pref_away_when_screen_off_summary">Marks your resource as away when the screen is turned off</string>
|
||||
<string name="pref_xa_on_silent_mode">Not available in silent mode</string>
|
||||
<string name="pref_xa_on_silent_mode_summary">Marks your resource as not available when device is in silent mode</string>
|
||||
<string name="pref_treat_vibrate_as_silent">Treat vibrate as silent mode</string>
|
||||
<string name="pref_treat_vibrate_as_silent_summary">Marks your resource as not available when device is on vibrate</string>
|
||||
<string name="pref_show_connection_options">Extended connection settings</string>
|
||||
<string name="pref_show_connection_options_summary">Show hostname and port settings when setting up an account</string>
|
||||
<string name="hostname_example">xmpp.example.com</string>
|
||||
|
|
|
@ -189,6 +189,12 @@
|
|||
android:key="xa_on_silent_mode"
|
||||
android:summary="@string/pref_xa_on_silent_mode_summary"
|
||||
android:title="@string/pref_xa_on_silent_mode"/>
|
||||
<CheckBoxPreference
|
||||
android:dependency="xa_on_silent_mode"
|
||||
android:defaultValue="false"
|
||||
android:key="treat_vibrate_as_silent"
|
||||
android:title="@string/pref_treat_vibrate_as_silent"
|
||||
android:summary="@string/pref_treat_vibrate_as_silent_summary"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_expert_options_other">
|
||||
<CheckBoxPreference
|
||||
|
|
Loading…
Reference in New Issue