From 167a691018a88db2d28e454cc52b3d6d99f4e7bc Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 19 Jul 2021 09:05:04 -0300 Subject: [PATCH] Update SMS tag visibility in onRecipientChanged. --- .../contacts/ContactSelectionListItem.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/contacts/ContactSelectionListItem.java b/app/src/main/java/org/thoughtcrime/securesms/contacts/ContactSelectionListItem.java index 865f7ed08..c62971f0b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/contacts/ContactSelectionListItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/contacts/ContactSelectionListItem.java @@ -90,17 +90,22 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF } else if (recipientId != null) { this.recipient = Recipient.live(recipientId); this.recipient.observeForever(this); - name = this.recipient.get().getDisplayName(getContext()); } - if (recipient == null || recipient.get().isRegistered()) { + Recipient recipientSnapshot = recipient != null ? recipient.get() : null; + + if (recipientSnapshot != null && !recipientSnapshot.isResolving()) { + name = recipientSnapshot.getDisplayName(getContext()); + } else { + name = ""; + } + + if (recipientSnapshot == null || recipientSnapshot.isResolving() || recipientSnapshot.isRegistered()) { smsTag.setVisibility(GONE); } else { smsTag.setVisibility(VISIBLE); } - Recipient recipientSnapshot = recipient != null ? recipient.get() : null; - if (recipientSnapshot == null || recipientSnapshot.isResolving()) { this.contactPhotoImage.setAvatar(glideRequests, null, false); setText(null, type, name, number, label, about); @@ -209,6 +214,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF if (this.recipient != null && this.recipient.getId().equals(recipient.getId())) { contactPhotoImage.setAvatar(glideRequests, recipient, false); setText(recipient, contactType, contactName, contactNumber, contactLabel, contactAbout); + smsTag.setVisibility(recipient.isRegistered() ? GONE : VISIBLE); } else { Log.w(TAG, "Bad change! Local recipient doesn't match. Ignoring. Local: " + (this.recipient == null ? "null" : this.recipient.getId()) + ", Changed: " + recipient.getId()); }