mirror of https://github.com/M66B/FairEmail.git
Added option to disable Autocrypt
This commit is contained in:
parent
da3bc81473
commit
694a97600f
|
@ -4468,7 +4468,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
else
|
else
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_not_encrypted));
|
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 &&
|
message.autocrypt != null &&
|
||||||
OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(data.getAction()))
|
OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(data.getAction()))
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
private SwitchCompat swDisplayHidden;
|
private SwitchCompat swDisplayHidden;
|
||||||
private Spinner spEncryptMethod;
|
private Spinner spEncryptMethod;
|
||||||
private Spinner spOpenPgp;
|
private Spinner spOpenPgp;
|
||||||
|
private SwitchCompat swAutocrypt;
|
||||||
private SwitchCompat swAutocryptMutual;
|
private SwitchCompat swAutocryptMutual;
|
||||||
private SwitchCompat swSign;
|
private SwitchCompat swSign;
|
||||||
private SwitchCompat swEncrypt;
|
private SwitchCompat swEncrypt;
|
||||||
|
@ -84,7 +85,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
|
|
||||||
private final static String[] RESET_OPTIONS = new String[]{
|
private final static String[] RESET_OPTIONS = new String[]{
|
||||||
"disable_tracking", "display_hidden",
|
"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",
|
"secure",
|
||||||
"biometrics", "pin", "biometrics_timeout"
|
"biometrics", "pin", "biometrics_timeout"
|
||||||
};
|
};
|
||||||
|
@ -104,6 +106,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
|
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
|
||||||
spEncryptMethod = view.findViewById(R.id.spEncryptMethod);
|
spEncryptMethod = view.findViewById(R.id.spEncryptMethod);
|
||||||
spOpenPgp = view.findViewById(R.id.spOpenPgp);
|
spOpenPgp = view.findViewById(R.id.spOpenPgp);
|
||||||
|
swAutocrypt = view.findViewById(R.id.swAutocrypt);
|
||||||
swAutocryptMutual = view.findViewById(R.id.swAutocryptMutual);
|
swAutocryptMutual = view.findViewById(R.id.swAutocryptMutual);
|
||||||
swSign = view.findViewById(R.id.swSign);
|
swSign = view.findViewById(R.id.swSign);
|
||||||
swEncrypt = view.findViewById(R.id.swEncrypt);
|
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() {
|
swAutocryptMutual.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -356,7 +367,9 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swAutocrypt.setChecked(prefs.getBoolean("autocrypt", true));
|
||||||
swAutocryptMutual.setChecked(prefs.getBoolean("autocrypt_mutual", true));
|
swAutocryptMutual.setChecked(prefs.getBoolean("autocrypt_mutual", true));
|
||||||
|
swAutocryptMutual.setEnabled(swAutocrypt.isChecked());
|
||||||
swSign.setChecked(prefs.getBoolean("sign_default", false));
|
swSign.setChecked(prefs.getBoolean("sign_default", false));
|
||||||
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
|
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
|
||||||
swSign.setEnabled(!swEncrypt.isChecked());
|
swSign.setEnabled(!swEncrypt.isChecked());
|
||||||
|
|
|
@ -243,7 +243,10 @@ public class MessageHelper {
|
||||||
InternetAddress from = (InternetAddress) message.from[0];
|
InternetAddress from = (InternetAddress) message.from[0];
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean autocrypt = prefs.getBoolean("autocrypt", true);
|
||||||
boolean mutual = prefs.getBoolean("autocrypt_mutual", true);
|
boolean mutual = prefs.getBoolean("autocrypt_mutual", true);
|
||||||
|
|
||||||
|
if (autocrypt) {
|
||||||
String mode = (mutual ? "mutual" : "nopreference");
|
String mode = (mutual ? "mutual" : "nopreference");
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -272,6 +275,7 @@ public class MessageHelper {
|
||||||
" prefer-encrypt=" + mode + ";" +
|
" prefer-encrypt=" + mode + ";" +
|
||||||
" keydata=" + sb.toString());
|
" keydata=" + sb.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PGP: https://tools.ietf.org/html/rfc3156
|
// PGP: https://tools.ietf.org/html/rfc3156
|
||||||
// S/MIME: https://tools.ietf.org/html/rfc8551
|
// S/MIME: https://tools.ietf.org/html/rfc8551
|
||||||
|
|
|
@ -90,6 +90,18 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvOpenPgp" />
|
app:layout_constraintTop_toBottomOf="@id/tvOpenPgp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swAutocrypt"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/title_advanced_autocrypt"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/spOpenPgp"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swAutocryptMutual"
|
android:id="@+id/swAutocryptMutual"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -99,7 +111,7 @@
|
||||||
android:text="@string/title_advanced_autocrypt_mutual"
|
android:text="@string/title_advanced_autocrypt_mutual"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/spOpenPgp"
|
app:layout_constraintTop_toBottomOf="@id/swAutocrypt"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
|
|
@ -359,6 +359,7 @@
|
||||||
<string name="title_advanced_display_hidden">Display hidden message texts</string>
|
<string name="title_advanced_display_hidden">Display hidden message texts</string>
|
||||||
<string name="title_advanced_encrypt_method">Default encryption method</string>
|
<string name="title_advanced_encrypt_method">Default encryption method</string>
|
||||||
<string name="title_advanced_openpgp">OpenPGP provider</string>
|
<string name="title_advanced_openpgp">OpenPGP provider</string>
|
||||||
|
<string name="title_advanced_autocrypt">Use Autocrypt</string>
|
||||||
<string name="title_advanced_autocrypt_mutual">Autocrypt mutual mode</string>
|
<string name="title_advanced_autocrypt_mutual">Autocrypt mutual mode</string>
|
||||||
<string name="title_advanced_sign_default">Sign by default</string>
|
<string name="title_advanced_sign_default">Sign by default</string>
|
||||||
<string name="title_advanced_encrypt_default">Encrypt by default</string>
|
<string name="title_advanced_encrypt_default">Encrypt by default</string>
|
||||||
|
|
Loading…
Reference in New Issue