Show all sender addresses

This commit is contained in:
M66B 2019-08-04 13:43:37 +02:00
parent f60d15a02b
commit 12f05b9edd
5 changed files with 46 additions and 18 deletions

View File

@ -648,6 +648,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivExpander.setVisibility(View.GONE); ivExpander.setVisibility(View.GONE);
// Line 1 // Line 1
boolean outgoing = (viewType != ViewType.THREAD && EntityFolder.isOutgoing(message.folderType));
Address[] addresses = (outgoing ? message.to : message.senders);
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
Long size = ("size".equals(sort) ? message.totalSize : message.size); Long size = ("size".equals(sort) ? message.totalSize : message.size);
tvSize.setText(size == null ? null : Helper.humanReadableByteCount(size, true)); tvSize.setText(size == null ? null : Helper.humanReadableByteCount(size, true));
tvSize.setVisibility(size == null || (message.content && !"size".equals(sort)) ? View.GONE : View.VISIBLE); tvSize.setVisibility(size == null || (message.content && !"size".equals(sort)) ? View.GONE : View.VISIBLE);
@ -742,8 +745,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
// Contact info // Contact info
boolean outgoing = (viewType != ViewType.THREAD && EntityFolder.isOutgoing(message.folderType));
Address[] addresses = (outgoing ? message.to : message.from);
ContactInfo info = ContactInfo.get(context, addresses, true); ContactInfo info = ContactInfo.get(context, addresses, true);
if (info == null) { if (info == null) {
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
@ -753,9 +754,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<ContactInfo>() { new SimpleTask<ContactInfo>() {
@Override @Override
protected void onPreExecute(Bundle args) { protected void onPreExecute(Bundle args) {
Address[] addresses = (Address[]) args.getSerializable("addresses"); //Address[] addresses = (Address[]) args.getSerializable("addresses");
ivAvatar.setVisibility(View.GONE); ivAvatar.setVisibility(View.GONE);
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false)); //tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
} }
@Override @Override
@ -883,7 +884,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivAvatar.setVisibility(View.VISIBLE); ivAvatar.setVisibility(View.VISIBLE);
} else } else
ivAvatar.setVisibility(View.GONE); ivAvatar.setVisibility(View.GONE);
tvFrom.setText(info.getDisplayName(name_email)); //tvFrom.setText(info.getDisplayName(name_email));
} }
private void bindExpanded(final TupleMessageEx message) { private void bindExpanded(final TupleMessageEx message) {
@ -940,7 +941,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Addresses // Addresses
ivExpanderAddress.setImageLevel(show_addresses ? 0 /* less */ : 1 /* more */); ivExpanderAddress.setImageLevel(show_addresses ? 0 /* less */ : 1 /* more */);
String from = MessageHelper.formatAddresses(message.from); String from = MessageHelper.formatAddresses(message.senders);
String to = MessageHelper.formatAddresses(message.to); String to = MessageHelper.formatAddresses(message.to);
String replyto = MessageHelper.formatAddresses(message.reply); String replyto = MessageHelper.formatAddresses(message.reply);
String cc = MessageHelper.formatAddresses(message.cc); String cc = MessageHelper.formatAddresses(message.cc);

View File

@ -1063,7 +1063,16 @@ public abstract class DB extends RoomDatabase {
return null; return null;
List<Address> result = new ArrayList<>(); List<Address> result = new ArrayList<>();
try { try {
JSONArray jaddresses = new JSONArray(json); JSONArray jroot = new JSONArray(json);
JSONArray jaddresses = new JSONArray();
for (int i = 0; i < jroot.length(); i++) {
Object item = jroot.get(i);
if (jroot.get(i) instanceof JSONArray)
for (int j = 0; j < ((JSONArray) item).length(); j++)
jaddresses.put(((JSONArray) item).get(j));
else
jaddresses.put(item);
}
for (int i = 0; i < jaddresses.length(); i++) { for (int i = 0; i < jaddresses.length(); i++) {
JSONObject jaddress = (JSONObject) jaddresses.get(i); JSONObject jaddress = (JSONObject) jaddresses.get(i);
if (jaddress.has("personal")) if (jaddress.has("personal"))

View File

@ -42,6 +42,7 @@ public interface DaoMessage {
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", COUNT(message.id) AS count" + ", COUNT(message.id) AS count" +
", SUM(1 - message.ui_seen) AS unseen" + ", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" + ", SUM(1 - message.ui_flagged) AS unflagged" +
@ -53,7 +54,7 @@ public interface DaoMessage {
" OR (NOT :found AND :type IS NULL AND folder.unified)" + " OR (NOT :found AND :type IS NULL AND folder.unified)" +
" OR (NOT :found AND folder.type = :type))" + " OR (NOT :found AND folder.type = :type))" +
" THEN message.received ELSE 0 END) AS dummy" + " THEN message.received ELSE 0 END) AS dummy" +
" FROM message" + " FROM (SELECT * FROM message ORDER BY received DESC) AS message" +
" JOIN account ON account.id = message.account" + " JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" + " LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
@ -91,6 +92,7 @@ public interface DaoMessage {
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", COUNT(message.id) AS count" + ", COUNT(message.id) AS count" +
", SUM(1 - message.ui_seen) AS unseen" + ", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" + ", SUM(1 - message.ui_flagged) AS unflagged" +
@ -98,7 +100,7 @@ public interface DaoMessage {
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" + ", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
", SUM(message.size) AS totalSize" + ", SUM(message.size) AS totalSize" +
", MAX(CASE WHEN folder.id = :folder THEN message.received ELSE 0 END) AS dummy" + ", MAX(CASE WHEN folder.id = :folder THEN message.received ELSE 0 END) AS dummy" +
" FROM message" + " FROM (SELECT * FROM message ORDER BY received DESC) AS message" +
" JOIN account ON account.id = message.account" + " JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" + " LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
@ -132,6 +134,7 @@ public interface DaoMessage {
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", 1 AS count" + ", 1 AS count" +
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" + ", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" + ", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" +
@ -230,6 +233,7 @@ public interface DaoMessage {
", account.name AS accountName, identity.color AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, identity.color AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", 1 AS count" + ", 1 AS count" +
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" + ", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" + ", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" +
@ -247,6 +251,7 @@ public interface DaoMessage {
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", 1 AS count" + ", 1 AS count" +
", 1 AS unseen" + ", 1 AS unseen" +
", 0 AS unflagged" + ", 0 AS unflagged" +

View File

@ -599,17 +599,26 @@ public class MessageHelper {
return ""; return "";
List<String> formatted = new ArrayList<>(); List<String> formatted = new ArrayList<>();
for (Address address : addresses) for (int i = 0; i < addresses.length; i++) {
if (address instanceof InternetAddress) { boolean duplicate = false;
InternetAddress a = (InternetAddress) address; for (int j = 0; j < i; j++)
String personal = a.getPersonal(); if (addresses[i].equals(addresses[j])) {
duplicate = true;
break;
}
if (duplicate)
continue;
if (addresses[i] instanceof InternetAddress) {
InternetAddress address = (InternetAddress) addresses[i];
String personal = address.getPersonal();
if (TextUtils.isEmpty(personal)) if (TextUtils.isEmpty(personal))
formatted.add(a.getAddress()); formatted.add(address.getAddress());
else { else {
if (compose) { if (compose) {
boolean quote = false; boolean quote = false;
for (int i = 0; i < personal.length(); i++) for (int c = 0; c < personal.length(); c++)
if ("()<>,;:\\\"[]@".indexOf(personal.charAt(i)) >= 0) { if ("()<>,;:\\\"[]@".indexOf(personal.charAt(c)) >= 0) {
quote = true; quote = true;
break; break;
} }
@ -618,12 +627,13 @@ public class MessageHelper {
} }
if (full) if (full)
formatted.add(personal + " <" + a.getAddress() + ">"); formatted.add(personal + " <" + address.getAddress() + ">");
else else
formatted.add(personal); formatted.add(personal);
} }
} else } else
formatted.add(address.toString()); formatted.add(addresses[i].toString());
}
return TextUtils.join(", ", formatted); return TextUtils.join(", ", formatted);
} }

View File

@ -23,6 +23,8 @@ import androidx.room.Ignore;
import java.util.Objects; import java.util.Objects;
import javax.mail.Address;
public class TupleMessageEx extends EntityMessage { public class TupleMessageEx extends EntityMessage {
public String accountName; public String accountName;
public Integer accountColor; public Integer accountColor;
@ -34,6 +36,7 @@ public class TupleMessageEx extends EntityMessage {
public String identityName; public String identityName;
public String identityEmail; public String identityEmail;
public Boolean identitySynchronize; public Boolean identitySynchronize;
public Address[] senders;
public int count; public int count;
public int unseen; public int unseen;
public int unflagged; public int unflagged;