From 6e982690d24e7de87c2e2eeb104403e6a1e0f082 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 20 Jan 2017 16:33:05 +0100 Subject: [PATCH] move sign-only support settings to global --- k9mail/src/main/java/com/fsck/k9/Account.java | 12 ----------- k9mail/src/main/java/com/fsck/k9/K9.java | 11 ++++++++++ .../activity/compose/RecipientPresenter.java | 2 +- .../k9/activity/setup/AccountSettings.java | 5 ----- .../com/fsck/k9/activity/setup/Prefs.java | 6 ++++++ .../fsck/k9/preferences/GlobalSettings.java | 3 +++ .../com/fsck/k9/preferences/Settings.java | 2 +- .../messageview/MessageCryptoPresenter.java | 2 +- .../k9/ui/messageview/MessageTopView.java | 3 ++- .../res/xml/account_settings_preferences.xml | 7 ------- .../src/main/res/xml/global_preferences.xml | 21 +++++++++++++++---- 11 files changed, 42 insertions(+), 32 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/Account.java b/k9mail/src/main/java/com/fsck/k9/Account.java index ec3994203..b2dd944a7 100644 --- a/k9mail/src/main/java/com/fsck/k9/Account.java +++ b/k9mail/src/main/java/com/fsck/k9/Account.java @@ -220,7 +220,6 @@ public class Account implements BaseAccount, StoreConfig { private boolean mStripSignature; private boolean mSyncRemoteDeletions; private long mCryptoKey; - private boolean mCryptoSupportSignOnly; private boolean mMarkMessageAsReadOnView; private boolean mAlwaysShowCcBcc; private boolean mAllowRemoteSearch; @@ -316,7 +315,6 @@ public class Account implements BaseAccount, StoreConfig { mStripSignature = DEFAULT_STRIP_SIGNATURE; mSyncRemoteDeletions = true; mCryptoKey = NO_OPENPGP_KEY; - mCryptoSupportSignOnly = false; mAllowRemoteSearch = false; mRemoteSearchFullText = false; mRemoteSearchNumResults = DEFAULT_REMOTE_SEARCH_NUM_RESULTS; @@ -465,7 +463,6 @@ public class Account implements BaseAccount, StoreConfig { identities = loadIdentities(storage); mCryptoKey = storage.getLong(mUuid + ".cryptoKey", NO_OPENPGP_KEY); - mCryptoSupportSignOnly = storage.getBoolean(mUuid + ".cryptoSupportSignOnly", false); mAllowRemoteSearch = storage.getBoolean(mUuid + ".allowRemoteSearch", false); mRemoteSearchFullText = storage.getBoolean(mUuid + ".remoteSearchFullText", false); mRemoteSearchNumResults = storage.getInt(mUuid + ".remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS); @@ -732,7 +729,6 @@ public class Account implements BaseAccount, StoreConfig { editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote); editor.putBoolean(mUuid + ".stripSignature", mStripSignature); editor.putLong(mUuid + ".cryptoKey", mCryptoKey); - editor.putBoolean(mUuid + ".cryptoSupportSignOnly", mCryptoSupportSignOnly); editor.putBoolean(mUuid + ".allowRemoteSearch", mAllowRemoteSearch); editor.putBoolean(mUuid + ".remoteSearchFullText", mRemoteSearchFullText); editor.putInt(mUuid + ".remoteSearchNumResults", mRemoteSearchNumResults); @@ -1604,14 +1600,6 @@ public class Account implements BaseAccount, StoreConfig { mCryptoKey = keyId; } - public boolean getCryptoSupportSignOnly() { - return mCryptoSupportSignOnly; - } - - public void setCryptoSupportSignOnly(boolean cryptoSupportSignOnly) { - mCryptoSupportSignOnly = cryptoSupportSignOnly; - } - public boolean allowRemoteSearch() { return mAllowRemoteSearch; } diff --git a/k9mail/src/main/java/com/fsck/k9/K9.java b/k9mail/src/main/java/com/fsck/k9/K9.java index 1eaef8cb1..6840bda21 100644 --- a/k9mail/src/main/java/com/fsck/k9/K9.java +++ b/k9mail/src/main/java/com/fsck/k9/K9.java @@ -243,6 +243,7 @@ public class K9 extends Application { private static boolean mHideTimeZone = false; private static String sCryptoProvider = ""; + private static boolean sCryptoSupportSignOnly = false; private static SortType mSortType; private static Map mSortAscending = new HashMap(); @@ -469,6 +470,7 @@ public class K9 extends Application { editor.putBoolean("hideTimeZone", mHideTimeZone); editor.putString("cryptoProvider", sCryptoProvider); + editor.putBoolean("cryptoSupportSignOnly", sCryptoSupportSignOnly); editor.putString("language", language); editor.putInt("theme", theme.ordinal()); @@ -689,6 +691,7 @@ public class K9 extends Application { mHideTimeZone = storage.getBoolean("hideTimeZone", false); sCryptoProvider = storage.getString("cryptoProvider", NO_CRYPTO_PROVIDER); + sCryptoSupportSignOnly = storage.getBoolean("cryptoSupportSignOnly", false); mConfirmDelete = storage.getBoolean("confirmDelete", false); mConfirmDiscardMessage = storage.getBoolean("confirmDiscardMessage", true); @@ -1247,6 +1250,14 @@ public class K9 extends Application { sCryptoProvider = cryptoProvider; } + public static boolean getCryptoSupportSignOnly() { + return sCryptoSupportSignOnly; + } + + public static void setCryptoSupportSignOnly(boolean supportSignOnly) { + sCryptoSupportSignOnly = supportSignOnly; + } + public static String getAttachmentDefaultPath() { return mAttachmentDefaultPath; } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java index 5861c537d..222307a86 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java @@ -251,7 +251,7 @@ public class RecipientPresenter implements PermissionPingCallback { menu.findItem(R.id.openpgp_inline_enable).setVisible(isCryptoConfigured && !cryptoEnablePgpInline); menu.findItem(R.id.openpgp_inline_disable).setVisible(isCryptoConfigured && cryptoEnablePgpInline); - boolean showSignOnly = isCryptoConfigured && account.getCryptoSupportSignOnly(); + boolean showSignOnly = isCryptoConfigured && K9.getCryptoSupportSignOnly(); boolean isSignOnly = cachedCryptoStatus.isSignOnly(); menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly); diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java index 5a19c77b8..096c76b8f 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java @@ -113,7 +113,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_KEY = "crypto_key"; - private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only"; 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"; @@ -698,7 +697,6 @@ public class AccountSettings extends K9PreferenceActivity { PreferenceScreen cryptoMenu = (PreferenceScreen) findPreference(PREFERENCE_CRYPTO); if (mHasCrypto) { mCryptoKey = (OpenPgpKeyPreference) findPreference(PREFERENCE_CRYPTO_KEY); - mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); mCryptoKey.setValue(mAccount.getCryptoKey()); mCryptoKey.setOpenPgpProvider(K9.getCryptoProvider()); @@ -712,7 +710,6 @@ public class AccountSettings extends K9PreferenceActivity { } }); - mCryptoSupportSignOnly.setChecked(mAccount.getCryptoSupportSignOnly()); cryptoMenu.setOnPreferenceClickListener(null); } else { cryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_configured); @@ -791,10 +788,8 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue()); if (mHasCrypto) { mAccount.setCryptoKey(mCryptoKey.getValue()); - mAccount.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked()); } else { mAccount.setCryptoKey(Account.NO_OPENPGP_KEY); - mAccount.setCryptoSupportSignOnly(false); } // In webdav account we use the exact folder name also for inbox, diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/Prefs.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/Prefs.java index 78b5dc3b4..c4bfc2d1b 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/Prefs.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/Prefs.java @@ -94,6 +94,7 @@ public class Prefs extends K9PreferenceActivity { private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone"; private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; + private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only"; private static final String PREFERENCE_AUTOFIT_WIDTH = "messageview_autofit_width"; private static final String PREFERENCE_BACKGROUND_OPS = "background_ops"; @@ -155,6 +156,7 @@ public class Prefs extends K9PreferenceActivity { private CheckBoxListPreference mVisibleRefileActions; private OpenPgpAppPreference mCryptoProvider; + private CheckBoxPreference mCryptoSupportSignOnly; private CheckBoxPreference mQuietTimeEnabled; private CheckBoxPreference mDisableNotificationDuringQuietTime; @@ -401,6 +403,9 @@ public class Prefs extends K9PreferenceActivity { } }); + mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); + mCryptoSupportSignOnly.setChecked(K9.getCryptoSupportSignOnly()); + mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH); mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath()); mAttachmentPathPreference @@ -557,6 +562,7 @@ public class Prefs extends K9PreferenceActivity { K9.setHideTimeZone(mHideTimeZone.isChecked()); K9.setCryptoProvider(mCryptoProvider.getValue()); + K9.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked()); StorageEditor editor = storage.edit(); K9.save(editor); diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java b/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java index 6f57f9509..e44b7f5b9 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java @@ -293,6 +293,9 @@ public class GlobalSettings { s.put("cryptoProvider", Settings.versions( new V(46, new StringSetting(K9.NO_CRYPTO_PROVIDER)) )); + s.put("cryptoSupportSignOnly", Settings.versions( + new V(47, new BooleanSetting(false)) + )); SETTINGS = Collections.unmodifiableMap(s); diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/Settings.java b/k9mail/src/main/java/com/fsck/k9/preferences/Settings.java index c9a906615..df629761a 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/Settings.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/Settings.java @@ -36,7 +36,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 46; + public static final int VERSION = 47; static Map validate(int version, Map> settings, Map importedSettings, boolean useDefaultValues) { diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java index 7d4b9da11..e1b2021c7 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageCryptoPresenter.java @@ -59,7 +59,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener { return false; } - boolean suppressSignOnlyMessages = !account.getCryptoSupportSignOnly(); + boolean suppressSignOnlyMessages = !K9.getCryptoSupportSignOnly(); if (suppressSignOnlyMessages && displayStatus.isUnencryptedSigned()) { return false; } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java index 4b376605c..9c0fbcd1e 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.java @@ -19,6 +19,7 @@ import android.widget.TextView; import com.fsck.k9.Account; import com.fsck.k9.Account.ShowPictures; +import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.helper.Contacts; import com.fsck.k9.mail.Address; @@ -114,7 +115,7 @@ public class MessageTopView extends LinearLayout { containerView, false); containerView.addView(view); - boolean hideUnsignedTextDivider = !account.getCryptoSupportSignOnly(); + boolean hideUnsignedTextDivider = !K9.getCryptoSupportSignOnly(); view.displayMessageViewContainer(messageViewInfo, new OnRenderingFinishedListener() { @Override public void onLoadFinished() { diff --git a/k9mail/src/main/res/xml/account_settings_preferences.xml b/k9mail/src/main/res/xml/account_settings_preferences.xml index 6f906b7b3..c4235b6ea 100644 --- a/k9mail/src/main/res/xml/account_settings_preferences.xml +++ b/k9mail/src/main/res/xml/account_settings_preferences.xml @@ -479,13 +479,6 @@ android:key="crypto_key" android:title="@string/account_settings_crypto_key" /> - - - diff --git a/k9mail/src/main/res/xml/global_preferences.xml b/k9mail/src/main/res/xml/global_preferences.xml index e73277250..b0935d5b8 100644 --- a/k9mail/src/main/res/xml/global_preferences.xml +++ b/k9mail/src/main/res/xml/global_preferences.xml @@ -409,8 +409,21 @@ - + + + + + + + +