diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-14 01:14:58 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-14 01:14:58 +0200 |
commit | 36ef8a9a62f32f0843c9e317d493a7f136624dce (patch) | |
tree | 7d139791b132f62397ad09d41b8b24cde0a436b7 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results | |
parent | 03d103af0722540c0f636c139fac33d3ffb28a34 (diff) | |
download | open-keychain-36ef8a9a62f32f0843c9e317d493a7f136624dce.tar.gz open-keychain-36ef8a9a62f32f0843c9e317d493a7f136624dce.tar.bz2 open-keychain-36ef8a9a62f32f0843c9e317d493a7f136624dce.zip |
work on OperationResultParcel
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java | 2 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java | 2 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java | 2 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java | 4 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java) | 36 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java | 2 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java | 5 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java | 2 |
8 files changed, 22 insertions, 33 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java index 31f4cabc3..44177563f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ConsolidateResult.java @@ -18,7 +18,7 @@ package org.sufficientlysecure.keychain.service.results; -public class ConsolidateResult extends OperationResultParcel { +public class ConsolidateResult extends OperationResult { public ConsolidateResult(int result, OperationLog log) { super(result, log); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java index 7339f1306..18533ffe6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java @@ -23,7 +23,7 @@ import android.os.Parcel; import org.openintents.openpgp.OpenPgpMetadata; import org.openintents.openpgp.OpenPgpSignatureResult; -public class DecryptVerifyResult extends OperationResultParcel { +public class DecryptVerifyResult extends OperationResult { // the fourth bit indicates a "data pending" result! (it's also a form of non-success) public static final int RESULT_PENDING = RESULT_ERROR +8; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java index 169ed9f36..9385afd8e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/EditKeyResult.java @@ -23,7 +23,7 @@ import android.os.Parcel; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; -public class EditKeyResult extends OperationResultParcel { +public class EditKeyResult extends OperationResult { private transient UncachedKeyRing mRing; public final long mRingMasterKeyId; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java index 62b5b1b52..ec9c424cf 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/ImportKeyResult.java @@ -34,7 +34,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.LogDisplayActivity; import org.sufficientlysecure.keychain.ui.LogDisplayFragment; -public class ImportKeyResult extends OperationResultParcel { +public class ImportKeyResult extends OperationResult { public final int mNewKeys, mUpdatedKeys, mBadKeys, mSecret; @@ -109,7 +109,7 @@ public class ImportKeyResult extends OperationResultParcel { int duration, color; // Not an overall failure - if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) { + if ((resultType & OperationResult.RESULT_ERROR) == 0) { String withWarnings; duration = Duration.EXTRA_LONG; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java index 56f5248cb..d2be1466f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResultParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/OperationResult.java @@ -52,7 +52,7 @@ import java.util.List; * TODO ideally, this class should be abstract, and all actual results of a specific subclass * */ -public class OperationResultParcel implements Parcelable { +public abstract class OperationResult implements Parcelable { public static final String EXTRA_RESULT = "operation_result"; @@ -71,12 +71,12 @@ public class OperationResultParcel implements Parcelable { /// A list of log entries tied to the operation result. final OperationLog mLog; - public OperationResultParcel(int result, OperationLog log) { + public OperationResult(int result, OperationLog log) { mResult = result; mLog = log; } - public OperationResultParcel(Parcel source) { + public OperationResult(Parcel source) { mResult = source.readInt(); mLog = new OperationLog(); mLog.addAll(source.createTypedArrayList(LogEntryParcel.CREATOR)); @@ -156,25 +156,22 @@ public class OperationResultParcel implements Parcelable { public SuperCardToast createNotify(final Activity activity) { - String str; int color; + // Take the last message as string + String str = activity.getString(mLog.getLast().mType.getMsgId()); + // Not an overall failure if (cancelled()) { color = Style.RED; - str = "operation cancelled!"; } else if (success()) { if (getLog().containsWarnings()) { color = Style.ORANGE; } else { color = Style.GREEN; } - str = "operation succeeded!"; - // str = activity.getString(R.string.import_error); } else { color = Style.RED; - str = "operation failed"; - // str = activity.getString(R.string.import_error); } boolean button = getLog() != null && !getLog().isEmpty(); @@ -197,7 +194,7 @@ public class OperationResultParcel implements Parcelable { public void onClick(View view, Parcelable token) { Intent intent = new Intent( activity, LogDisplayActivity.class); - intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResultParcel.this); + intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResult.this); activity.startActivity(intent); } } @@ -498,6 +495,11 @@ public class OperationResultParcel implements Parcelable { MSG_SE_SIGCRYPTING (R.string.msg_se_sigcrypting), MSG_SE_SYMMETRIC (R.string.msg_se_symmetric), + MSG_CRT_UPLOAD_SUCCESS (R.string.msg_crt_upload_success), + MSG_CRT_SUCCESS (R.string.msg_crt_success), + + MSG_ACC_SAVED (R.string.api_settings_save) + ; private final int mMsgId; @@ -533,27 +535,17 @@ public class OperationResultParcel implements Parcelable { } } - public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() { - public OperationResultParcel createFromParcel(final Parcel source) { - return new OperationResultParcel(source); - } - - public OperationResultParcel[] newArray(final int size) { - return new OperationResultParcel[size]; - } - }; - public static class OperationLog implements Iterable<LogEntryParcel> { private final List<LogEntryParcel> mParcels = new ArrayList<LogEntryParcel>(); /// Simple convenience method public void add(LogLevel level, LogType type, int indent, Object... parameters) { - mParcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, parameters)); + mParcels.add(new OperationResult.LogEntryParcel(level, type, indent, parameters)); } public void add(LogLevel level, LogType type, int indent) { - mParcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, (Object[]) null)); + mParcels.add(new OperationResult.LogEntryParcel(level, type, indent, (Object[]) null)); } public boolean containsType(LogType type) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java index 0edb9c617..e229a5c6a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SaveKeyringResult.java @@ -23,7 +23,7 @@ import android.os.Parcel; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; -public class SaveKeyringResult extends OperationResultParcel { +public class SaveKeyringResult extends OperationResult { public final long mRingMasterKeyId; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java index 100a7c675..9d492e545 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SignEncryptResult.java @@ -19,12 +19,9 @@ package org.sufficientlysecure.keychain.service.results; import android.os.Parcel; -import org.openintents.openpgp.OpenPgpMetadata; -import org.openintents.openpgp.OpenPgpSignatureResult; - import java.util.Date; -public class SignEncryptResult extends OperationResultParcel { +public class SignEncryptResult extends OperationResult { // the fourth bit indicates a "data pending" result! (it's also a form of non-success) public static final int RESULT_PENDING = RESULT_ERROR +8; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java index 5022c46a7..38b2e4bc3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/SingletonResult.java @@ -27,7 +27,7 @@ import com.github.johnpersano.supertoasts.util.Style; /** This is a simple subclass meant to contain only a single log message. This log * message is also shown without a log button in the createNotify SuperToast. */ -public class SingletonResult extends OperationResultParcel { +public class SingletonResult extends OperationResult { /** Construct from a parcel - trivial because we have no extra data. */ public SingletonResult(Parcel source) { |