Show addressses by default when from/subject not a single script

This commit is contained in:
M66B 2023-12-02 08:03:17 +01:00
parent ca54f1559c
commit 7f18979613
2 changed files with 34 additions and 18 deletions

View File

@ -72,7 +72,6 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.QuoteSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;
@ -274,6 +273,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean check_reply_domain;
private boolean check_mx;
private boolean check_blocklist;
private boolean show_addresses_default;
private boolean hide_attachments_default;
private MessageHelper.AddressFormat email_format;
private boolean prefer_contact;
@ -2544,7 +2545,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void bindAddresses(TupleMessageEx message) {
boolean show_addresses = properties.getValue("addresses", message.id);
boolean show_addresses = properties.getValue("addresses", message.id, getShowAddressesDefault(message));
boolean full = (show_addresses || email_format == MessageHelper.AddressFormat.NAME_EMAIL);
int froms = (message.from == null ||
@ -3608,7 +3609,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
attachments = new ArrayList<>();
properties.setAttachments(message.id, attachments);
boolean hide_attachments = properties.getValue("hide_attachments", message.id);
boolean hide_attachments = properties.getValue("hide_attachments", message.id, hide_attachments_default);
boolean show_inline = properties.getValue("inline", message.id);
Log.i("Hide attachments=" + hide_attachments + " Show inline=" + show_inline);
@ -5364,11 +5365,29 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onToggleAddresses(TupleMessageEx message) {
boolean addresses = !properties.getValue("addresses", message.id);
boolean addresses = !properties.getValue("addresses", message.id, getShowAddressesDefault(message));
properties.setValue("addresses", message.id, addresses);
bindAddresses(message);
}
private boolean getShowAddressesDefault(TupleMessageEx message) {
if (show_addresses_default)
return true;
if (message.from != null)
for (Address from : message.from) {
if (!(from instanceof InternetAddress))
continue;
if (!TextHelper.isSingleScript(((InternetAddress) from).getPersonal()))
return true;
}
if (!TextHelper.isSingleScript(message.subject))
return true;
return false;
}
private void onDownloadAttachments(final TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
@ -5415,7 +5434,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onExpandAttachments(TupleMessageEx message) {
boolean hide_attachments = properties.getValue("hide_attachments", message.id);
boolean hide_attachments = properties.getValue("hide_attachments", message.id, hide_attachments_default);
properties.setValue("hide_attachments", message.id, !hide_attachments);
cowner.restart();
bindAttachments(message, properties.getAttachments(message.id), false);
@ -7967,6 +7986,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.check_reply_domain = prefs.getBoolean("check_reply_domain", true);
this.check_mx = prefs.getBoolean("check_mx", false);
this.check_blocklist = prefs.getBoolean("check_blocklist", false);
this.show_addresses_default = prefs.getBoolean("addresses", false);
this.hide_attachments_default = prefs.getBoolean("hide_attachments", false);
this.email_format = MessageHelper.getAddressFormat(context);
this.prefer_contact = prefs.getBoolean("prefer_contact", false);
@ -8941,6 +8962,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean getValue(String name, long id);
boolean getValue(String name, long id, boolean def);
void setExpanded(TupleMessageEx message, boolean expanded, boolean scroll);
void setSize(long id, Float size);

View File

@ -345,8 +345,6 @@ public class FragmentMessages extends FragmentBase
private boolean autoclose;
private String onclose;
private boolean quick_scroll;
private boolean addresses;
private boolean hide_attachments;
private boolean auto_hide_answer;
private boolean swipe_reply;
private boolean quick_actions;
@ -500,8 +498,6 @@ public class FragmentMessages extends FragmentBase
autoclose = prefs.getBoolean("autoclose", true);
onclose = (autoclose ? null : prefs.getString("onclose", null));
quick_scroll = prefs.getBoolean("quick_scroll", true);
addresses = prefs.getBoolean("addresses", false);
hide_attachments = prefs.getBoolean("hide_attachments", false);
auto_hide_answer = prefs.getBoolean("auto_hide_answer", false);
swipe_reply = prefs.getBoolean("swipe_reply", false);
quick_actions = prefs.getBoolean("quick_actions", true);
@ -2524,15 +2520,12 @@ public class FragmentMessages extends FragmentBase
@Override
public boolean getValue(String name, long id) {
if (values.containsKey(name))
return values.get(name).contains(id);
else {
if ("addresses".equals(name))
return addresses;
else if ("hide_attachments".equals(name))
return hide_attachments;
}
return false;
return getValue(name, id, false);
}
@Override
public boolean getValue(String name, long id, boolean def) {
return ((values.containsKey(name)) ? values.get(name).contains(id) : def);
}
@Override