From 076b576f9d4f408fe09d810bff6089b26da490c8 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 12 Apr 2021 18:04:15 +0200 Subject: [PATCH] Format addresses max --- .../eu/faircode/email/AdapterMessage.java | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 5a21d4fc50..6ba444ee9b 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1767,12 +1767,16 @@ public class AdapterMessage extends RecyclerView.Adapter 0) ssb.append("; "); @@ -1803,6 +1807,9 @@ public class AdapterMessage extends RecyclerView.Adapter max) + ssb.append(context.getString(R.string.title_name_plus, "", addresses.length - max)); + return ssb; } @@ -1816,10 +1823,7 @@ public class AdapterMessage extends RecyclerView.Adapter 1 || show_addresses) && !TextUtils.isEmpty(from) ? View.VISIBLE : View.GONE); tvFromEx.setText(from); - tvToTitle.setVisibility((!show_recipients || show_addresses) && !TextUtils.isEmpty(to) ? View.VISIBLE : View.GONE); - tvTo.setVisibility((!show_recipients || show_addresses) && !TextUtils.isEmpty(to) ? View.VISIBLE : View.GONE); - if (show_addresses || (message.to == null || message.to.length < MAX_RECIPIENTS)) - tvTo.setText(to); - else - tvTo.setText(context.getString(R.string.title_recipients, message.to.length)); + tvToTitle.setVisibility((!show_recipients || show_addresses) && (message.to != null && message.to.length > 0) ? View.VISIBLE : View.GONE); + tvTo.setVisibility((!show_recipients || show_addresses) && (message.to != null && message.to.length > 0) ? View.VISIBLE : View.GONE); + tvTo.setText(formatAddresses(message.to, full, show_addresses ? Integer.MAX_VALUE : MAX_RECIPIENTS)); tvReplyToTitle.setVisibility(show_addresses && !TextUtils.isEmpty(replyto) ? View.VISIBLE : View.GONE); tvReplyTo.setVisibility(show_addresses && !TextUtils.isEmpty(replyto) ? View.VISIBLE : View.GONE); tvReplyTo.setText(replyto); - tvCcTitle.setVisibility(!TextUtils.isEmpty(cc) ? View.VISIBLE : View.GONE); - tvCc.setVisibility(!TextUtils.isEmpty(cc) ? View.VISIBLE : View.GONE); - if (show_addresses || (message.cc == null || message.cc.length < MAX_RECIPIENTS)) - tvCc.setText(cc); - else - tvCc.setText(context.getString(R.string.title_recipients, message.cc.length)); + tvCcTitle.setVisibility(message.cc == null || message.cc.length == 0 ? View.GONE : View.VISIBLE); + tvCc.setVisibility(message.cc == null || message.cc.length == 0 ? View.GONE : View.VISIBLE); + tvCc.setText(formatAddresses(message.cc, full, show_addresses ? Integer.MAX_VALUE : MAX_RECIPIENTS)); - tvBccTitle.setVisibility(!TextUtils.isEmpty(bcc) ? View.VISIBLE : View.GONE); - tvBcc.setVisibility(!TextUtils.isEmpty(bcc) ? View.VISIBLE : View.GONE); - if (show_addresses || (message.bcc == null || message.bcc.length < MAX_RECIPIENTS)) - tvBcc.setText(bcc); - else - tvBcc.setText(context.getString(R.string.title_recipients, message.bcc.length)); + tvBccTitle.setVisibility(message.bcc == null || message.bcc.length == 0 ? View.GONE : View.VISIBLE); + tvBcc.setVisibility(message.bcc == null || message.bcc.length == 0 ? View.GONE : View.VISIBLE); + tvBcc.setText(formatAddresses(message.bcc, full, show_addresses ? Integer.MAX_VALUE : MAX_RECIPIENTS)); InternetAddress via = null; if (message.identityEmail != null)