Limit number of recipients in headers

pull/207/head
M66B 3 years ago
parent 0a8ede7d57
commit 372f0b1b5e

@ -1322,11 +1322,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
MessageHelper.AddressFormat format = email_format;
if (show_recipients && recipients != null && recipients.length > 0) {
int maxRecipients = (compact ? MAX_RECIPIENTS_COMPACT : MAX_RECIPIENTS_NORMAL);
tvFrom.setText(context.getString(outgoing && viewType != ViewType.THREAD && compact
? R.string.title_to_from
: R.string.title_from_to,
MessageHelper.formatAddresses(senders, format, false),
MessageHelper.formatAddresses(recipients, format, false)));
formatAddresses(senders, format, maxRecipients),
formatAddresses(recipients, format, maxRecipients)));
} else
tvFrom.setText(MessageHelper.formatAddresses(senders, format, false));
@ -2195,6 +2196,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}.setLog(false).execute(context, owner, sargs, "message:tools");
}
private String formatAddresses(Address[] addresses, MessageHelper.AddressFormat format, int max) {
List<Address> list = new ArrayList<>();
if (addresses != null)
for (Address address : addresses)
if (!list.contains(address))
list.add(address);
Address[] sub = list.subList(0, Math.min(list.size(), max)).toArray(new Address[0]);
String result = MessageHelper.formatAddresses(sub, format, false);
if (list.size() > sub.length)
result = context.getString(R.string.title_name_plus, result, list.size() - sub.length);
return result;
}
private Spanned formatAddresses(Address[] addresses, boolean full) {
return formatAddresses(addresses, full, Integer.MAX_VALUE);
}

Loading…
Cancel
Save