Option to auto encrypt on reply

pull/215/head
M66B 3 months ago
parent 9ab3805dcc
commit 322cb2f803

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

@ -88,6 +88,7 @@ public class FragmentOptionsEncryption extends FragmentBase
private SwitchCompat swSign;
private SwitchCompat swEncrypt;
private SwitchCompat swEncryptAuto;
private SwitchCompat swEncryptReply;
private SwitchCompat swAutoVerify;
private SwitchCompat swAutoDecrypt;
private SwitchCompat swAutoUndoDecrypt;
@ -119,7 +120,7 @@ public class FragmentOptionsEncryption extends FragmentBase
static final int REQUEST_IMPORT_CERTIFICATE = 1;
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",
"openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject",
"sign_algo_smime", "encrypt_algo_smime", "check_certificate"
@ -141,6 +142,7 @@ public class FragmentOptionsEncryption extends FragmentBase
swSign = view.findViewById(R.id.swSign);
swEncrypt = view.findViewById(R.id.swEncrypt);
swEncryptAuto = view.findViewById(R.id.swEncryptAuto);
swEncryptReply = view.findViewById(R.id.swEncryptReply);
swAutoVerify = view.findViewById(R.id.swAutoVerify);
swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt);
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() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -664,6 +673,7 @@ public class FragmentOptionsEncryption extends FragmentBase
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
swSign.setEnabled(!swEncrypt.isChecked());
swEncryptAuto.setChecked(prefs.getBoolean("encrypt_auto", false));
swEncryptReply.setChecked(prefs.getBoolean("encrypt_reply", false));
swAutoVerify.setChecked(prefs.getBoolean("auto_verify", false));
swAutoDecrypt.setChecked(prefs.getBoolean("auto_decrypt", false));
swAutoUndoDecrypt.setChecked(prefs.getBoolean("auto_undecrypt", false));

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

@ -839,6 +839,7 @@
<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_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_decrypt">Automatically decrypt messages</string>
<string name="title_advanced_auto_undo_decrypt">Undo decryption on closing conversation</string>

Loading…
Cancel
Save