diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java index a406077be..0827df7ae 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java @@ -84,7 +84,7 @@ public class ComposeCryptoStatus { case NO_CHOICE: if (recipientAutocryptStatusType == RecipientAutocryptStatusType.NO_RECIPIENTS) { return CryptoStatusDisplayType.NO_CHOICE_EMPTY; - } else if (canEncryptAndIsMutual()) { + } else if (canEncryptAndIsMutualDefault()) { if (recipientAutocryptStatusType.isConfirmed()) { return CryptoStatusDisplayType.NO_CHOICE_MUTUAL_TRUSTED; } else { @@ -136,7 +136,7 @@ public class ComposeCryptoStatus { } boolean isExplicitlyEnabled = (cryptoMode == CryptoMode.CHOICE_ENABLED); - boolean isMutualAndNotDisabled = (cryptoMode != CryptoMode.CHOICE_DISABLED && canEncryptAndIsMutual()); + boolean isMutualAndNotDisabled = (cryptoMode != CryptoMode.CHOICE_DISABLED && canEncryptAndIsMutualDefault()); return isExplicitlyEnabled || isMutualAndNotDisabled; } @@ -168,8 +168,16 @@ public class ComposeCryptoStatus { return recipientAddresses.length > 0; } - boolean canEncryptAndIsMutual() { - return allRecipientsCanEncrypt() && preferEncryptMutual && recipientAutocryptStatus.type.isMutual(); + public boolean isSenderPreferEncryptMutual() { + return preferEncryptMutual; + } + + private boolean isRecipientsPreferEncryptMutual() { + return recipientAutocryptStatus.type.isMutual(); + } + + boolean canEncryptAndIsMutualDefault() { + return allRecipientsCanEncrypt() && isSenderPreferEncryptMutual() && isRecipientsPreferEncryptMutual(); } boolean hasAutocryptPendingIntent() { diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java index 07914d877..d06e8ecb9 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java @@ -400,7 +400,7 @@ public class RecipientPresenter implements PermissionPingCallback { .setCryptoProviderState(cryptoProviderState) .setCryptoMode(currentCryptoMode) .setEnablePgpInline(cryptoEnablePgpInline) - .setPreferEncryptMutual(false) // TODO introduce a setting + .setPreferEncryptMutual(account.getAutocryptPreferEncryptMutual()) .setRecipients(getAllRecipients()) .setOpenPgpKeyId(accountCryptoKey) .build(); @@ -640,7 +640,7 @@ public class RecipientPresenter implements PermissionPingCallback { if (currentCryptoStatus.hasAutocryptPendingIntent()) { recipientMvpView.launchUserInteractionPendingIntent( currentCryptoStatus.getAutocryptPendingIntent(), REQUEST_CODE_AUTOCRYPT); - } else if (currentCryptoStatus.canEncryptAndIsMutual()) { + } else if (currentCryptoStatus.canEncryptAndIsMutualDefault()) { onCryptoModeChanged(CryptoMode.CHOICE_DISABLED); } else { onCryptoModeChanged(CryptoMode.CHOICE_ENABLED); @@ -648,7 +648,7 @@ public class RecipientPresenter implements PermissionPingCallback { return; } - if (currentCryptoMode == CryptoMode.CHOICE_DISABLED && !currentCryptoStatus.canEncryptAndIsMutual()) { + if (currentCryptoMode == CryptoMode.CHOICE_DISABLED && !currentCryptoStatus.canEncryptAndIsMutualDefault()) { onCryptoModeChanged(CryptoMode.CHOICE_ENABLED); return; } @@ -902,14 +902,14 @@ public class RecipientPresenter implements PermissionPingCallback { if (!cachedCryptoStatus.allRecipientsCanEncrypt()) { onCryptoModeChanged(CryptoMode.CHOICE_ENABLED); recipientMvpView.showOpenPgpEnabledErrorDialog(true); - } else if (cachedCryptoStatus.canEncryptAndIsMutual()) { + } else if (cachedCryptoStatus.canEncryptAndIsMutualDefault()) { onCryptoModeChanged(CryptoMode.NO_CHOICE); } else { recipientMvpView.showOpenPgpEncryptExplanationDialog(); onCryptoModeChanged(CryptoMode.CHOICE_ENABLED); } } else { - if (cachedCryptoStatus.canEncryptAndIsMutual()) { + if (cachedCryptoStatus.canEncryptAndIsMutualDefault()) { onCryptoModeChanged(CryptoMode.CHOICE_DISABLED); } else { onCryptoModeChanged(CryptoMode.NO_CHOICE); diff --git a/k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java b/k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java index 185f8e25b..43ad2d71b 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java +++ b/k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java @@ -113,8 +113,8 @@ public class PgpMessageBuilder extends MessageBuilder { byte[] keyData = autocryptOpenPgpApiInteractor.getKeyMaterialForKeyId( openPgpApi, openPgpKeyId, address.getAddress()); if (keyData != null) { - autocryptOperations.addAutocryptHeaderToMessage( - currentProcessedMimeMessage, keyData, address.getAddress(), false); + autocryptOperations.addAutocryptHeaderToMessage(currentProcessedMimeMessage, keyData, + address.getAddress(), cryptoStatus.isSenderPreferEncryptMutual()); } startOrContinueBuildMessage(null);