1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -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_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_apg_not_installed">APG not installed</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_STRIP_SIGNATURE = "strip_signature";
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";
@ -682,15 +683,9 @@ public class AccountSettings extends K9PreferenceActivity {
}
});
final boolean hasCryptoAvailable = new Apg().isAvailable(this);
if (hasCryptoAvailable) {
mCryptoApp = (ListPreference) findPreference(PREFERENCE_CRYPTO_APP);
CharSequence cryptoAppEntries[] = mCryptoApp.getEntries();
if (!new Apg().isAvailable(this)) {
int apgIndex = mCryptoApp.findIndexOfValue(Apg.NAME);
if (apgIndex >= 0) {
cryptoAppEntries[apgIndex] = "APG (" + getResources().getString(R.string.account_settings_crypto_app_not_available) + ")";
mCryptoApp.setEntries(cryptoAppEntries);
}
}
mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp()));
mCryptoApp.setSummary(mCryptoApp.getEntry());
mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@ -714,6 +709,11 @@ public class AccountSettings extends K9PreferenceActivity {
mCryptoAutoEncrypt.setChecked(mAccount.isCryptoAutoEncrypt());
handleCryptoAppDependencies();
} else {
final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO);
mCryptoMenu.setEnabled(false);
mCryptoMenu.setSummary(R.string.account_settings_crypto_apg_not_installed);
}
}
private void handleCryptoAppDependencies() {