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

Commit 31674420 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

mail: Add PGP encryption to compose

parent 32de6b4c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -49,4 +49,22 @@
    <string name="unread_widget_unified_inbox_account_summary_e" translatable="false">@string/integrated_inbox_title_e</string>
    <string name="show_unified_inbox_title_e">Show All Inboxes</string>
    <string name="folder_settings_include_in_integrated_inbox_summary_e">All messages are shown in All Inboxes</string>

    <string name="openpgp_dialog_proceed">Proceed</string>
    <string name="openpgp_dialog_cancel">Cancel</string>
    <string name="openpgp_dialog_create_key_pair">Create key pair</string>
    <string name="openpgp_enable_encryption_title">Enable encryption</string>
    <string name="openpgp_enable_encryption_description">End-to-end encryption is the safest way to keep other people
        from spying on communications or accessing data transferred from one end device to another.By proceeding,
        OpenPGP support will be enabled.\n\n<b>Required: </b>To send an encrypted mail, a pair of keys is required
        so that the data encrypted on the sender\'s device can be decrypted by the intended recipient. For example,
        you will need the public key of the person you are sending to and vice versa.
    </string>
    <string name="openpgp_setup_encryption_key_title">Set up encryption keys</string>
    <string name="openpgp_setup_encryption_key_description">End-to-end encryption is the safest way to keep other
        people from spying on communications or accessing data transferred from one end device to another.\n\nTo
        send an encrypted mail, a pair of keys is required so that the data encrypted on the sender\'s device can
        be decrypted by the intended recipient. For example, you will need the public key of the person you are
        sending to and vice versa.
    </string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ dependencyCheckPlugin = "0.51.0"
dependencyGuardPlugin = "0.5.0"
detektPlugin = "1.23.5"
detektPluginCompose = "0.4.16"
elib = "0.0.1-alpha11"
fastAdapter = "5.7.0"
forkhandlesBom = "2.20.0.0"
glide = "4.16.0"
@@ -188,6 +189,7 @@ clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" }
detekt-plugin-compose = { module = "io.nlopez.compose.rules:detekt", version.ref = "detektPluginCompose" }
diff-utils = { module = "io.github.java-diff-utils:java-diff-utils", version.ref = "javaDiffUtils" }
elib = { module = "foundation.e:elib", version.ref = "elib" }
fastadapter = { module = "com.mikepenz:fastadapter", version.ref = "fastAdapter" }
fastadapter-extensions-drag = { module = "com.mikepenz:fastadapter-extensions-drag", version.ref = "fastAdapter" }
fastadapter-extensions-utils = { module = "com.mikepenz:fastadapter-extensions-utils", version.ref = "fastAdapter" }
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ dependencies {

    implementation(libs.gson)
    implementation(libs.androidx.datastore.preferences)
    implementation(libs.elib)

    implementation(projects.legacy.core)
    implementation(projects.mail.common)
+9 −2
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import com.fsck.k9.activity.compose.ReplyToPresenter;
import com.fsck.k9.activity.compose.ReplyToView;
import com.fsck.k9.activity.compose.SaveMessageTask;
import com.fsck.k9.activity.misc.Attachment;
import com.fsck.k9.activity.pgp.OpenPgpConfigureCallBack;
import com.fsck.k9.autocrypt.AutocryptDraftStateHeaderParser;
import com.fsck.k9.contact.ContactIntentHelper;
import app.k9mail.legacy.message.controller.MessageReference;
@@ -127,7 +128,8 @@ import timber.log.Timber;
public class MessageCompose extends K9Activity implements OnClickListener,
        CancelListener, AttachmentDownloadCancelListener, OnFocusChangeListener,
        OnOpenPgpInlineChangeListener, OnOpenPgpSignOnlyChangeListener, MessageBuilder.Callback,
        AttachmentPresenter.AttachmentsChangedListener, OnOpenPgpDisableListener {
        AttachmentPresenter.AttachmentsChangedListener, OnOpenPgpDisableListener,
        OpenPgpConfigureCallBack {

    private static final int DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE = 1;
    private static final int DIALOG_CONFIRM_DISCARD_ON_BACK = 2;
@@ -312,7 +314,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
        recipientPresenter = new RecipientPresenter(getApplicationContext(), getSupportLoaderManager(),
                openPgpApiManager, recipientMvpView, account, composePgpInlineDecider, composePgpEnableByDefaultDecider,
                AutocryptStatusInteractor.getInstance(), new ReplyToParser(),
                DI.get(AutocryptDraftStateHeaderParser.class));
                DI.get(AutocryptDraftStateHeaderParser.class), preferences);
        recipientPresenter.asyncUpdateCryptoStatus();


@@ -1451,6 +1453,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
        quotedMessagePresenter.processDraftMessage(messageViewInfo, k9identity);
    }

    @Override
    public void initializePgpSetup() {
        recipientPresenter.initializeOpenPgpSetup();
    }

    static class SendMessageTask extends AsyncTask<Void, Void, Void> {
        final MessagingController messagingController;
        final Preferences preferences;
+2 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ data class ComposeCryptoStatus(
    val recipientAddressesAsArray = recipientAddresses.toTypedArray()

    private val displayTypeFromProviderError = when (openPgpProviderState) {
        OpenPgpProviderState.OK -> null
        OpenPgpProviderState.OK -> if(openPgpKeyId == null) CryptoStatusDisplayType.KEY_MISSING else null
        OpenPgpProviderState.UNCONFIGURED -> CryptoStatusDisplayType.UNCONFIGURED
        OpenPgpProviderState.UNINITIALIZED -> CryptoStatusDisplayType.UNINITIALIZED
        OpenPgpProviderState.ERROR, OpenPgpProviderState.UI_REQUIRED -> CryptoStatusDisplayType.ERROR
@@ -123,6 +123,7 @@ data class ComposeCryptoStatus(
    val autocryptPendingIntent = recipientAutocryptStatus?.intent

    val sendErrorStateOrNull = when {
        openPgpProviderState in listOf(OpenPgpProviderState.UNINITIALIZED, OpenPgpProviderState.UI_REQUIRED) -> null
        openPgpProviderState != OpenPgpProviderState.OK -> SendErrorState.PROVIDER_ERROR
        openPgpKeyId == null && (isEncryptionEnabled || isSignOnly) -> SendErrorState.KEY_CONFIG_ERROR
        isEncryptionEnabled && !allRecipientsCanEncrypt() -> SendErrorState.ENABLED_ERROR
Loading