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

Commit 6064204d authored by Vincent Breitmoser's avatar Vincent Breitmoser Committed by GitHub
Browse files

Merge pull request #1995 from k9mail/readd-clearsign

Allow pgp/inline with sign-only again
parents aef446f1 afb5e493
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -93,14 +93,18 @@ public class ComposeCryptoStatus {
            return CryptoSpecialModeDisplayType.NONE;
        }

        if (isPgpInlineModeEnabled()) {
            return CryptoSpecialModeDisplayType.PGP_INLINE;
        if (isSignOnly() && isPgpInlineModeEnabled()) {
            return CryptoSpecialModeDisplayType.SIGN_ONLY_PGP_INLINE;
        }

        if (isSignOnly()) {
            return CryptoSpecialModeDisplayType.SIGN_ONLY;
        }

        if (isPgpInlineModeEnabled()) {
            return CryptoSpecialModeDisplayType.PGP_INLINE;
        }

        return CryptoSpecialModeDisplayType.NONE;
    }

+3 −9
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener

    private static final int VIEW_INDEX_CRYPTO_SPECIAL_PGP_INLINE = 0;
    private static final int VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY = 1;
    private static final int VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY_PGP_INLINE = 2;

    private static final int VIEW_INDEX_BCC_EXPANDER_VISIBLE = 0;
    private static final int VIEW_INDEX_BCC_EXPANDER_HIDDEN = 1;
@@ -335,14 +336,6 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
        Toast.makeText(activity, R.string.compose_error_private_missing_keys, Toast.LENGTH_LONG).show();
    }

    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();
    }
@@ -449,7 +442,8 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
    public enum CryptoSpecialModeDisplayType {
        NONE(VIEW_INDEX_HIDDEN),
        PGP_INLINE(VIEW_INDEX_CRYPTO_SPECIAL_PGP_INLINE),
        SIGN_ONLY(VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY);
        SIGN_ONLY(VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY),
        SIGN_ONLY_PGP_INLINE(VIEW_INDEX_CRYPTO_SPECIAL_SIGN_ONLY_PGP_INLINE);


        final int childToDisplay;
+4 −19
Original line number Diff line number Diff line
@@ -723,16 +723,6 @@ public class RecipientPresenter implements PermissionPingCallback {
    }

    public void onMenuSetPgpInline(boolean enablePgpInline) {
        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();
@@ -744,12 +734,6 @@ 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) {
@@ -761,6 +745,7 @@ public class RecipientPresenter implements PermissionPingCallback {
    }

    public void onCryptoPgpSignOnlyDisabled() {
        onCryptoPgpInlineChanged(false);
        onCryptoModeChanged(CryptoMode.OPPORTUNISTIC);
    }

@@ -784,10 +769,10 @@ public class RecipientPresenter implements PermissionPingCallback {

    void onClickCryptoSpecialModeIndicator() {
        ComposeCryptoStatus currentCryptoStatus = getCurrentCryptoStatus();
        if (currentCryptoStatus.isPgpInlineModeEnabled()) {
            recipientMvpView.showOpenPgpInlineDialog(false);
        } else if (currentCryptoStatus.isSignOnly()) {
        if (currentCryptoStatus.isSignOnly()) {
            recipientMvpView.showOpenPgpSignOnlyDialog(false);
        } else if (currentCryptoStatus.isPgpInlineModeEnabled()) {
            recipientMvpView.showOpenPgpInlineDialog(false);
        } else {
            throw new IllegalStateException("This icon should not be clickable while no special mode is active!");
        }
+4 −8
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource;
public class PgpMessageBuilder extends MessageBuilder {
    private static final int REQUEST_USER_INTERACTION = 1;


    private OpenPgpApi openPgpApi;

    private MimeMessage currentProcessedMimeMessage;
@@ -115,16 +114,12 @@ public class PgpMessageBuilder extends MessageBuilder {
                throw new MessagingException("Attachments are not supported in PGP/INLINE format!");
            }

            if (isPgpInlineMode && shouldSign && !shouldEncrypt) {
                throw new UnsupportedOperationException("Clearsigning is not supported!");
            }

            if (pgpApiIntent == null) {
                pgpApiIntent = buildOpenPgpApiIntent(shouldSign, shouldEncrypt, isPgpInlineMode);
            }

            PendingIntent returnedPendingIntent = launchOpenPgpApiIntent(
                    pgpApiIntent, shouldEncrypt, isPgpInlineMode);
                    pgpApiIntent, shouldEncrypt || isPgpInlineMode, shouldEncrypt || !isPgpInlineMode, isPgpInlineMode);
            if (returnedPendingIntent != null) {
                queueMessageBuildPendingIntent(returnedPendingIntent, REQUEST_USER_INTERACTION);
                return;
@@ -174,7 +169,7 @@ public class PgpMessageBuilder extends MessageBuilder {
    }

    private PendingIntent launchOpenPgpApiIntent(@NonNull Intent openPgpIntent,
            boolean captureOutputPart, boolean writeBodyContentOnly) throws MessagingException {
            boolean captureOutputPart, boolean capturedOutputPartIs7Bit, boolean writeBodyContentOnly) throws MessagingException {
        final MimeBodyPart bodyPart = currentProcessedMimeMessage.toBodyPart();
        String[] contentType = currentProcessedMimeMessage.getHeader(MimeHeader.HEADER_CONTENT_TYPE);
        if (contentType.length > 0) {
@@ -187,7 +182,8 @@ public class PgpMessageBuilder extends MessageBuilder {
        OutputStream outputStream = null;
        if (captureOutputPart) {
            try {
                pgpResultTempBody = new BinaryTempFileBody(MimeUtil.ENC_7BIT);
                pgpResultTempBody = new BinaryTempFileBody(
                        capturedOutputPartIs7Bit ? MimeUtil.ENC_7BIT : MimeUtil.ENC_8BIT);
                outputStream = pgpResultTempBody.getOutputStream();
                // OpenKeychain/BouncyCastle at this point use the system newline for formatting, which is LF on android.
                // we need this to be CRLF, so we convert the data after receiving.
+25 −4
Original line number Diff line number Diff line
@@ -51,32 +51,53 @@
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:padding="8dp"
            android:id="@+id/crypto_special_mode"
            android:visibility="gone"
            tools:visibility="visible"
            android:inAnimation="@anim/fade_in"
            android:outAnimation="@anim/fade_out"
            custom:previewInitialChild="0">
            custom:previewInitialChild="2">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_margin="8dp"
                android:src="@drawable/compatibility"
                android:tint="@color/light_black"
                android:visibility="gone"
                tools:visibility="visible"
                />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="8dp"
                android:src="@drawable/status_signature_verified_cutout"
                android:tint="?attr/openpgp_blue"
                />

            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_margin="8dp"
                    android:src="@drawable/status_signature_verified_cutout"
                    android:tint="?attr/openpgp_blue"
                    />

                <ImageView
                    android:layout_width="16dp"
                    android:layout_height="16dp"
                    android:layout_gravity="right|bottom"
                    android:src="@drawable/compatibility"
                    android:tint="@color/light_black"
                    />
            </FrameLayout>

        </com.fsck.k9.view.ToolableViewAnimator>


Loading