Fix and simplify in OperationResultParcel

This commit is contained in:
Dominik Schürmann 2014-08-16 12:13:30 +02:00
parent 2497722b48
commit 188eeb79c9

View File

@ -28,6 +28,7 @@ import com.github.johnpersano.supertoasts.SuperToast;
import com.github.johnpersano.supertoasts.util.OnClickWrapper; import com.github.johnpersano.supertoasts.util.OnClickWrapper;
import com.github.johnpersano.supertoasts.util.Style; import com.github.johnpersano.supertoasts.util.Style;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.KeyRing;
@ -190,13 +191,13 @@ public abstract class OperationResults {
public static class EditKeyResult extends OperationResultParcel { public static class EditKeyResult extends OperationResultParcel {
private transient UncachedKeyRing mRing; private transient UncachedKeyRing mRing;
public final Long mRingMasterKeyId; public final long mRingMasterKeyId;
public EditKeyResult(int result, OperationLog log, public EditKeyResult(int result, OperationLog log,
UncachedKeyRing ring) { UncachedKeyRing ring) {
super(result, log); super(result, log);
mRing = ring; mRing = ring;
mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : null; mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
} }
public UncachedKeyRing getRing() { public UncachedKeyRing getRing() {
@ -205,19 +206,14 @@ public abstract class OperationResults {
public EditKeyResult(Parcel source) { public EditKeyResult(Parcel source) {
super(source); super(source);
mRingMasterKeyId = source.readInt() != 0 ? source.readLong() : null; mRingMasterKeyId = source.readLong();
} }
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags); super.writeToParcel(dest, flags);
if (mRingMasterKeyId == null) {
dest.writeInt(0);
} else {
dest.writeInt(1);
dest.writeLong(mRingMasterKeyId); dest.writeLong(mRingMasterKeyId);
} }
}
public static Creator<EditKeyResult> CREATOR = new Creator<EditKeyResult>() { public static Creator<EditKeyResult> CREATOR = new Creator<EditKeyResult>() {
public EditKeyResult createFromParcel(final Parcel source) { public EditKeyResult createFromParcel(final Parcel source) {
@ -234,12 +230,12 @@ public abstract class OperationResults {
public static class SaveKeyringResult extends OperationResultParcel { public static class SaveKeyringResult extends OperationResultParcel {
public final Long mRingMasterKeyId; public final long mRingMasterKeyId;
public SaveKeyringResult(int result, OperationLog log, public SaveKeyringResult(int result, OperationLog log,
CanonicalizedKeyRing ring) { CanonicalizedKeyRing ring) {
super(result, log); super(result, log);
mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : null; mRingMasterKeyId = ring != null ? ring.getMasterKeyId() : Constants.key.none;
} }
// Some old key was updated // Some old key was updated