use autovalue for DeleteKeyringParcel
This commit is contained in:
parent
ef366173d0
commit
68ca88c87d
|
@ -52,8 +52,8 @@ public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel>
|
|||
public OperationResult execute(DeleteKeyringParcel deleteKeyringParcel,
|
||||
CryptoInputParcel cryptoInputParcel) {
|
||||
|
||||
long[] masterKeyIds = deleteKeyringParcel.mMasterKeyIds;
|
||||
boolean isSecret = deleteKeyringParcel.mIsSecret;
|
||||
long[] masterKeyIds = deleteKeyringParcel.getMasterKeyIds();
|
||||
boolean isSecret = deleteKeyringParcel.isDeleteSecret();
|
||||
|
||||
return onlyDeleteKey(masterKeyIds, isSecret);
|
||||
}
|
||||
|
|
|
@ -19,45 +19,24 @@
|
|||
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class DeleteKeyringParcel implements Parcelable {
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
public long[] mMasterKeyIds;
|
||||
public boolean mIsSecret;
|
||||
|
||||
public DeleteKeyringParcel(long[] masterKeyIds, boolean isSecret) {
|
||||
mMasterKeyIds = masterKeyIds;
|
||||
mIsSecret = isSecret;
|
||||
@AutoValue
|
||||
public abstract class DeleteKeyringParcel implements Parcelable {
|
||||
public abstract long[] getMasterKeyIds();
|
||||
public abstract boolean isDeleteSecret();
|
||||
|
||||
|
||||
public static DeleteKeyringParcel createDeletePublicKeysParcel(long[] masterKeyIds) {
|
||||
return new AutoValue_DeleteKeyringParcel(masterKeyIds, false);
|
||||
}
|
||||
|
||||
protected DeleteKeyringParcel(Parcel in) {
|
||||
mIsSecret = in.readByte() != 0x00;
|
||||
mMasterKeyIds = in.createLongArray();
|
||||
public static DeleteKeyringParcel createDeleteSingleSecretKeyParcel(long masterKeyId) {
|
||||
return new AutoValue_DeleteKeyringParcel(new long[] { masterKeyId }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeByte((byte) (mIsSecret ? 0x01 : 0x00));
|
||||
dest.writeLongArray(mMasterKeyIds);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<DeleteKeyringParcel> CREATOR = new Parcelable.Creator<DeleteKeyringParcel>() {
|
||||
@Override
|
||||
public DeleteKeyringParcel createFromParcel(Parcel in) {
|
||||
return new DeleteKeyringParcel(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteKeyringParcel[] newArray(int size) {
|
||||
return new DeleteKeyringParcel[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -183,9 +183,12 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||
return new CryptoOperationHelper.Callback<DeleteKeyringParcel, DeleteResult>() {
|
||||
@Override
|
||||
public DeleteKeyringParcel createOperationInput() {
|
||||
return new DeleteKeyringParcel(mMasterKeyIds, mHasSecret);
|
||||
if (mHasSecret) {
|
||||
return DeleteKeyringParcel.createDeleteSingleSecretKeyParcel(mMasterKeyIds[0]);
|
||||
} else {
|
||||
return DeleteKeyringParcel.createDeletePublicKeysParcel(mMasterKeyIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCryptoOperationSuccess(DeleteResult result) {
|
||||
returnResult(result);
|
||||
|
|
Loading…
Reference in a new issue