Add preference to disable the SMS channel all together.

1) If the SMS fallback preference is disabled, no outgoing
   messages will succeed via the SMS transport.

2) If the SMS fallback preference is disabled, "mirroring" the
   SMS db state when not the default system SMS app is disabled.
This commit is contained in:
Moxie Marlinspike
2014-02-20 14:49:31 -08:00
parent c5821f770a
commit 918f223149
8 changed files with 66 additions and 14 deletions

View File

@@ -100,6 +100,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
initializeIdentitySelection();
initializePlatformSpecificOptions();
initializeSmsFallbackOption();
initializePushMessagingToggle();
this.findPreference(TextSecurePreferences.CHANGE_PASSPHRASE_PREF)
@@ -178,8 +179,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
}
private void initializePlatformSpecificOptions() {
PreferenceGroup generalCategory = (PreferenceGroup)findPreference("general_category");
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
PreferenceGroup generalCategory = (PreferenceGroup) findPreference("general_category");
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
generalCategory.removePreference(findPreference(TextSecurePreferences.ALL_SMS_PREF));
@@ -198,6 +199,29 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
}
}
private void initializeSmsFallbackOption() {
CheckBoxPreference allowSmsPreference =
(CheckBoxPreference) findPreference(TextSecurePreferences.ALLOW_SMS_FALLBACK_PREF);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (Util.isDefaultSmsProvider(this) || !TextSecurePreferences.isPushRegistered(this)) {
allowSmsPreference.setEnabled(false);
allowSmsPreference.setChecked(true);
} else {
allowSmsPreference.setEnabled(true);
}
} else {
if (TextSecurePreferences.isInterceptAllMmsEnabled(this) ||
TextSecurePreferences.isInterceptAllSmsEnabled(this))
{
allowSmsPreference.setEnabled(false);
allowSmsPreference.setChecked(true);
} else {
allowSmsPreference.setEnabled(true);
}
}
}
private void initializeEditTextSummary(final EditTextPreference preference) {
if (preference.getText() == null) {
preference.setSummary("Not set");
@@ -268,6 +292,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
dynamicTheme.onResume(this);
} else if (key.equals(TextSecurePreferences.LANGUAGE_PREF)) {
dynamicLanguage.onResume(this);
} else if (key.equals(TextSecurePreferences.ALL_MMS_PREF) ||
key.equals(TextSecurePreferences.ALL_SMS_PREF))
{
initializeSmsFallbackOption();
}
}