Actually use prefer-encrypt setting
This commit is contained in:
parent
9498725fd0
commit
d606475309
3 changed files with 19 additions and 11 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue