From 99991e665170ad95ea689dd0bbdb6f3c910737e0 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 18 Sep 2014 19:15:53 +0200 Subject: [PATCH 1/4] Remove option to select (legacy) APG as crypto provider --- .../openpgp/util/OpenPgpListPreference.java | 24 +++------- res/xml/account_settings_preferences.xml | 14 ------ .../k9/activity/setup/AccountSettings.java | 45 +++---------------- 3 files changed, 10 insertions(+), 73 deletions(-) diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java index 54c5b1348..3c21eaff0 100644 --- a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java +++ b/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java @@ -16,6 +16,9 @@ package org.openintents.openpgp.util; +import java.util.ArrayList; +import java.util.List; + import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; @@ -31,10 +34,8 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.TextView; -import org.openintents.openpgp.R; -import java.util.ArrayList; -import java.util.List; +import org.openintents.openpgp.R; /** * Does not extend ListPreference, but is very similar to it! @@ -46,7 +47,6 @@ public class OpenPgpListPreference extends DialogPreference { private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse( String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); - private ArrayList mLegacyList = new ArrayList(); private ArrayList mList = new ArrayList(); private String mSelectedPackage; @@ -59,17 +59,6 @@ public class OpenPgpListPreference extends DialogPreference { this(context, null); } - /** - * Public method to add new entries for legacy applications - * - * @param packageName - * @param simpleName - * @param icon - */ - public void addLegacyProvider(int position, String packageName, String simpleName, Drawable icon) { - mLegacyList.add(position, new OpenPgpProviderEntry(packageName, simpleName, icon)); - } - @Override protected void onPrepareDialogBuilder(Builder builder) { mList.clear(); @@ -78,10 +67,7 @@ public class OpenPgpListPreference extends DialogPreference { mList.add(0, new OpenPgpProviderEntry("", getContext().getString(R.string.openpgp_list_preference_none), getContext().getResources().getDrawable(R.drawable.ic_action_cancel_launchersize_light))); - - // add all additional (legacy) providers - mList.addAll(mLegacyList); - + // search for OpenPGP providers... ArrayList providerList = new ArrayList(); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT); diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 6c65658ed..a0c5f4a28 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -471,20 +471,6 @@ android:key="crypto_app" android:title="@string/account_settings_crypto_app" /> - - - - diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 9c27ae4de..32adbdd77 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -1,16 +1,12 @@ package com.fsck.k9.activity.setup; -import android.app.Dialog; - import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.openintents.openpgp.util.OpenPgpListPreference; -import org.openintents.openpgp.util.OpenPgpUtils; - +import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -38,13 +34,15 @@ import com.fsck.k9.activity.ChooseIdentity; import com.fsck.k9.activity.ColorPickerDialog; import com.fsck.k9.activity.K9PreferenceActivity; import com.fsck.k9.activity.ManageIdentities; -import com.fsck.k9.crypto.Apg; import com.fsck.k9.mail.Folder; import com.fsck.k9.mail.Store; import com.fsck.k9.mail.store.LocalStore.LocalFolder; import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.service.MailService; +import org.openintents.openpgp.util.OpenPgpListPreference; +import org.openintents.openpgp.util.OpenPgpUtils; + public class AccountSettings extends K9PreferenceActivity { private static final String EXTRA_ACCOUNT = "account"; @@ -107,8 +105,6 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions"; private static final String PREFERENCE_CRYPTO = "crypto"; private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; - private static final String PREFERENCE_CRYPTO_AUTO_SIGNATURE = "crypto_auto_signature"; - private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt"; private static final String PREFERENCE_CLOUD_SEARCH_ENABLED = "remote_search_enabled"; private static final String PREFERENCE_REMOTE_SEARCH_NUM_RESULTS = "account_remote_search_num_results"; private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text"; @@ -174,8 +170,6 @@ public class AccountSettings extends K9PreferenceActivity { private ListPreference mMaxPushFolders; private boolean mHasCrypto = false; private OpenPgpListPreference mCryptoApp; - private CheckBoxPreference mCryptoAutoSignature; - private CheckBoxPreference mCryptoAutoEncrypt; private PreferenceScreen mSearchScreen; private CheckBoxPreference mCloudSearchEnabled; @@ -686,15 +680,10 @@ public class AccountSettings extends K9PreferenceActivity { } }); - mHasCrypto = (new Apg().isAvailable(this) || OpenPgpUtils.isAvailable(this)); + mHasCrypto = OpenPgpUtils.isAvailable(this); if (mHasCrypto) { mCryptoApp = (OpenPgpListPreference) findPreference(PREFERENCE_CRYPTO_APP); - // add "apg" - if (new Apg().isAvailable(this)) { - mCryptoApp.addLegacyProvider(0, "apg", "APG", null); - } - mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); mCryptoApp.setSummary(mCryptoApp.getEntry()); mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @@ -702,21 +691,9 @@ public class AccountSettings extends K9PreferenceActivity { String value = newValue.toString(); mCryptoApp.setSummary(mCryptoApp.getEntryByValue(value)); mCryptoApp.setValue(value); - handleCryptoAppDependencies(); - if (Apg.NAME.equals(value)) { - Apg.createInstance(null).test(AccountSettings.this); - } return false; } }); - - mCryptoAutoSignature = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_AUTO_SIGNATURE); - mCryptoAutoSignature.setChecked(mAccount.getCryptoAutoSignature()); - - mCryptoAutoEncrypt = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_AUTO_ENCRYPT); - mCryptoAutoEncrypt.setChecked(mAccount.isCryptoAutoEncrypt()); - - handleCryptoAppDependencies(); } else { final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO); mCryptoMenu.setEnabled(false); @@ -744,16 +721,6 @@ public class AccountSettings extends K9PreferenceActivity { listPreference.setEntries(newEntries); } - private void handleCryptoAppDependencies() { - if ("apg".equals(mCryptoApp.getValue())) { - mCryptoAutoSignature.setEnabled(true); - mCryptoAutoEncrypt.setEnabled(true); - } else { - mCryptoAutoSignature.setEnabled(false); - mCryptoAutoEncrypt.setEnabled(false); - } - } - private void saveSettings() { if (mAccountDefault.isChecked()) { Preferences.getPreferences(this).setDefaultAccount(mAccount); @@ -793,8 +760,6 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue()); if (mHasCrypto) { mAccount.setCryptoApp(mCryptoApp.getValue()); - mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked()); - mAccount.setCryptoAutoEncrypt(mCryptoAutoEncrypt.isChecked()); } // In webdav account we use the exact folder name also for inbox, From 352fb8fd2548944dde0aeaf4162867c9e0ce1156 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 18 Sep 2014 19:45:25 +0200 Subject: [PATCH 2/4] Remove legacy APG interface --- res/layout/message_view_crypto_layout.xml | 58 -- res/layout/message_view_header.xml | 2 - res/values/strings.xml | 1 + src/com/fsck/k9/Account.java | 42 +- src/com/fsck/k9/activity/MessageCompose.java | 132 +--- .../k9/activity/setup/AccountSettings.java | 2 +- src/com/fsck/k9/crypto/Apg.java | 588 ------------------ src/com/fsck/k9/crypto/CryptoProvider.java | 48 -- src/com/fsck/k9/crypto/None.java | 103 --- .../fsck/k9/fragment/MessageViewFragment.java | 21 +- .../fsck/k9/preferences/AccountSettings.java | 10 +- src/com/fsck/k9/preferences/Settings.java | 2 +- src/com/fsck/k9/view/MessageCryptoView.java | 140 ----- src/com/fsck/k9/view/SingleMessageView.java | 12 +- 14 files changed, 15 insertions(+), 1146 deletions(-) delete mode 100644 res/layout/message_view_crypto_layout.xml delete mode 100644 src/com/fsck/k9/crypto/Apg.java delete mode 100644 src/com/fsck/k9/crypto/CryptoProvider.java delete mode 100644 src/com/fsck/k9/crypto/None.java delete mode 100644 src/com/fsck/k9/view/MessageCryptoView.java diff --git a/res/layout/message_view_crypto_layout.xml b/res/layout/message_view_crypto_layout.xml deleted file mode 100644 index a5bda33a5..000000000 --- a/res/layout/message_view_crypto_layout.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - -