diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index ded0a33563..659ccf8950 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -4468,7 +4468,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
else
throw new IllegalArgumentException(context.getString(R.string.title_not_encrypted));
- if (message.from != null && message.from.length > 0 &&
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean autocrypt = prefs.getBoolean("autocrypt", true);
+ if (autocrypt &&
+ message.from != null && message.from.length > 0 &&
message.autocrypt != null &&
OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(data.getAction()))
try {
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
index e9a8688b41..638f4daff0 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
@@ -67,6 +67,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swDisplayHidden;
private Spinner spEncryptMethod;
private Spinner spOpenPgp;
+ private SwitchCompat swAutocrypt;
private SwitchCompat swAutocryptMutual;
private SwitchCompat swSign;
private SwitchCompat swEncrypt;
@@ -84,7 +85,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"disable_tracking", "display_hidden",
- "default_encrypt_method", "openpgp_provider", "autocrypt_mutual", "sign_default", "encrypt_default", "auto_decrypt",
+ "default_encrypt_method", "openpgp_provider", "autocrypt", "autocrypt_mutual",
+ "sign_default", "encrypt_default", "auto_decrypt",
"secure",
"biometrics", "pin", "biometrics_timeout"
};
@@ -104,6 +106,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
spEncryptMethod = view.findViewById(R.id.spEncryptMethod);
spOpenPgp = view.findViewById(R.id.spOpenPgp);
+ swAutocrypt = view.findViewById(R.id.swAutocrypt);
swAutocryptMutual = view.findViewById(R.id.swAutocryptMutual);
swSign = view.findViewById(R.id.swSign);
swEncrypt = view.findViewById(R.id.swEncrypt);
@@ -175,6 +178,14 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
+ swAutocrypt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("autocrypt", checked).apply();
+ swAutocryptMutual.setEnabled(checked);
+ }
+ });
+
swAutocryptMutual.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -356,7 +367,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
break;
}
+ swAutocrypt.setChecked(prefs.getBoolean("autocrypt", true));
swAutocryptMutual.setChecked(prefs.getBoolean("autocrypt_mutual", true));
+ swAutocryptMutual.setEnabled(swAutocrypt.isChecked());
swSign.setChecked(prefs.getBoolean("sign_default", false));
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
swSign.setEnabled(!swEncrypt.isChecked());
diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java
index ebe563c8ed..8e27935037 100644
--- a/app/src/main/java/eu/faircode/email/MessageHelper.java
+++ b/app/src/main/java/eu/faircode/email/MessageHelper.java
@@ -243,34 +243,38 @@ public class MessageHelper {
InternetAddress from = (InternetAddress) message.from[0];
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean autocrypt = prefs.getBoolean("autocrypt", true);
boolean mutual = prefs.getBoolean("autocrypt_mutual", true);
- String mode = (mutual ? "mutual" : "nopreference");
- StringBuilder sb = new StringBuilder();
- File file = attachment.getFile(context);
- try (BufferedReader br = new BufferedReader(new FileReader(file))) {
- String line = br.readLine();
- while (line != null) {
- String data = null;
- if (line.length() > 0 &&
- !line.startsWith("-----BEGIN ") &&
- !line.startsWith("-----END "))
- data = line;
+ if (autocrypt) {
+ String mode = (mutual ? "mutual" : "nopreference");
- line = br.readLine();
+ StringBuilder sb = new StringBuilder();
+ File file = attachment.getFile(context);
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
+ String line = br.readLine();
+ while (line != null) {
+ String data = null;
+ if (line.length() > 0 &&
+ !line.startsWith("-----BEGIN ") &&
+ !line.startsWith("-----END "))
+ data = line;
- // https://www.w3.org/Protocols/rfc822/3_Lexical.html#z0
- if (data != null &&
- line != null && !line.startsWith("-----END "))
- sb.append("\r\n ").append(data);
+ line = br.readLine();
+
+ // https://www.w3.org/Protocols/rfc822/3_Lexical.html#z0
+ if (data != null &&
+ line != null && !line.startsWith("-----END "))
+ sb.append("\r\n ").append(data);
+ }
}
- }
- // https://autocrypt.org/level1.html#the-autocrypt-header
- imessage.addHeader("Autocrypt",
- "addr=" + from.getAddress() + ";" +
- " prefer-encrypt=" + mode + ";" +
- " keydata=" + sb.toString());
+ // https://autocrypt.org/level1.html#the-autocrypt-header
+ imessage.addHeader("Autocrypt",
+ "addr=" + from.getAddress() + ";" +
+ " prefer-encrypt=" + mode + ";" +
+ " keydata=" + sb.toString());
+ }
}
// PGP: https://tools.ietf.org/html/rfc3156
diff --git a/app/src/main/res/layout/fragment_options_privacy.xml b/app/src/main/res/layout/fragment_options_privacy.xml
index d0436002de..c94316bb19 100644
--- a/app/src/main/res/layout/fragment_options_privacy.xml
+++ b/app/src/main/res/layout/fragment_options_privacy.xml
@@ -90,6 +90,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenPgp" />
+
+
Display hidden message texts
Default encryption method
OpenPGP provider
+ Use Autocrypt
Autocrypt mutual mode
Sign by default
Encrypt by default