diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java index 510b4e405c7268ac9af019a140c83c16a6e5faab..83be6b12989235d2e8970d4403f2f4df3208afff 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -1,3 +1,20 @@ +/* + * 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 . + */ + 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,14 +718,14 @@ 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; + } else { + builder = SimpleMessageBuilder.newInstance(); + recipientPresenter.builderSetProperties(builder); } - - PgpMessageBuilder pgpBuilder = PgpMessageBuilder.newInstance(); - recipientPresenter.builderSetProperties(pgpBuilder, cryptoStatus); - builder = pgpBuilder; } else { builder = SimpleMessageBuilder.newInstance(); recipientPresenter.builderSetProperties(builder); 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 b7c6dbf8fe64d20249755a643b1cea7b1a40df75..44a6b1984d80652a20a4c740cc07768159b96e6b 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 @@ -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) { 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 16627d6565934300a69e0b2d7ef98f7189e09281..0ee13b75eee098760fb8e4c4fb401dc881159337 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 @@ -1,17 +1,18 @@ /* * 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 . + * you should have received a copy of the gnu general public license + * along with this program. if not, see . */ 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) { 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 b5e9b1e802d4fd6df64e8730c1e84b596f402114..c87d3eede41424a431c596de5d915315f07ab6c2 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 @@ -1,3 +1,20 @@ +/* + * 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 . + */ + 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 openPgpProviderPackages = getOpenPgpProviderPackages(context); + if (openPgpProviderPackages.size() > 0) { + return openPgpProviderPackages.get(0); + } + return null; + } + public static List getOpenPgpProviderPackages(Context context) { ArrayList result = new ArrayList<>();