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

Commit 0378f1a8 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

Prevent pgp/inline in sign-only mode and vice versa

parent b72a3ce8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -335,7 +335,15 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
        Toast.makeText(activity, R.string.compose_error_private_missing_keys, Toast.LENGTH_LONG).show();
    }

    public void showErrorAttachInline() {
    public void showErrorSignOnlyInline() {
        Toast.makeText(activity, R.string.error_crypto_sign_only_inline, Toast.LENGTH_LONG).show();
    }

    public void showErrorInlineSignOnly() {
        Toast.makeText(activity, R.string.error_crypto_inline_sign_only, Toast.LENGTH_LONG).show();
    }

    public void showErrorInlineAttach() {
        Toast.makeText(activity, R.string.error_crypto_inline_attach, Toast.LENGTH_LONG).show();
    }

+18 −3
Original line number Diff line number Diff line
@@ -602,7 +602,7 @@ public class RecipientPresenter implements PermissionPingCallback {
    public void showPgpAttachError(AttachErrorState attachErrorState) {
        switch (attachErrorState) {
            case IS_INLINE:
                recipientMvpView.showErrorAttachInline();
                recipientMvpView.showErrorInlineAttach();
                break;
            default:
                throw new AssertionError("not all error states handled, this is a bug!");
@@ -721,8 +721,17 @@ public class RecipientPresenter implements PermissionPingCallback {
    }

    public void onMenuSetPgpInline(boolean enablePgpInline) {
        cryptoEnablePgpInline = enablePgpInline;
        updateCryptoStatus();
        if (getCurrentCryptoStatus().isSignOnly()) {
            if (cryptoEnablePgpInline) {
                Log.e(K9.LOG_TAG, "Inconsistent state: PGP/INLINE was enabled in sign-only mode!");
                onCryptoPgpInlineChanged(false);
            }

            recipientMvpView.showErrorSignOnlyInline();
            return;
        }

        onCryptoPgpInlineChanged(enablePgpInline);
        if (enablePgpInline) {
            boolean shouldShowPgpInlineDialog = checkAndIncrementPgpInlineDialogCounter();
            if (shouldShowPgpInlineDialog) {
@@ -733,6 +742,12 @@ public class RecipientPresenter implements PermissionPingCallback {

    public void onMenuSetSignOnly(boolean enableSignOnly) {
        if (enableSignOnly) {
            if (getCurrentCryptoStatus().isPgpInlineModeEnabled()) {
                recipientMvpView.showErrorInlineSignOnly();
                return;
            }

            onCryptoPgpInlineChanged(false);
            onCryptoModeChanged(CryptoMode.SIGN_ONLY);
            boolean shouldShowPgpSignOnlyDialog = checkAndIncrementPgpSignOnlyDialogCounter();
            if (shouldShowPgpSignOnlyDialog) {
+2 −0
Original line number Diff line number Diff line
@@ -1161,6 +1161,8 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="error_crypto_provider_connect">Cannot connect to crypto provider, check your settings or click crypto icon to retry!</string>
    <string name="error_crypto_provider_ui_required">Crypto provider access denied, click crypto icon to retry!</string>
    <string name="error_crypto_inline_attach">PGP/INLINE mode does not support attachments!</string>
    <string name="error_crypto_inline_sign_only">PGP/INLINE mode does not support sign-only mode!</string>
    <string name="error_crypto_sign_only_inline">Sign-Only mode does not support PGP/INLINE!</string>
    <string name="enable_inline_pgp">Enable PGP/INLINE</string>
    <string name="disable_inline_pgp">Disable PGP/INLINE</string>
    <string name="enable_sign_only">Enable PGP Sign-Only</string>