use autovalue for DeleteKeyringParcel
This commit is contained in:
@@ -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];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user