1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 05:02:26 -05:00

Remove option to select (legacy) APG as crypto provider

This commit is contained in:
cketti 2014-09-18 19:15:53 +02:00
parent 4105cdd3cb
commit 99991e6651
3 changed files with 10 additions and 73 deletions

View File

@ -16,6 +16,9 @@
package org.openintents.openpgp.util; package org.openintents.openpgp.util;
import java.util.ArrayList;
import java.util.List;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -31,10 +34,8 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.TextView; import android.widget.TextView;
import org.openintents.openpgp.R;
import java.util.ArrayList; import org.openintents.openpgp.R;
import java.util.List;
/** /**
* Does not extend ListPreference, but is very similar to it! * 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( private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse(
String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE)));
private ArrayList<OpenPgpProviderEntry> mLegacyList = new ArrayList<OpenPgpProviderEntry>();
private ArrayList<OpenPgpProviderEntry> mList = new ArrayList<OpenPgpProviderEntry>(); private ArrayList<OpenPgpProviderEntry> mList = new ArrayList<OpenPgpProviderEntry>();
private String mSelectedPackage; private String mSelectedPackage;
@ -59,17 +59,6 @@ public class OpenPgpListPreference extends DialogPreference {
this(context, null); 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 @Override
protected void onPrepareDialogBuilder(Builder builder) { protected void onPrepareDialogBuilder(Builder builder) {
mList.clear(); mList.clear();
@ -79,9 +68,6 @@ public class OpenPgpListPreference extends DialogPreference {
getContext().getString(R.string.openpgp_list_preference_none), getContext().getString(R.string.openpgp_list_preference_none),
getContext().getResources().getDrawable(R.drawable.ic_action_cancel_launchersize_light))); getContext().getResources().getDrawable(R.drawable.ic_action_cancel_launchersize_light)));
// add all additional (legacy) providers
mList.addAll(mLegacyList);
// search for OpenPGP providers... // search for OpenPGP providers...
ArrayList<OpenPgpProviderEntry> providerList = new ArrayList<OpenPgpProviderEntry>(); ArrayList<OpenPgpProviderEntry> providerList = new ArrayList<OpenPgpProviderEntry>();
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT);

View File

@ -471,20 +471,6 @@
android:key="crypto_app" android:key="crypto_app"
android:title="@string/account_settings_crypto_app" /> android:title="@string/account_settings_crypto_app" />
<CheckBoxPreference
android:persistent="false"
android:key="crypto_auto_signature"
android:title="@string/account_settings_crypto_auto_signature"
android:summary="@string/account_settings_crypto_auto_signature_summary"
android:dependency="crypto_app"/>
<CheckBoxPreference
android:persistent="false"
android:key="crypto_auto_encrypt"
android:title="@string/account_settings_crypto_auto_encrypt"
android:summary="@string/account_settings_crypto_auto_encrypt_summary"
android:dependency="crypto_app"/>
</PreferenceScreen> </PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>

View File

@ -1,16 +1,12 @@
package com.fsck.k9.activity.setup; package com.fsck.k9.activity.setup;
import android.app.Dialog;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.openintents.openpgp.util.OpenPgpListPreference; import android.app.Dialog;
import org.openintents.openpgp.util.OpenPgpUtils;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; 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.ColorPickerDialog;
import com.fsck.k9.activity.K9PreferenceActivity; import com.fsck.k9.activity.K9PreferenceActivity;
import com.fsck.k9.activity.ManageIdentities; import com.fsck.k9.activity.ManageIdentities;
import com.fsck.k9.crypto.Apg;
import com.fsck.k9.mail.Folder; import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Store; import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.store.LocalStore.LocalFolder; import com.fsck.k9.mail.store.LocalStore.LocalFolder;
import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.service.MailService; import com.fsck.k9.service.MailService;
import org.openintents.openpgp.util.OpenPgpListPreference;
import org.openintents.openpgp.util.OpenPgpUtils;
public class AccountSettings extends K9PreferenceActivity { public class AccountSettings extends K9PreferenceActivity {
private static final String EXTRA_ACCOUNT = "account"; 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_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions";
private static final String PREFERENCE_CRYPTO = "crypto"; private static final String PREFERENCE_CRYPTO = "crypto";
private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; 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_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_NUM_RESULTS = "account_remote_search_num_results";
private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text"; 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 ListPreference mMaxPushFolders;
private boolean mHasCrypto = false; private boolean mHasCrypto = false;
private OpenPgpListPreference mCryptoApp; private OpenPgpListPreference mCryptoApp;
private CheckBoxPreference mCryptoAutoSignature;
private CheckBoxPreference mCryptoAutoEncrypt;
private PreferenceScreen mSearchScreen; private PreferenceScreen mSearchScreen;
private CheckBoxPreference mCloudSearchEnabled; 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) { if (mHasCrypto) {
mCryptoApp = (OpenPgpListPreference) findPreference(PREFERENCE_CRYPTO_APP); 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.setValue(String.valueOf(mAccount.getCryptoApp()));
mCryptoApp.setSummary(mCryptoApp.getEntry()); mCryptoApp.setSummary(mCryptoApp.getEntry());
mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@ -702,21 +691,9 @@ public class AccountSettings extends K9PreferenceActivity {
String value = newValue.toString(); String value = newValue.toString();
mCryptoApp.setSummary(mCryptoApp.getEntryByValue(value)); mCryptoApp.setSummary(mCryptoApp.getEntryByValue(value));
mCryptoApp.setValue(value); mCryptoApp.setValue(value);
handleCryptoAppDependencies();
if (Apg.NAME.equals(value)) {
Apg.createInstance(null).test(AccountSettings.this);
}
return false; 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 { } else {
final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO); final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO);
mCryptoMenu.setEnabled(false); mCryptoMenu.setEnabled(false);
@ -744,16 +721,6 @@ public class AccountSettings extends K9PreferenceActivity {
listPreference.setEntries(newEntries); 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() { private void saveSettings() {
if (mAccountDefault.isChecked()) { if (mAccountDefault.isChecked()) {
Preferences.getPreferences(this).setDefaultAccount(mAccount); Preferences.getPreferences(this).setDefaultAccount(mAccount);
@ -793,8 +760,6 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue()); mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue());
if (mHasCrypto) { if (mHasCrypto) {
mAccount.setCryptoApp(mCryptoApp.getValue()); mAccount.setCryptoApp(mCryptoApp.getValue());
mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked());
mAccount.setCryptoAutoEncrypt(mCryptoAutoEncrypt.isChecked());
} }
// In webdav account we use the exact folder name also for inbox, // In webdav account we use the exact folder name also for inbox,