Special extra

pull/212/head
M66B 2 years ago
parent 06f9e5c437
commit bc197f4cf4

@ -7981,8 +7981,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (email == null)
return;
email = MessageHelper.addExtra(email, extra);
((InternetAddress) addresses[0]).setAddress(email);
Pair<String, String> p = MessageHelper.getExtra(email, extra);
if (p.first != null)
try {
((InternetAddress) addresses[0]).setPersonal(p.first);
} catch (Throwable ex) {
Log.e(ex);
}
if (p.second != null)
((InternetAddress) addresses[0]).setAddress(p.second);
}
PagedList<TupleMessageEx> getCurrentList() {

@ -32,6 +32,7 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Base64;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.core.net.MailTo;
@ -773,11 +774,16 @@ public class MessageHelper {
email != null && message.extra != null) {
String username = UriHelper.getEmailUser(identity.email);
if (!message.extra.equals(username)) {
email = addExtra(email, message.extra);
Pair<String, String> extra = getExtra(email, message.extra);
if (!identity.sender_extra_name)
if (extra.first != null)
name = extra.first;
else if (!identity.sender_extra_name)
name = null;
if (extra.second != null)
email = extra.second;
Log.i("extra=\"" + name + "\" <" + email + ">");
}
}
@ -788,10 +794,19 @@ public class MessageHelper {
return new InternetAddress(email, name, StandardCharsets.UTF_8.name());
}
static String addExtra(String email, String extra) {
static Pair<String, String> getExtra(String email, String extra) {
String name = null;
int comma = extra.indexOf(',');
if (comma >= 0) {
name = extra.substring(0, comma).trim();
extra = extra.substring(comma + 1).trim();
if (TextUtils.isEmpty(extra))
return new Pair<>(name, null);
}
int at = email.indexOf('@');
if (at < 0)
return email;
return new Pair<>(name, email);
if (extra.length() > 1 && extra.startsWith("+"))
email = email.substring(0, at) + extra + email.substring(at);
@ -800,7 +815,7 @@ public class MessageHelper {
else
email = extra + email.substring(at);
return email;
return new Pair<>(name, email);
}
private static void addAddress(String email, Message.RecipientType type, MimeMessage imessage, EntityIdentity identity) throws MessagingException {

Loading…
Cancel
Save