Move SMS/MMS pref hiding logic to onCreate

Closes #6528
// FREEBIE
This commit is contained in:
Mateo Hernandez 2017-04-15 11:58:26 -05:00 committed by Moxie Marlinspike
parent a353ebd834
commit f07ce7b1f1

View File

@ -31,6 +31,8 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
this.findPreference(MMS_PREF) this.findPreference(MMS_PREF)
.setOnPreferenceClickListener(new ApnPreferencesClickListener()); .setOnPreferenceClickListener(new ApnPreferencesClickListener());
initializePlatformSpecificOptions();
} }
@Override @Override
@ -38,7 +40,7 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
super.onResume(); super.onResume();
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__sms_mms); ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__sms_mms);
initializePlatformSpecificOptions(); initializeDefaultPreference();
} }
private void initializePlatformSpecificOptions() { private void initializePlatformSpecificOptions() {
@ -51,7 +53,19 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference); if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference);
if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference); if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference);
} else if (defaultPreference != null) {
preferenceScreen.removePreference(defaultPreference);
}
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && manualMmsPreference != null) {
preferenceScreen.removePreference(manualMmsPreference);
}
}
private void initializeDefaultPreference() {
if (VERSION.SDK_INT < VERSION_CODES.KITKAT) return;
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
if (Util.isDefaultSmsProvider(getActivity())) { if (Util.isDefaultSmsProvider(getActivity())) {
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled)); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
@ -63,13 +77,6 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled)); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app)); defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
} }
} else if (defaultPreference != null) {
preferenceScreen.removePreference(defaultPreference);
}
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && manualMmsPreference != null) {
preferenceScreen.removePreference(manualMmsPreference);
}
} }
private class ApnPreferencesClickListener implements Preference.OnPreferenceClickListener { private class ApnPreferencesClickListener implements Preference.OnPreferenceClickListener {