diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java b/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java index e2b68b25b..1c2111a70 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java @@ -68,6 +68,10 @@ public final class CryptoResultAnnotation { return new CryptoResultAnnotation(error, replacementData, null, null, null, null); } + public static CryptoResultAnnotation createOpenPgpCanceledAnnotation() { + return new CryptoResultAnnotation(CryptoError.OPENPGP_UI_CANCELED, null, null, null, null, null); + } + public static CryptoResultAnnotation createOpenPgpErrorAnnotation(OpenPgpError error) { return new CryptoResultAnnotation(CryptoError.OPENPGP_API_RETURNED_ERROR, null, null, null, null, error); } @@ -131,6 +135,7 @@ public final class CryptoResultAnnotation { public enum CryptoError { NONE, + OPENPGP_UI_CANCELED, OPENPGP_API_RETURNED_ERROR, SIGNED_BUT_INCOMPLETE, ENCRYPTED_BUT_INCOMPLETE, diff --git a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java index 19e232f19..3bb00d899 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java @@ -20,7 +20,6 @@ import android.util.Log; import com.fsck.k9.Account; import com.fsck.k9.K9; -import com.fsck.k9.R; import com.fsck.k9.crypto.MessageDecryptVerifier; import com.fsck.k9.mail.Body; import com.fsck.k9.mail.BodyPart; @@ -440,7 +439,7 @@ public class MessageCryptoHelper { Log.w(K9.LOG_TAG, "OpenPGP API error: " + error.getMessage()); } - onCryptoFailed(error); + onCryptoOperationFailed(error); } private void handleCryptoOperationSuccess(MimeBodyPart outputPart) { @@ -465,7 +464,7 @@ public class MessageCryptoHelper { userInteractionResultIntent = data; decryptOrVerifyNextPart(); } else { - onCryptoFailed(new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, context.getString(R.string.openpgp_canceled_by_user))); + onCryptoOperationCanceled(); } } @@ -485,7 +484,13 @@ public class MessageCryptoHelper { } } - private void onCryptoFailed(OpenPgpError error) { + private void onCryptoOperationCanceled() { + CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpCanceledAnnotation(); + addCryptoResultAnnotationToMessage(errorPart); + onCryptoFinished(); + } + + private void onCryptoOperationFailed(OpenPgpError error) { CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpErrorAnnotation(error); addCryptoResultAnnotationToMessage(errorPart); onCryptoFinished();