From 18ad00790a927c8ec500cc2fc5e3623bafcdf42d Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 9 Apr 2018 21:15:15 +0200 Subject: [PATCH] Add setting to store all drafts encrypted --- app/core/src/main/java/com/fsck/k9/Account.java | 11 +++++++++++ .../java/com/fsck/k9/preferences/AccountSettings.java | 3 +++ .../main/java/com/fsck/k9/preferences/Settings.java | 2 +- .../java/com/fsck/k9/message/PgpMessageBuilderTest.kt | 1 + .../ui/settings/account/AccountSettingsDataStore.kt | 2 ++ app/ui/src/main/res/values/strings.xml | 4 +++- app/ui/src/main/res/xml/account_settings.xml | 8 ++++++++ 7 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/core/src/main/java/com/fsck/k9/Account.java b/app/core/src/main/java/com/fsck/k9/Account.java index c05b30f7a..7edaf2513 100644 --- a/app/core/src/main/java/com/fsck/k9/Account.java +++ b/app/core/src/main/java/com/fsck/k9/Account.java @@ -216,6 +216,7 @@ public class Account implements BaseAccount, StoreConfig { private boolean autocryptPreferEncryptMutual; private boolean openPgpHideSignOnly; private boolean openPgpEncryptSubject; + private boolean openPgpEncryptAllDrafts; private boolean markMessageAsReadOnView; private boolean alwaysShowCcBcc; private boolean allowRemoteSearch; @@ -461,6 +462,7 @@ public class Account implements BaseAccount, StoreConfig { openPgpKey = storage.getLong(accountUuid + ".cryptoKey", NO_OPENPGP_KEY); openPgpHideSignOnly = storage.getBoolean(accountUuid + ".openPgpHideSignOnly", true); openPgpEncryptSubject = storage.getBoolean(accountUuid + ".openPgpEncryptSubject", true); + openPgpEncryptAllDrafts = storage.getBoolean(accountUuid + ".openPgpEncryptAllDrafts", true); autocryptPreferEncryptMutual = storage.getBoolean(accountUuid + ".autocryptMutualMode", false); allowRemoteSearch = storage.getBoolean(accountUuid + ".allowRemoteSearch", false); remoteSearchFullText = storage.getBoolean(accountUuid + ".remoteSearchFullText", false); @@ -740,6 +742,7 @@ public class Account implements BaseAccount, StoreConfig { editor.putLong(accountUuid + ".cryptoKey", openPgpKey); editor.putBoolean(accountUuid + ".openPgpHideSignOnly", openPgpHideSignOnly); editor.putBoolean(accountUuid + ".openPgpEncryptSubject", openPgpEncryptSubject); + editor.putBoolean(accountUuid + ".openPgpEncryptAllDrafts", openPgpEncryptAllDrafts); editor.putString(accountUuid + ".openPgpProvider", openPgpProvider); editor.putBoolean(accountUuid + ".autocryptMutualMode", autocryptPreferEncryptMutual); editor.putBoolean(accountUuid + ".allowRemoteSearch", allowRemoteSearch); @@ -1591,6 +1594,14 @@ public class Account implements BaseAccount, StoreConfig { this.openPgpEncryptSubject = openPgpEncryptSubject; } + public boolean getOpenPgpEncryptAllDrafts() { + return openPgpEncryptAllDrafts; + } + + public void setOpenPgpEncryptAllDrafts(boolean openPgpEncryptAllDrafts) { + this.openPgpEncryptAllDrafts = openPgpEncryptAllDrafts; + } + public boolean allowRemoteSearch() { return allowRemoteSearch; } diff --git a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettings.java b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettings.java index 9e7b19d44..75c0f1afd 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettings.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettings.java @@ -239,6 +239,9 @@ public class AccountSettings { s.put("openPgpEncryptSubject", Settings.versions( new V(51, new BooleanSetting(true)) )); + s.put("openPgpEncryptAllDrafts", Settings.versions( + new V(55, new BooleanSetting(true)) + )); s.put("autocryptMutualMode", Settings.versions( new V(50, new BooleanSetting(false)) )); diff --git a/app/core/src/main/java/com/fsck/k9/preferences/Settings.java b/app/core/src/main/java/com/fsck/k9/preferences/Settings.java index d2982c9b8..cb2909047 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/Settings.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/Settings.java @@ -36,7 +36,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 54; + public static final int VERSION = 55; static Map validate(int version, Map> settings, Map importedSettings, boolean useDefaultValues) { diff --git a/app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt b/app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt index b4bfdd5ad..421578df5 100644 --- a/app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt +++ b/app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt @@ -55,6 +55,7 @@ class PgpMessageBuilderTest : RobolectricTest() { false, false, true, + true, CryptoMode.NO_CHOICE ) private val openPgpApi = mock(OpenPgpApi::class.java) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt index bf6cba651..e121e26c5 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt @@ -36,6 +36,7 @@ class AccountSettingsDataStore( "remote_search_enabled" -> account.allowRemoteSearch() "openpgp_hide_sign_only" -> account.openPgpHideSignOnly "openpgp_encrypt_subject" -> account.openPgpEncryptSubject + "openpgp_encrypt_all_drafts" -> account.openPgpEncryptAllDrafts "autocrypt_prefer_encrypt" -> account.autocryptPreferEncryptMutual "upload_sent_messages" -> account.isUploadSentMessages else -> defValue @@ -68,6 +69,7 @@ class AccountSettingsDataStore( "remote_search_enabled" -> account.setAllowRemoteSearch(value) "openpgp_hide_sign_only" -> account.openPgpHideSignOnly = value "openpgp_encrypt_subject" -> account.openPgpEncryptSubject = value + "openpgp_encrypt_all_drafts" -> account.openPgpEncryptAllDrafts = value "autocrypt_prefer_encrypt" -> account.autocryptPreferEncryptMutual = value "upload_sent_messages" -> account.isUploadSentMessages = value else -> return diff --git a/app/ui/src/main/res/values/strings.xml b/app/ui/src/main/res/values/strings.xml index 9f48956c7..58a5bbf9b 100644 --- a/app/ui/src/main/res/values/strings.xml +++ b/app/ui/src/main/res/values/strings.xml @@ -606,6 +606,9 @@ Please submit bug reports, contribute new features and ask questions at Configuring… No OpenPGP app configured No OpenPGP app found - click to install + Store all drafts encrypted + All drafts will be stored encrypted + Encrypt drafts only if encryption is enabled Folder poll frequency @@ -1351,7 +1354,6 @@ You can keep this message and use it as a backup for your secret key. If you wan Open Close - Allow access to contacts To be able to provide contact suggestions and to display contact names and photos, the app needs access to your contacts. diff --git a/app/ui/src/main/res/xml/account_settings.xml b/app/ui/src/main/res/xml/account_settings.xml index 07a4be5c5..de4254557 100644 --- a/app/ui/src/main/res/xml/account_settings.xml +++ b/app/ui/src/main/res/xml/account_settings.xml @@ -447,6 +447,14 @@ android:summary="@string/account_settings_crypto_encrypt_subject_subtitle" android:title="@string/account_settings_crypto_encrypt_subject" /> + +