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

Commit 39a732d0 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

Honor encrypt all drafts setting during message compose

parent 18ad0079
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -45,12 +45,12 @@ data class AutocryptDraftStateHeader(val isEncrypt: Boolean,
        const val VALUE_YES = "yes";

        fun fromCryptoStatus(cryptoStatus: CryptoStatus): AutocryptDraftStateHeader {
            if (cryptoStatus.isSignOnly()) {
                return AutocryptDraftStateHeader(false, true, cryptoStatus.isReplyToEncrypted(),
                        cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled(), mapOf())
            if (cryptoStatus.isSignOnly) {
                return AutocryptDraftStateHeader(false, true, cryptoStatus.isReplyToEncrypted,
                        cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled, mapOf())
            }
            return AutocryptDraftStateHeader(cryptoStatus.isEncryptionEnabled(), false, cryptoStatus.isReplyToEncrypted(),
                    cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled(), mapOf())
            return AutocryptDraftStateHeader(cryptoStatus.isEncryptionEnabled, false, cryptoStatus.isReplyToEncrypted,
                    cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled, mapOf())
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ interface CryptoStatus {
    fun isUserChoice(): Boolean
    val isReplyToEncrypted: Boolean
    fun hasRecipients(): Boolean
    val isEncryptAllDrafts: Boolean
    val isEncryptSubject: Boolean
    fun getRecipientAddresses(): Array<String>
}
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public class PgpMessageBuilder extends MessageBuilder {
    private void startOrContinueBuildMessage(@Nullable Intent pgpApiIntent) {
        try {
            boolean shouldSign = cryptoStatus.isSigningEnabled() && !isDraft();
            boolean shouldEncrypt = cryptoStatus.isEncryptionEnabled();
            boolean shouldEncrypt = cryptoStatus.isEncryptionEnabled() || (isDraft() && cryptoStatus.isEncryptAllDrafts());
            boolean isPgpInlineMode = cryptoStatus.isPgpInlineModeEnabled() && !isDraft();

            if (!shouldSign && !shouldEncrypt) {
+8 −5
Original line number Diff line number Diff line
@@ -16,13 +16,14 @@ import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderState
 * or saving as draft.
 */
data class ComposeCryptoStatus(private val openPgpProviderState: OpenPgpProviderState,
                               private val cryptoMode: CryptoMode,
                               override val openPgpKeyId: Long?,
                               val recipientAddresses: List<String>,
                               override val isPgpInlineModeEnabled: Boolean,
                               override val isSenderPreferEncryptMutual: Boolean,
                               override val isReplyToEncrypted: Boolean,
                               override val isEncryptAllDrafts: Boolean,
                               override val isEncryptSubject: Boolean,
                               val recipientAddresses: List<String>,
                               private val cryptoMode: CryptoMode,
                               private val recipientAutocryptStatus: RecipientAutocryptStatus? = null) : CryptoStatus {

    constructor(openPgpProviderState: OpenPgpProviderState,
@@ -31,11 +32,12 @@ data class ComposeCryptoStatus(private val openPgpProviderState: OpenPgpProvider
                isPgpInlineModeEnabled: Boolean,
                isSenderPreferEncryptMutual: Boolean,
                isReplyToEncrypted: Boolean,
                isEncryptAllDrafts: Boolean,
                isEncryptSubject: Boolean,
                cryptoMode: CryptoMode) : this(
            openPgpProviderState, cryptoMode,
            openPgpKeyId,
            isPgpInlineModeEnabled, isSenderPreferEncryptMutual, isReplyToEncrypted, isEncryptSubject, recipientAddresses.map { it.address.address })
            openPgpProviderState, openPgpKeyId,
            recipientAddresses.map { it.address.address },
            isPgpInlineModeEnabled, isSenderPreferEncryptMutual, isReplyToEncrypted, isEncryptAllDrafts, isEncryptSubject, cryptoMode)

    private val recipientAutocryptStatusType = recipientAutocryptStatus?.type
    private val isRecipientsPreferEncryptMutual = recipientAutocryptStatus?.type?.isMutual ?: false
@@ -141,6 +143,7 @@ data class ComposeCryptoStatus(private val openPgpProviderState: OpenPgpProvider
            isPgpInlineModeEnabled = isPgpInlineModeEnabled,
            isSenderPreferEncryptMutual = isSenderPreferEncryptMutual,
            isReplyToEncrypted = isReplyToEncrypted,
            isEncryptAllDrafts=  isEncryptAllDrafts,
            isEncryptSubject = isEncryptSubject,
            recipientAddresses = recipientAddresses,
            recipientAutocryptStatus = recipientAutocryptStatusType
+1 −0
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ public class RecipientPresenter {
                cryptoEnablePgpInline,
                account.getAutocryptPreferEncryptMutual(),
                isReplyToEncryptedMessage,
                account.getOpenPgpEncryptAllDrafts(),
                account.getOpenPgpEncryptSubject(),
                currentCryptoMode);