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

Commit 1a4af6f6 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '5445-Enable_openPGP_support_by_default' into 'main'

5445-Enable_openPGP_support_by_default

See merge request !82
parents f51ce9ea 2387ddfe
Loading
Loading
Loading
Loading
Loading
+27 −11
Original line number Diff line number Diff line
/*
 * Copyright ECORP SAS 2022
 *
 * this program is free software: you can redistribute it and/or modify
 * it under the terms of the gnu general public license as published by
 * the free software foundation, either version 3 of the license, or
 * (at your option) any later version.
 *
 * this program is distributed in the hope that it will be useful,
 * but without any warranty; without even the implied warranty of
 * merchantability or fitness for a particular purpose.  see the
 * gnu general public license for more details.
 *
 * you should have received a copy of the gnu general public license
 * along with this program.  if not, see <https://www.gnu.org/licenses/>.
 */

package com.fsck.k9.activity;


@@ -25,9 +42,6 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
@@ -46,6 +60,9 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.fsck.k9.Account;
@@ -115,7 +132,6 @@ import com.fsck.k9.ui.messagelist.DefaultFolderProvider;
import com.fsck.k9.ui.permissions.K9PermissionUiHelper;
import com.fsck.k9.ui.permissions.Permission;
import com.fsck.k9.ui.permissions.PermissionUiHelper;

import org.jetbrains.annotations.NotNull;
import org.openintents.openpgp.OpenPgpApiManager;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -702,11 +718,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
        boolean shouldUsePgpMessageBuilder = cryptoStatus.isOpenPgpConfigured();
        if (shouldUsePgpMessageBuilder) {
            SendErrorState maybeSendErrorState = cryptoStatus.getSendErrorStateOrNull();
            if (maybeSendErrorState != null) {
                recipientPresenter.showPgpSendError(maybeSendErrorState);
                return null;
            }

            if (maybeSendErrorState == null) {
                PgpMessageBuilder pgpBuilder = PgpMessageBuilder.newInstance();
                recipientPresenter.builderSetProperties(pgpBuilder, cryptoStatus);
                builder = pgpBuilder;
@@ -714,6 +726,10 @@ public class MessageCompose extends K9Activity implements OnClickListener,
                builder = SimpleMessageBuilder.newInstance();
                recipientPresenter.builderSetProperties(builder);
            }
        } else {
            builder = SimpleMessageBuilder.newInstance();
            recipientPresenter.builderSetProperties(builder);
        }

        builder.setSubject(Utility.stripNewLines(subjectView.getText().toString()))
                .setSentDate(new Date())
+7 −2
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;
import com.fsck.k9.Account;
import com.fsck.k9.Core;
import com.fsck.k9.DI;
@@ -58,6 +56,7 @@ import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListe
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.lamonjush.fullscreenloadingdialog.FullScreenLoadingDialog;
import org.openintents.openpgp.util.OpenPgpProviderUtil;
import timber.log.Timber;

/**
@@ -267,6 +266,7 @@ public class AccountSetupBasics extends K9Activity
        if (mAccount == null) {
            mAccount = Preferences.getPreferences(this).newAccount();
            mAccount.setChipColor(accountCreator.pickColor());
            setOpenPgpProvider();
        }

        mAccount.setSenderName(getOwnerName());
@@ -405,6 +405,7 @@ public class AccountSetupBasics extends K9Activity
        if (mAccount == null) {
            mAccount = Preferences.getPreferences(this).newAccount();
            mAccount.setChipColor(accountCreator.pickColor());
            setOpenPgpProvider();
        }
        mAccount.setSenderName(getOwnerName());
        mAccount.setEmail(email);
@@ -415,6 +416,10 @@ public class AccountSetupBasics extends K9Activity
        AccountSetupAccountType.actionSelectAccountType(this, mAccount, false, initialAccountSettings);
    }

    private void setOpenPgpProvider() {
        mAccount.setOpenPgpProvider(OpenPgpProviderUtil.getOpenPgpProviderPackage(getApplicationContext()));
    }

    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.next) {
+12 −9
Original line number Diff line number Diff line
/*
 * Copyright ECORP SAS 2022
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 *
 * this program is free software: you can redistribute it and/or modify
 * it under the terms of the gnu general public license as published by
 * the free software foundation, either version 3 of the license, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * this program is distributed in the hope that it will be useful,
 * but without any warranty; without even the implied warranty of
 * merchantability or fitness for a particular purpose.  see the
 * gnu general public license for more details.
 *
 * You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * you should have received a copy of the gnu general public license
 * along with this program.  if not, see <https://www.gnu.org/licenses/>.
 */

package com.fsck.k9.activity.setup.accountmanager;
@@ -34,6 +35,7 @@ import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mailstore.SpecialLocalFoldersCreator;
import com.fsck.k9.preferences.Protocols;
import com.fsck.k9.ui.ConnectionSettings;
import org.openintents.openpgp.util.OpenPgpProviderUtil;
import timber.log.Timber;


@@ -49,6 +51,7 @@ public class EeloAccountCreator {
        account.setChipColor(accountCreator.pickColor());
        account.setEmail(emailId);
        account.setName(emailId);
        account.setOpenPgpProvider(OpenPgpProviderUtil.getOpenPgpProviderPackage(context.getApplicationContext()));

        ConnectionSettings connectionSettings = providersXmlDiscoveryDiscover(emailId);
        if (connectionSettings == null) {
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright ECORP SAS 2022
 *
 * this program is free software: you can redistribute it and/or modify
 * it under the terms of the gnu general public license as published by
 * the free software foundation, either version 3 of the license, or
 * (at your option) any later version.
 *
 * this program is distributed in the hope that it will be useful,
 * but without any warranty; without even the implied warranty of
 * merchantability or fitness for a particular purpose.  see the
 * gnu general public license for more details.
 *
 * you should have received a copy of the gnu general public license
 * along with this program.  if not, see <https://www.gnu.org/licenses/>.
 */

package org.openintents.openpgp.util;


@@ -9,6 +26,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import androidx.annotation.Nullable;


public class OpenPgpProviderUtil {
    private static final String PACKAGE_NAME_APG = "org.thialfihar.android.apg";
@@ -17,6 +36,15 @@ public class OpenPgpProviderUtil {
        DISALLOWED_PROVIDERS.add(PACKAGE_NAME_APG);
    }

    @Nullable
    public static String getOpenPgpProviderPackage(Context context) {
        List<String> openPgpProviderPackages = getOpenPgpProviderPackages(context);
        if (openPgpProviderPackages.size() > 0) {
            return openPgpProviderPackages.get(0);
        }
        return null;
    }

    public static List<String> getOpenPgpProviderPackages(Context context) {
        ArrayList<String> result = new ArrayList<>();