(Address[] addresses, boolean prefer_contact, boolean only_contact)
| 1114 | } |
| 1115 | |
| 1116 | static Address[] fillIn(Address[] addresses, boolean prefer_contact, boolean only_contact) { |
| 1117 | if (addresses == null) |
| 1118 | return null; |
| 1119 | |
| 1120 | Address[] modified = new Address[addresses.length]; |
| 1121 | for (int i = 0; i < addresses.length; i++) { |
| 1122 | InternetAddress address = (InternetAddress) addresses[i]; |
| 1123 | String email = address.getAddress(); |
| 1124 | String personal = (only_contact ? null : address.getPersonal()); |
| 1125 | if (!TextUtils.isEmpty(email)) { |
| 1126 | Lookup lookup = emailLookup.get(email.toLowerCase(Locale.ROOT)); |
| 1127 | if (lookup != null && |
| 1128 | (TextUtils.isEmpty(personal) || prefer_contact)) |
| 1129 | personal = lookup.displayName; |
| 1130 | } |
| 1131 | try { |
| 1132 | modified[i] = new InternetAddress(email, personal, StandardCharsets.UTF_8.name()); |
| 1133 | } catch (UnsupportedEncodingException ex) { |
| 1134 | Log.e(ex); |
| 1135 | modified[i] = address; |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | return modified; |
| 1140 | } |
| 1141 | |
| 1142 | private static Map<String, Lookup> getEmailLookup(Context context) { |
| 1143 | Map<String, Lookup> all = new ConcurrentHashMap<>(); |
no test coverage detected