From f2882193d7c5b627ac93bf0578917f042dacac77 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 12 May 2024 08:56:59 +0200 Subject: [PATCH] Merge addresses --- .../eu/faircode/email/AdapterMessage.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 5cea72d844..8d2505dbb4 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -8784,20 +8784,8 @@ public class AdapterMessage extends RecyclerView.Adapter senders = new ArrayList<>(); - if (message.from != null) - senders.addAll(Arrays.asList(message.from)); - if (message.senders != null) - senders.addAll(Arrays.asList(message.senders)); - message.senders = senders.toArray(new Address[0]); - - List
recipients = new ArrayList<>(); - if (message.to != null) - recipients.addAll(Arrays.asList(message.to)); - if (message.recipients != null) - recipients.addAll(Arrays.asList(message.recipients)); - message.recipients = recipients.toArray(new Address[0]); - + message.senders = merge(message.from, message.senders); + message.recipients = merge(message.to, message.recipients); addExtra(message.senders, message.extra); } else { message.senders = message.from; @@ -8825,6 +8813,28 @@ public class AdapterMessage extends RecyclerView.Adapter result = new ArrayList<>(); + result.addAll(Arrays.asList(base)); + for (Address a : addresses) + for (Address b : base) { + if (a.equals(b)) { + if (a instanceof InternetAddress && b instanceof InternetAddress) { + if (Objects.equals(((InternetAddress) a).getPersonal(), ((InternetAddress) b).getPersonal())) + continue; + } else + continue; + } + result.add(a); + } + return result.toArray(new Address[0]); + } + static void addExtra(Address[] addresses, String extra) { if (addresses == null || addresses.length == 0) return;