Option to auto encrypt on reply

pull/215/head
M66B 1 year ago
parent 9ab3805dcc
commit 322cb2f803

@ -5496,6 +5496,7 @@ public class FragmentCompose extends FragmentBase {
boolean resize_reply = prefs.getBoolean("resize_reply", true); boolean resize_reply = prefs.getBoolean("resize_reply", true);
boolean sign_default = prefs.getBoolean("sign_default", false); boolean sign_default = prefs.getBoolean("sign_default", false);
boolean encrypt_default = prefs.getBoolean("encrypt_default", false); boolean encrypt_default = prefs.getBoolean("encrypt_default", false);
boolean encrypt_reply = prefs.getBoolean("encrypt_reply", false);
boolean receipt_default = prefs.getBoolean("receipt_default", false); boolean receipt_default = prefs.getBoolean("receipt_default", false);
boolean write_below = prefs.getBoolean("write_below", false); boolean write_below = prefs.getBoolean("write_below", false);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true); boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
@ -5981,17 +5982,21 @@ public class FragmentCompose extends FragmentBase {
// Encryption // Encryption
List<Address> recipients = data.draft.getAllRecipients(); List<Address> recipients = data.draft.getAllRecipients();
boolean reply = (encrypt_reply && (
EntityMessage.PGP_SIGNENCRYPT.equals(ref.ui_encrypt) ||
EntityMessage.SMIME_SIGNENCRYPT.equals(ref.ui_encrypt)));
if (EntityMessage.PGP_SIGNONLY.equals(ref.ui_encrypt) || if (EntityMessage.PGP_SIGNONLY.equals(ref.ui_encrypt) ||
EntityMessage.PGP_SIGNENCRYPT.equals(ref.ui_encrypt)) { EntityMessage.PGP_SIGNENCRYPT.equals(ref.ui_encrypt)) {
if (PgpHelper.isOpenKeychainInstalled(context) && if (PgpHelper.isOpenKeychainInstalled(context) &&
selected.sign_key != null && selected.sign_key != null &&
PgpHelper.hasPgpKey(context, recipients, true)) (reply || PgpHelper.hasPgpKey(context, recipients, true)))
data.draft.ui_encrypt = ref.ui_encrypt; data.draft.ui_encrypt = ref.ui_encrypt;
} else if (EntityMessage.SMIME_SIGNONLY.equals(ref.ui_encrypt) || } else if (EntityMessage.SMIME_SIGNONLY.equals(ref.ui_encrypt) ||
EntityMessage.SMIME_SIGNENCRYPT.equals(ref.ui_encrypt)) { EntityMessage.SMIME_SIGNENCRYPT.equals(ref.ui_encrypt)) {
if (ActivityBilling.isPro(context) && if (ActivityBilling.isPro(context) &&
selected.sign_key_alias != null && selected.sign_key_alias != null &&
SmimeHelper.hasSmimeKey(context, recipients, true)) (reply || SmimeHelper.hasSmimeKey(context, recipients, true)))
data.draft.ui_encrypt = ref.ui_encrypt; data.draft.ui_encrypt = ref.ui_encrypt;
} }
} }

@ -88,6 +88,7 @@ public class FragmentOptionsEncryption extends FragmentBase
private SwitchCompat swSign; private SwitchCompat swSign;
private SwitchCompat swEncrypt; private SwitchCompat swEncrypt;
private SwitchCompat swEncryptAuto; private SwitchCompat swEncryptAuto;
private SwitchCompat swEncryptReply;
private SwitchCompat swAutoVerify; private SwitchCompat swAutoVerify;
private SwitchCompat swAutoDecrypt; private SwitchCompat swAutoDecrypt;
private SwitchCompat swAutoUndoDecrypt; private SwitchCompat swAutoUndoDecrypt;
@ -119,7 +120,7 @@ public class FragmentOptionsEncryption extends FragmentBase
static final int REQUEST_IMPORT_CERTIFICATE = 1; static final int REQUEST_IMPORT_CERTIFICATE = 1;
final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList( final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
"sign_default", "encrypt_default", "encrypt_auto", "sign_default", "encrypt_default", "encrypt_auto", "encrypt_reply",
"auto_verify", "auto_decrypt", "auto_undecrypt", "auto_verify", "auto_decrypt", "auto_undecrypt",
"openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject", "openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject",
"sign_algo_smime", "encrypt_algo_smime", "check_certificate" "sign_algo_smime", "encrypt_algo_smime", "check_certificate"
@ -141,6 +142,7 @@ public class FragmentOptionsEncryption extends FragmentBase
swSign = view.findViewById(R.id.swSign); swSign = view.findViewById(R.id.swSign);
swEncrypt = view.findViewById(R.id.swEncrypt); swEncrypt = view.findViewById(R.id.swEncrypt);
swEncryptAuto = view.findViewById(R.id.swEncryptAuto); swEncryptAuto = view.findViewById(R.id.swEncryptAuto);
swEncryptReply = view.findViewById(R.id.swEncryptReply);
swAutoVerify = view.findViewById(R.id.swAutoVerify); swAutoVerify = view.findViewById(R.id.swAutoVerify);
swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt); swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt);
swAutoUndoDecrypt = view.findViewById(R.id.swAutoUndoDecrypt); swAutoUndoDecrypt = view.findViewById(R.id.swAutoUndoDecrypt);
@ -228,6 +230,13 @@ public class FragmentOptionsEncryption extends FragmentBase
} }
}); });
swEncryptReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("encrypt_reply", checked).apply();
}
});
swAutoVerify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swAutoVerify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -664,6 +673,7 @@ public class FragmentOptionsEncryption extends FragmentBase
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false)); swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
swSign.setEnabled(!swEncrypt.isChecked()); swSign.setEnabled(!swEncrypt.isChecked());
swEncryptAuto.setChecked(prefs.getBoolean("encrypt_auto", false)); swEncryptAuto.setChecked(prefs.getBoolean("encrypt_auto", false));
swEncryptReply.setChecked(prefs.getBoolean("encrypt_reply", false));
swAutoVerify.setChecked(prefs.getBoolean("auto_verify", false)); swAutoVerify.setChecked(prefs.getBoolean("auto_verify", false));
swAutoDecrypt.setChecked(prefs.getBoolean("auto_decrypt", false)); swAutoDecrypt.setChecked(prefs.getBoolean("auto_decrypt", false));
swAutoUndoDecrypt.setChecked(prefs.getBoolean("auto_undecrypt", false)); swAutoUndoDecrypt.setChecked(prefs.getBoolean("auto_undecrypt", false));

@ -130,6 +130,17 @@
app:layout_constraintTop_toBottomOf="@id/swEncrypt" app:layout_constraintTop_toBottomOf="@id/swEncrypt"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEncryptReply"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_encrypt_reply"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swEncryptAuto"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoVerify" android:id="@+id/swAutoVerify"
android:layout_width="0dp" android:layout_width="0dp"
@ -138,7 +149,7 @@
android:text="@string/title_advanced_auto_verify" android:text="@string/title_advanced_auto_verify"
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/swEncryptAuto" app:layout_constraintTop_toBottomOf="@id/swEncryptReply"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -839,6 +839,7 @@
<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>
<string name="title_advanced_encrypt_auto">Automatically encrypt when all recipients\' keys are available</string> <string name="title_advanced_encrypt_auto">Automatically encrypt when all recipients\' keys are available</string>
<string name="title_advanced_encrypt_reply">Automatically encrypt when replying to an encrypted message</string>
<string name="title_advanced_auto_verify">Automatically verify signed messages</string> <string name="title_advanced_auto_verify">Automatically verify signed messages</string>
<string name="title_advanced_auto_decrypt">Automatically decrypt messages</string> <string name="title_advanced_auto_decrypt">Automatically decrypt messages</string>
<string name="title_advanced_auto_undo_decrypt">Undo decryption on closing conversation</string> <string name="title_advanced_auto_undo_decrypt">Undo decryption on closing conversation</string>

Loading…
Cancel
Save