From ffc5ba2cf36e8eb25fc981938aa7b6f997697c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 21 Mar 2015 15:40:15 +0100 Subject: [PATCH] PGP: Set correct encryption state in message crypto annotation via RESULT_TYPE --- .../fsck/k9/ui/crypto/MessageCryptoHelper.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 4a8792cb6..8f12d1b5e 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 @@ -403,12 +403,18 @@ public class MessageCryptoHelper { resultAnnotation.setOutputData(outputPart); - // TODO if the data /was/ encrypted, we should set it here! - // this is not easy to determine for inline data though - resultAnnotation.setWasEncrypted(false); - - OpenPgpSignatureResult signatureResult = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); - resultAnnotation.setSignatureResult(signatureResult); + int resultType = currentCryptoResult.getIntExtra(OpenPgpApi.RESULT_TYPE, + OpenPgpApi.RESULT_TYPE_UNENCRYPTED_UNSIGNED); + if ((resultType & OpenPgpApi.RESULT_TYPE_ENCRYPTED) == OpenPgpApi.RESULT_TYPE_ENCRYPTED) { + resultAnnotation.setWasEncrypted(true); + } else { + resultAnnotation.setWasEncrypted(false); + } + if ((resultType & OpenPgpApi.RESULT_TYPE_SIGNED) == OpenPgpApi.RESULT_TYPE_SIGNED) { + OpenPgpSignatureResult signatureResult = + currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); + resultAnnotation.setSignatureResult(signatureResult); + } PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT); resultAnnotation.setPendingIntent(pendingIntent);