Add setting to store all drafts encrypted

This commit is contained in:
Vincent Breitmoser 2018-04-09 21:15:15 +02:00
parent f9527b9e67
commit 18ad00790a
7 changed files with 29 additions and 2 deletions

View file

@ -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;
}

View file

@ -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))
));

View file

@ -36,7 +36,7 @@ public class Settings {
*
* @see SettingsExporter
*/
public static final int VERSION = 54;
public static final int VERSION = 55;
static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
Map<String, String> importedSettings, boolean useDefaultValues) {

View file

@ -55,6 +55,7 @@ class PgpMessageBuilderTest : RobolectricTest() {
false,
false,
true,
true,
CryptoMode.NO_CHOICE
)
private val openPgpApi = mock(OpenPgpApi::class.java)

View file

@ -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

View file

@ -606,6 +606,9 @@ Please submit bug reports, contribute new features and ask questions at
<string name="account_settings_crypto_summary_config">Configuring…</string>
<string name="account_settings_no_openpgp_provider_configured">No OpenPGP app configured</string>
<string name="account_settings_no_openpgp_provider_installed">No OpenPGP app found - click to install</string>
<string name="account_settings_crypto_encrypt_all_drafts">Store all drafts encrypted</string>
<string name="account_settings_crypto_encrypt_all_drafts_on">All drafts will be stored encrypted</string>
<string name="account_settings_crypto_encrypt_all_drafts_off">Encrypt drafts only if encryption is enabled</string>
<string name="account_settings_mail_check_frequency_label">Folder poll frequency</string>
@ -1351,7 +1354,6 @@ You can keep this message and use it as a backup for your secret key. If you wan
<string name="navigation_drawer_open">Open</string>
<string name="navigation_drawer_close">Close</string>
<!-- permissions -->
<string name="permission_contacts_rationale_title">Allow access to contacts</string>
<string name="permission_contacts_rationale_message">To be able to provide contact suggestions and to display contact names and photos, the app needs access to your contacts.</string>

View file

@ -447,6 +447,14 @@
android:summary="@string/account_settings_crypto_encrypt_subject_subtitle"
android:title="@string/account_settings_crypto_encrypt_subject" />
<SwitchPreference
android:dependency="openpgp_key"
android:key="openpgp_encrypt_all_drafts"
android:title="@string/account_settings_crypto_encrypt_all_drafts"
android:summaryOn="@string/account_settings_crypto_encrypt_all_drafts_on"
android:summaryOff="@string/account_settings_crypto_encrypt_all_drafts_off"
/>
<Preference
android:dependency="openpgp_key"
android:key="autocrypt_transfer"