Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2186058 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

add screen to display when no crypto provider is configured

parent 8ee9b2c5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -159,5 +159,6 @@ public final class CryptoResultAnnotation {
        OPENPGP_ENCRYPTED_BUT_INCOMPLETE,
        SIGNED_BUT_UNSUPPORTED,
        ENCRYPTED_BUT_UNSUPPORTED,
        OPENPGP_ENCRYPTED_NO_PROVIDER,
    }
}
+11 −8
Original line number Diff line number Diff line
@@ -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) {
            return null;
        }

        ArrayList<Part> extraParts = new ArrayList<>();
        Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts);

        if (!annotations.has(primaryPart)) {
        if (primaryPart == null) {
            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<Part> extraParts;

        CryptoMessageParts(Part contentPart, CryptoResultAnnotation contentCryptoAnnotation, List<Part> extraParts) {
        CryptoMessageParts(Part contentPart, @Nullable CryptoResultAnnotation contentCryptoAnnotation, List<Part> extraParts) {
            this.contentPart = contentPart;
            this.contentCryptoAnnotation = contentCryptoAnnotation;
            this.extraParts = Collections.unmodifiableList(extraParts);
+5 −0
Original line number Diff line number Diff line
@@ -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: {
+15 −0
Original line number Diff line number Diff line
@@ -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) {
+9 −0
Original line number Diff line number Diff line
@@ -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!");
    }
Loading