From ab0d5d9b140b629a8b0226f2c8eb42a436eaa6d1 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 25 Jan 2023 19:44:47 +0100 Subject: [PATCH] Extra special --- .../eu/faircode/email/FragmentCompose.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index a43cc5a003..40d304778f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4933,11 +4933,11 @@ public class FragmentCompose extends FragmentBase { data.draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply); } - Address preferred = null; if (ref.identity != null) { EntityIdentity recognized = db.identity().getIdentity(ref.identity); EntityLog.log(context, "Recognized=" + (recognized == null ? null : recognized.email)); + Address preferred = null; if (recognized != null) { Address same = null; Address similar = null; @@ -4975,15 +4975,23 @@ public class FragmentCompose extends FragmentBase { preferred = (same == null ? similar : same); } - } else - EntityLog.log(context, "Recognized=null"); - if (preferred != null) { - String from = ((InternetAddress) preferred).getAddress(); - EntityLog.log(context, "Preferred=" + from); - data.draft.extra = UriHelper.getEmailUser(from); + if (preferred != null) { + String from = ((InternetAddress) preferred).getAddress(); + String name = ((InternetAddress) preferred).getPersonal(); + EntityLog.log(context, "Preferred=" + name + " <" + from + ">"); + if (TextUtils.isEmpty(from) || from.equals(recognized.email)) + from = null; + if (TextUtils.isEmpty(name) || name.equals(recognized.name)) + name = null; + String username = UriHelper.getEmailUser(from); + String extra = (name == null ? "" : name + ", ") + + (username == null ? "" : username); + data.draft.extra = (TextUtils.isEmpty(extra) ? null : extra); + } else + EntityLog.log(context, "Preferred=null"); } else - EntityLog.log(context, "Preferred=null"); + EntityLog.log(context, "Recognized=null"); } if ("reply_all".equals(action))