From 47ab9aaabf3e7fcb346d52eefd2b8f227deacde0 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 28 Apr 2022 14:11:58 +0600 Subject: [PATCH] 5342-Enable_opePGP_support_by_default issue: https://gitlab.e.foundation/e/backlog/-/issues/5342 --- .../fsck/k9/activity/setup/AccountSetupBasics.java | 3 +++ .../setup/accountmanager/EeloAccountCreator.java | 2 ++ .../openintents/openpgp/util/OpenPgpProviderUtil.java | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java index 43878dc830..cce63c3f63 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -43,6 +43,7 @@ import com.fsck.k9.view.ClientCertificateSpinner; import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListener; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; +import org.openintents.openpgp.util.OpenPgpProviderUtil; import timber.log.Timber; /** @@ -251,6 +252,7 @@ public class AccountSetupBasics extends K9Activity if (mAccount == null) { mAccount = Preferences.getPreferences(this).newAccount(); mAccount.setChipColor(accountCreator.pickColor()); + mAccount.setOpenPgpProvider(OpenPgpProviderUtil.getOpenPgpProviderPackage(getApplicationContext())); } mAccount.setSenderName(getOwnerName()); @@ -368,6 +370,7 @@ public class AccountSetupBasics extends K9Activity if (mAccount == null) { mAccount = Preferences.getPreferences(this).newAccount(); mAccount.setChipColor(accountCreator.pickColor()); + mAccount.setOpenPgpProvider(OpenPgpProviderUtil.getOpenPgpProviderPackage(getApplicationContext())); } mAccount.setSenderName(getOwnerName()); mAccount.setEmail(email); diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java index 25f1fbcf30..d139c1cd19 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java @@ -19,6 +19,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; @@ -34,6 +35,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) { diff --git a/plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpProviderUtil.java b/plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpProviderUtil.java index b5e9b1e802..e2b3fd729c 100644 --- a/plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpProviderUtil.java +++ b/plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpProviderUtil.java @@ -9,6 +9,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 +19,15 @@ public class OpenPgpProviderUtil { DISALLOWED_PROVIDERS.add(PACKAGE_NAME_APG); } + @Nullable + public static String getOpenPgpProviderPackage(Context context) { + List openPgpProviderPackages = getOpenPgpProviderPackages(context); + if (openPgpProviderPackages.size() > 0) { + return openPgpProviderPackages.get(0); + } + return null; + } + public static List getOpenPgpProviderPackages(Context context) { ArrayList result = new ArrayList<>(); -- GitLab