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)
.setOnPreferenceClickListener(new ApnPreferencesClickListener());
initializePlatformSpecificOptions();
}
@Override
@ -38,7 +40,7 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
super.onResume();
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__sms_mms);
initializePlatformSpecificOptions();
initializeDefaultPreference();
}
private void initializePlatformSpecificOptions() {
@ -51,18 +53,6 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference);
if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference);
if (Util.isDefaultSmsProvider(getActivity())) {
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
} else {
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
defaultPreference.setIntent(intent);
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
}
} else if (defaultPreference != null) {
preferenceScreen.removePreference(defaultPreference);
}
@ -72,6 +62,23 @@ public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
}
}
private void initializeDefaultPreference() {
if (VERSION.SDK_INT < VERSION_CODES.KITKAT) return;
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
if (Util.isDefaultSmsProvider(getActivity())) {
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
} else {
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
defaultPreference.setIntent(intent);
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
}
}
private class ApnPreferencesClickListener implements Preference.OnPreferenceClickListener {
@Override