Display registered number in advanced preferences

Fixes #4504
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-11-24 14:14:07 -08:00
parent 8914c79613
commit 54b30c47f5

View File

@ -55,7 +55,6 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
masterSecret = getArguments().getParcelable("master_secret"); masterSecret = getArguments().getParcelable("master_secret");
addPreferencesFromResource(R.xml.preferences_advanced); addPreferencesFromResource(R.xml.preferences_advanced);
initializePushMessagingToggle();
initializeIdentitySelection(); initializeIdentitySelection();
Preference submitDebugLog = this.findPreference(SUBMIT_DEBUG_LOG_PREF); Preference submitDebugLog = this.findPreference(SUBMIT_DEBUG_LOG_PREF);
@ -67,6 +66,8 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__advanced); ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__advanced);
initializePushMessagingToggle();
} }
@Override @Override
@ -81,7 +82,15 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
private void initializePushMessagingToggle() { private void initializePushMessagingToggle() {
CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF); CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
preference.setChecked(TextSecurePreferences.isPushRegistered(getActivity()));
if (TextSecurePreferences.isPushRegistered(getActivity())) {
preference.setChecked(true);
preference.setSummary(TextSecurePreferences.getLocalNumber(getActivity()));
} else {
preference.setChecked(false);
preference.setSummary(R.string.preferences__free_private_messages_and_calls);
}
preference.setOnPreferenceChangeListener(new PushMessagingClickListener()); preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
} }
@ -169,8 +178,8 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
break; break;
case SUCCESS: case SUCCESS:
checkBoxPreference.setChecked(false);
TextSecurePreferences.setPushRegistered(getActivity(), false); TextSecurePreferences.setPushRegistered(getActivity(), false);
initializePushMessagingToggle();
break; break;
} }
} }