Refactored to reduce coupling between ChangeUnlockParcel and SaveKeyringParcel

This commit is contained in:
Alex Fong
2016-04-19 09:00:15 +08:00
parent a5a2335673
commit bc3aa44b22
12 changed files with 38 additions and 28 deletions

View File

@@ -33,6 +33,10 @@ public class ChangeUnlockParcel implements Parcelable {
// The new passphrase to use
public final Passphrase mNewPassphrase;
public ChangeUnlockParcel(Passphrase newPassphrase) {
mNewPassphrase = newPassphrase;
}
public ChangeUnlockParcel(Long masterKeyId, byte[] fingerprint, Passphrase newPassphrase) {
if (newPassphrase == null) {
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");

View File

@@ -103,11 +103,15 @@ public class SaveKeyringParcel implements Parcelable {
mKeyserver = keysever;
}
public void setNewUnlock(Passphrase passphrase) {
mNewUnlock = new ChangeUnlockParcel(mMasterKeyId, mFingerprint, passphrase);
public void setNewUnlock(ChangeUnlockParcel parcel) {
mNewUnlock = parcel;
}
public ChangeUnlockParcel getChangeUnlockParcel() {
if(mNewUnlock != null) {
mNewUnlock.mMasterKeyId = mMasterKeyId;
mNewUnlock.mFingerprint = mFingerprint;
}
return mNewUnlock;
}