Pass MasterSecret into pref fragments

Fixes #2868
Closes #2870

// FREEBIE
This commit is contained in:
Jake McGinty 2015-04-02 17:16:55 -07:00 committed by Moxie Marlinspike
parent c50658a4f5
commit 0c7dba6d43
2 changed files with 10 additions and 15 deletions

View File

@ -69,16 +69,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Bundle fragmentArgs = new Bundle();
Fragment fragment = new ApplicationPreferenceFragment();
fragmentArgs.putParcelable("master_secret", masterSecret);
fragment.setArguments(fragmentArgs);
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, fragment)
.commit();
initFragment(android.R.id.content, new ApplicationPreferenceFragment(), masterSecret);
}
@Override
@ -185,10 +176,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
fragment = new NotificationsPreferenceFragment();
break;
case PREFERENCE_CATEGORY_APP_PROTECTION:
Bundle args = new Bundle();
args.putParcelable("master_secret", masterSecret);
fragment = new AppProtectionPreferenceFragment();
fragment.setArguments(args);
break;
case PREFERENCE_CATEGORY_APPEARANCE:
fragment = new AppearancePreferenceFragment();
@ -203,6 +191,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
throw new AssertionError();
}
Bundle args = new Bundle();
args.putParcelable("master_secret", masterSecret);
fragment.setArguments(args);
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(android.R.id.content, fragment);

View File

@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.RegistrationActivity;
import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.thoughtcrime.securesms.contacts.ContactIdentityManager;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@ -39,9 +40,12 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
private static final int PICK_IDENTITY_CONTACT = 1;
private MasterSecret masterSecret;
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
masterSecret = getArguments().getParcelable("master_secret");
addPreferencesFromResource(R.xml.preferences_advanced);
initializePushMessagingToggle();
@ -186,12 +190,11 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
builder.show();
} else {
Intent nextIntent = new Intent(getActivity(), ApplicationPreferencesActivity.class);
nextIntent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
Intent intent = new Intent(getActivity(), RegistrationActivity.class);
intent.putExtra("cancel_button", true);
intent.putExtra("next_intent", nextIntent);
intent.putExtra("master_secret", getActivity().getIntent().getParcelableExtra("master_secret"));
intent.putExtra("master_secret", masterSecret);
startActivity(intent);
}