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 28ce1a98b..174f21620 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/CryptoResultAnnotation.java @@ -159,5 +159,6 @@ public final class CryptoResultAnnotation { OPENPGP_ENCRYPTED_BUT_INCOMPLETE, SIGNED_BUT_UNSUPPORTED, ENCRYPTED_BUT_UNSUPPORTED, + OPENPGP_ENCRYPTED_NO_PROVIDER, } } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoSplitter.java b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoSplitter.java index cc6afc3c0..e0ef238fb 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoSplitter.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoSplitter.java @@ -12,6 +12,7 @@ import com.fsck.k9.crypto.MessageDecryptVerifier; import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Part; import com.fsck.k9.mailstore.CryptoResultAnnotation; +import com.fsck.k9.mailstore.CryptoResultAnnotation.CryptoError; public class MessageCryptoSplitter { @@ -19,20 +20,21 @@ public class MessageCryptoSplitter { @Nullable public static CryptoMessageParts split(@NonNull Message message, @Nullable MessageCryptoAnnotations annotations) { - if (annotations == null) { + ArrayList extraParts = new ArrayList<>(); + Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts); + if (primaryPart == null) { return null; } - ArrayList extraParts = new ArrayList<>(); - Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts); - - if (!annotations.has(primaryPart)) { - return null; + if (annotations == null) { + CryptoResultAnnotation rootPartAnnotation = + CryptoResultAnnotation.createErrorAnnotation(CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null); + return new CryptoMessageParts(primaryPart, rootPartAnnotation, extraParts); } CryptoResultAnnotation rootPartAnnotation = annotations.get(primaryPart); Part rootPart; - if (rootPartAnnotation.hasReplacementData()) { + if (rootPartAnnotation != null && rootPartAnnotation.hasReplacementData()) { rootPart = rootPartAnnotation.getReplacementData(); } else { rootPart = primaryPart; @@ -43,11 +45,12 @@ public class MessageCryptoSplitter { public static class CryptoMessageParts { public final Part contentPart; + @Nullable public final CryptoResultAnnotation contentCryptoAnnotation; public final List extraParts; - CryptoMessageParts(Part contentPart, CryptoResultAnnotation contentCryptoAnnotation, List extraParts) { + CryptoMessageParts(Part contentPart, @Nullable CryptoResultAnnotation contentCryptoAnnotation, List extraParts) { this.contentPart = contentPart; this.contentCryptoAnnotation = contentCryptoAnnotation; this.extraParts = Collections.unmodifiableList(extraParts); diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java index f09bbfec7..4f4c3f4a0 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java @@ -116,6 +116,11 @@ public class MessageCryptoPresenter implements OnCryptoClickListener { break; } + case ENCRYPTED_NO_PROVIDER: { + messageView.showNoCryptoProviderConfigured(messageViewInfo); + break; + } + case INCOMPLETE_SIGNED: case UNSUPPORTED_SIGNED: default: { diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java index e934900b7..683cada0c 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java @@ -189,6 +189,21 @@ public class MessageTopView extends LinearLayout { displayViewOnLoadFinished(false); } + public void showNoCryptoProviderConfigured(MessageViewInfo messageViewInfo) { + resetAndPrepareMessageView(messageViewInfo); + View view = mInflater.inflate(R.layout.message_content_crypto_no_provider, containerView, false); + + view.findViewById(R.id.crypto_settings).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + // TODO + } + }); + + containerView.addView(view); + displayViewOnLoadFinished(false); + } + private void setCryptoProviderIcon(Drawable openPgpApiProviderIcon, View view) { ImageView cryptoProviderIcon = (ImageView) view.findViewById(R.id.crypto_error_icon); if (openPgpApiProviderIcon != null) { diff --git a/k9mail/src/main/java/com/fsck/k9/view/MessageCryptoDisplayStatus.java b/k9mail/src/main/java/com/fsck/k9/view/MessageCryptoDisplayStatus.java index 69141182c..178fbd41e 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/MessageCryptoDisplayStatus.java +++ b/k9mail/src/main/java/com/fsck/k9/view/MessageCryptoDisplayStatus.java @@ -136,6 +136,12 @@ public enum MessageCryptoDisplayStatus { R.string.crypto_msg_signed_unencrypted, R.string.crypto_msg_sign_incomplete ), + ENCRYPTED_NO_PROVIDER ( + R.attr.openpgp_red, + R.drawable.status_lock_error, + R.string.crypto_msg_unsupported_encrypted + ), + UNSUPPORTED_ENCRYPTED ( R.attr.openpgp_red, R.drawable.status_lock_error, @@ -214,6 +220,9 @@ public enum MessageCryptoDisplayStatus { case OPENPGP_ENCRYPTED_API_ERROR: return ENCRYPTED_ERROR; + + case OPENPGP_ENCRYPTED_NO_PROVIDER: + return ENCRYPTED_NO_PROVIDER; } throw new IllegalStateException("Unhandled case!"); } diff --git a/k9mail/src/main/res/layout/message_content_crypto_no_provider.xml b/k9mail/src/main/res/layout/message_content_crypto_no_provider.xml new file mode 100644 index 000000000..caf1f91ba --- /dev/null +++ b/k9mail/src/main/res/layout/message_content_crypto_no_provider.xml @@ -0,0 +1,38 @@ + + + + + + + +