Fixed resetting selected encryption

This commit is contained in:
M66B 2023-05-06 19:02:42 +02:00
parent 589a27a0b9
commit eef5f92473
1 changed files with 8 additions and 6 deletions

View File

@ -516,7 +516,7 @@ public class FragmentCompose extends FragmentBase {
public void onFocusChange(View v, boolean hasFocus) { public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) if (!hasFocus)
try { try {
updateEncryption((EntityIdentity) spIdentity.getSelectedItem()); updateEncryption((EntityIdentity) spIdentity.getSelectedItem(), false);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }
@ -1382,13 +1382,14 @@ public class FragmentCompose extends FragmentBase {
}.serial().execute(FragmentCompose.this, args, "compose:contact"); }.serial().execute(FragmentCompose.this, args, "compose:contact");
} }
private void updateEncryption(EntityIdentity identity) { private void updateEncryption(EntityIdentity identity, boolean selected) {
if (identity == null) if (identity == null)
return; return;
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", working); args.putLong("id", working);
args.putLong("identity", identity.id); args.putLong("identity", identity.id);
args.putBoolean("selected", selected);
args.putString("to", etTo.getText().toString().trim()); args.putString("to", etTo.getText().toString().trim());
args.putString("cc", etCc.getText().toString().trim()); args.putString("cc", etCc.getText().toString().trim());
args.putString("bcc", etBcc.getText().toString().trim()); args.putString("bcc", etBcc.getText().toString().trim());
@ -1398,6 +1399,7 @@ public class FragmentCompose extends FragmentBase {
protected Integer onExecute(Context context, Bundle args) { protected Integer onExecute(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
long iid = args.getLong("identity"); long iid = args.getLong("identity");
boolean selected = args.getBoolean("selected");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean sign_default = prefs.getBoolean("sign_default", false); boolean sign_default = prefs.getBoolean("sign_default", false);
@ -1441,7 +1443,7 @@ public class FragmentCompose extends FragmentBase {
} }
} }
if (!encrypt_auto || draft.ui_encrypt == null) { if (selected || draft.ui_encrypt == null) {
if (encrypt_default || identity.encrypt_default) if (encrypt_default || identity.encrypt_default)
draft.ui_encrypt = (identity.encrypt == 0 draft.ui_encrypt = (identity.encrypt == 0
? EntityMessage.PGP_SIGNENCRYPT ? EntityMessage.PGP_SIGNENCRYPT
@ -1450,7 +1452,7 @@ public class FragmentCompose extends FragmentBase {
draft.ui_encrypt = (identity.encrypt == 0 draft.ui_encrypt = (identity.encrypt == 0
? EntityMessage.PGP_SIGNONLY ? EntityMessage.PGP_SIGNONLY
: EntityMessage.SMIME_SIGNONLY); : EntityMessage.SMIME_SIGNONLY);
else else if (selected)
draft.ui_encrypt = null; draft.ui_encrypt = null;
} }
@ -7631,7 +7633,7 @@ public class FragmentCompose extends FragmentBase {
if (!Objects.equals(spIdentity.getTag(), position)) { if (!Objects.equals(spIdentity.getTag(), position)) {
spIdentity.setTag(position); spIdentity.setTag(position);
updateEncryption(identity); updateEncryption(identity, true);
} }
} }
@ -7645,7 +7647,7 @@ public class FragmentCompose extends FragmentBase {
setBodyPadding(); setBodyPadding();
updateEncryption(null); updateEncryption(null, true);
} }
}; };