mirror of https://github.com/M66B/FairEmail.git
Fixed contact photos / identicons for outgoing messages
This commit is contained in:
parent
54cd2db2fe
commit
c4b1800111
|
@ -291,6 +291,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
final boolean show_expanded = properties.isExpanded(message.id);
|
||||
boolean show_addresses = properties.showAddresses(message.id);
|
||||
boolean show_headers = properties.showHeaders(message.id);
|
||||
boolean outgoing = EntityFolder.DRAFTS.equals(message.folderType) ||
|
||||
EntityFolder.OUTBOX.equals(message.folderType) ||
|
||||
EntityFolder.SENT.equals(message.folderType);
|
||||
|
||||
pbLoading.setVisibility(View.GONE);
|
||||
|
||||
|
@ -309,11 +312,12 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
}
|
||||
}
|
||||
if (!photo && identicons) {
|
||||
if (message.from != null && message.from.length > 0)
|
||||
ivAvatar.setImageBitmap(Identicon.generate(message.from[0].toString(), dp24, 5, "light".equals(theme)));
|
||||
else
|
||||
Address[] addresses = (outgoing ? message.to : message.from);
|
||||
if (addresses != null && addresses.length > 0) {
|
||||
ivAvatar.setImageBitmap(Identicon.generate(addresses[0].toString(), dp24, 5, "light".equals(theme)));
|
||||
photo = true;
|
||||
} else
|
||||
ivAvatar.setImageDrawable(null);
|
||||
photo = true;
|
||||
}
|
||||
ivAvatar.setVisibility(photo ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
@ -328,9 +332,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
else
|
||||
ivFlagged.setVisibility(message.count - message.unflagged > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (EntityFolder.DRAFTS.equals(message.folderType) ||
|
||||
EntityFolder.OUTBOX.equals(message.folderType) ||
|
||||
EntityFolder.SENT.equals(message.folderType)) {
|
||||
if (outgoing) {
|
||||
tvFrom.setText(MessageHelper.getFormattedAddresses(message.to, !compact));
|
||||
tvTime.setText(DateUtils.getRelativeTimeSpanString(context, message.sent == null ? message.received : message.sent));
|
||||
} else {
|
||||
|
|
|
@ -1848,9 +1848,14 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
try {
|
||||
if (message.from != null)
|
||||
for (int i = 0; i < message.from.length; i++) {
|
||||
String email = ((InternetAddress) message.from[i]).getAddress();
|
||||
boolean outgoing = EntityFolder.DRAFTS.equals(folder.type) ||
|
||||
EntityFolder.OUTBOX.equals(folder.type) ||
|
||||
EntityFolder.SENT.equals(folder.type);
|
||||
Address[] addresses = (outgoing ? message.to : message.from);
|
||||
|
||||
if (addresses != null)
|
||||
for (int i = 0; i < addresses.length; i++) {
|
||||
String email = ((InternetAddress) addresses[i]).getAddress();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
|
@ -1874,7 +1879,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
message.avatar = ContactsContract.Contacts.getLookupUri(contactId, lookupKey).toString();
|
||||
|
||||
if (!TextUtils.isEmpty(displayName))
|
||||
((InternetAddress) message.from[i]).setPersonal(displayName);
|
||||
((InternetAddress) addresses[i]).setPersonal(displayName);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
|
|
Loading…
Reference in New Issue