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

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

messageview: add canceled CryptoError state

Conflicts:
	k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java
	k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java
parent b57ef10e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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,
+9 −4
Original line number Diff line number Diff line
@@ -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();