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

pull/214/head
M66B 2 years ago
parent ca54f1559c
commit 7f18979613

@ -72,7 +72,6 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.text.style.QuoteSpan; import android.text.style.QuoteSpan;
import android.text.style.RelativeSizeSpan; import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.text.style.UnderlineSpan; 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_reply_domain;
private boolean check_mx; private boolean check_mx;
private boolean check_blocklist; private boolean check_blocklist;
private boolean show_addresses_default;
private boolean hide_attachments_default;
private MessageHelper.AddressFormat email_format; private MessageHelper.AddressFormat email_format;
private boolean prefer_contact; private boolean prefer_contact;
@ -2544,7 +2545,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void bindAddresses(TupleMessageEx message) { 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); boolean full = (show_addresses || email_format == MessageHelper.AddressFormat.NAME_EMAIL);
int froms = (message.from == null || int froms = (message.from == null ||
@ -3608,7 +3609,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
attachments = new ArrayList<>(); attachments = new ArrayList<>();
properties.setAttachments(message.id, attachments); 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); boolean show_inline = properties.getValue("inline", message.id);
Log.i("Hide attachments=" + hide_attachments + " Show inline=" + show_inline); 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) { 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); properties.setValue("addresses", message.id, addresses);
bindAddresses(message); 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) { private void onDownloadAttachments(final TupleMessageEx message) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);
@ -5415,7 +5434,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void onExpandAttachments(TupleMessageEx message) { 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); properties.setValue("hide_attachments", message.id, !hide_attachments);
cowner.restart(); cowner.restart();
bindAttachments(message, properties.getAttachments(message.id), false); 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_reply_domain = prefs.getBoolean("check_reply_domain", true);
this.check_mx = prefs.getBoolean("check_mx", false); this.check_mx = prefs.getBoolean("check_mx", false);
this.check_blocklist = prefs.getBoolean("check_blocklist", 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.email_format = MessageHelper.getAddressFormat(context);
this.prefer_contact = prefs.getBoolean("prefer_contact", false); 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 getValue(String name, long id, boolean def);
void setExpanded(TupleMessageEx message, boolean expanded, boolean scroll); void setExpanded(TupleMessageEx message, boolean expanded, boolean scroll);
void setSize(long id, Float size); void setSize(long id, Float size);

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

Loading…
Cancel
Save