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);
// 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);
tvSize.setText(size == null ? null : Helper.humanReadableByteCount(size, true));
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
boolean outgoing = (viewType != ViewType.THREAD && EntityFolder.isOutgoing(message.folderType));
Address[] addresses = (outgoing ? message.to : message.from);
ContactInfo info = ContactInfo.get(context, addresses, true);
if (info == null) {
Bundle aargs = new Bundle();
@ -753,9 +754,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<ContactInfo>() {
@Override
protected void onPreExecute(Bundle args) {
Address[] addresses = (Address[]) args.getSerializable("addresses");
//Address[] addresses = (Address[]) args.getSerializable("addresses");
ivAvatar.setVisibility(View.GONE);
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
//tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
}
@Override
@ -883,7 +884,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivAvatar.setVisibility(View.VISIBLE);
} else
ivAvatar.setVisibility(View.GONE);
tvFrom.setText(info.getDisplayName(name_email));
//tvFrom.setText(info.getDisplayName(name_email));
}
private void bindExpanded(final TupleMessageEx message) {
@ -940,7 +941,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Addresses
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 replyto = MessageHelper.formatAddresses(message.reply);
String cc = MessageHelper.formatAddresses(message.cc);

View File

@ -1063,7 +1063,16 @@ public abstract class DB extends RoomDatabase {
return null;
List<Address> result = new ArrayList<>();
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++) {
JSONObject jaddress = (JSONObject) jaddresses.get(i);
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" +
", 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" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", COUNT(message.id) AS count" +
", SUM(1 - message.ui_seen) AS unseen" +
", 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 folder.type = :type))" +
" 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" +
" LEFT JOIN identity ON identity.id = message.identity" +
" 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" +
", 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" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", COUNT(message.id) AS count" +
", SUM(1 - message.ui_seen) AS unseen" +
", 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" +
", SUM(message.size) AS totalSize" +
", 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" +
" LEFT JOIN identity ON identity.id = message.identity" +
" 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" +
", 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" +
", message.`from` AS senders" +
", 1 AS count" +
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", 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" +
", 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" +
", message.`from` AS senders" +
", 1 AS count" +
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", 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" +
", 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" +
", message.`from` AS senders" +
", 1 AS count" +
", 1 AS unseen" +
", 0 AS unflagged" +

View File

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

View File

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