1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-17 07:30:16 -05:00

Disable Cryptography setup menu if APG isn't installed.

This commit is contained in:
Andrew Chen 2012-12-18 16:18:00 -08:00
parent c530a00e5b
commit bcc29632e9
2 changed files with 29 additions and 28 deletions

View File

@ -555,6 +555,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="account_settings_crypto_auto_signature_summary">Use the account\'s email address to guess the signature key.</string> <string name="account_settings_crypto_auto_signature_summary">Use the account\'s email address to guess the signature key.</string>
<string name="account_settings_crypto_auto_encrypt">Auto-encrypt</string> <string name="account_settings_crypto_auto_encrypt">Auto-encrypt</string>
<string name="account_settings_crypto_auto_encrypt_summary">Automatically set encrypt if a public key matches a recipient.</string> <string name="account_settings_crypto_auto_encrypt_summary">Automatically set encrypt if a public key matches a recipient.</string>
<string name="account_settings_crypto_apg_not_installed">APG not installed</string>
<string name="account_settings_mail_check_frequency_label">Folder poll frequency</string> <string name="account_settings_mail_check_frequency_label">Folder poll frequency</string>

View File

@ -108,6 +108,7 @@ public class AccountSettings extends K9PreferenceActivity {
private static final String PREFERENCE_REPLY_AFTER_QUOTE = "reply_after_quote"; private static final String PREFERENCE_REPLY_AFTER_QUOTE = "reply_after_quote";
private static final String PREFERENCE_STRIP_SIGNATURE = "strip_signature"; private static final String PREFERENCE_STRIP_SIGNATURE = "strip_signature";
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_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_SIGNATURE = "crypto_auto_signature";
private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt"; private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt";
@ -682,38 +683,37 @@ public class AccountSettings extends K9PreferenceActivity {
} }
}); });
mCryptoApp = (ListPreference) findPreference(PREFERENCE_CRYPTO_APP); final boolean hasCryptoAvailable = new Apg().isAvailable(this);
CharSequence cryptoAppEntries[] = mCryptoApp.getEntries(); if (hasCryptoAvailable) {
if (!new Apg().isAvailable(this)) { mCryptoApp = (ListPreference) findPreference(PREFERENCE_CRYPTO_APP);
int apgIndex = mCryptoApp.findIndexOfValue(Apg.NAME); mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp()));
if (apgIndex >= 0) { mCryptoApp.setSummary(mCryptoApp.getEntry());
cryptoAppEntries[apgIndex] = "APG (" + getResources().getString(R.string.account_settings_crypto_app_not_available) + ")"; mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
mCryptoApp.setEntries(cryptoAppEntries); public boolean onPreferenceChange(Preference preference, Object newValue) {
} String value = newValue.toString();
} int index = mCryptoApp.findIndexOfValue(value);
mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); mCryptoApp.setSummary(mCryptoApp.getEntries()[index]);
mCryptoApp.setSummary(mCryptoApp.getEntry()); mCryptoApp.setValue(value);
mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { handleCryptoAppDependencies();
public boolean onPreferenceChange(Preference preference, Object newValue) { if (Apg.NAME.equals(value)) {
String value = newValue.toString(); Apg.createInstance(null).test(AccountSettings.this);
int index = mCryptoApp.findIndexOfValue(value); }
mCryptoApp.setSummary(mCryptoApp.getEntries()[index]); return false;
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 = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_AUTO_SIGNATURE);
mCryptoAutoSignature.setChecked(mAccount.getCryptoAutoSignature()); mCryptoAutoSignature.setChecked(mAccount.getCryptoAutoSignature());
mCryptoAutoEncrypt = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_AUTO_ENCRYPT); mCryptoAutoEncrypt = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_AUTO_ENCRYPT);
mCryptoAutoEncrypt.setChecked(mAccount.isCryptoAutoEncrypt()); mCryptoAutoEncrypt.setChecked(mAccount.isCryptoAutoEncrypt());
handleCryptoAppDependencies(); handleCryptoAppDependencies();
} else {
final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO);
mCryptoMenu.setEnabled(false);
mCryptoMenu.setSummary(R.string.account_settings_crypto_apg_not_installed);
}
} }
private void handleCryptoAppDependencies() { private void handleCryptoAppDependencies() {