From dd01b2968fa862d0a1eefd945c4ba0bc1a660493 Mon Sep 17 00:00:00 2001 From: jubb Date: Mon, 2 Aug 2021 16:59:55 +1000 Subject: [PATCH 1/3] fix: startup performance fixes --- app/build.gradle | 2 +- .../v2/utilities/MentionManagerUtilities.kt | 4 +- .../securesms/home/ConversationView.kt | 105 ++++++++++-------- .../securesms/home/HomeActivity.kt | 3 +- 4 files changed, 62 insertions(+), 52 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 562cbe713c..0d7e670c79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -142,7 +142,7 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.2' } -def canonicalVersionCode = 211 +def canonicalVersionCode = 214 def canonicalVersionName = "1.11.7" def postFixSize = 10 diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt index 31d650a671..4beb5e6d47 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt @@ -9,13 +9,15 @@ import org.thoughtcrime.securesms.database.model.MessageRecord object MentionManagerUtilities { fun populateUserPublicKeyCacheIfNeeded(threadID: Long, context: Context) { + // exit early if we need to + if (MentionsManager.userPublicKeyCache[threadID] != null) return + val result = mutableSetOf() val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID) if (recipient != null && recipient.address.isClosedGroup) { val members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(recipient.address.toGroupString(), false).map { it.address.serialize() } result.addAll(members) } else { - if (MentionsManager.userPublicKeyCache[threadID] != null) { return } val messageDatabase = DatabaseFactory.getMmsSmsDatabase(context) val reader = messageDatabase.readerFor(messageDatabase.getConversation(threadID)) var record: MessageRecord? = reader.next diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt index 9454070e77..4a34b15ff2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt @@ -12,6 +12,8 @@ import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.view_conversation.view.* +import kotlinx.android.synthetic.main.view_profile_picture.view.* +import kotlinx.coroutines.* import network.loki.messenger.R import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded @@ -40,56 +42,63 @@ class ConversationView : LinearLayout { // region Updating fun bind(thread: ThreadRecord, isTyping: Boolean, glide: GlideRequests) { this.thread = thread - populateUserPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a bad place to do this - val unreadCount = thread.unreadCount - if (thread.recipient.isBlocked) { - accentView.setBackgroundResource(R.color.destructive) - accentView.visibility = View.VISIBLE - } else { - accentView.setBackgroundResource(R.color.accent) - accentView.visibility = if (unreadCount > 0) View.VISIBLE else View.INVISIBLE - } - val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+" - unreadCountTextView.text = formattedUnreadCount - val textSize = if (unreadCount < 100) 12.0f else 9.0f - unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize) - unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL) - unreadCountIndicator.isVisible = (unreadCount != 0) profilePictureView.glide = glide - profilePictureView.update(thread.recipient, thread.threadId) - val senderDisplayName = getUserDisplayName(thread.recipient) ?: thread.recipient.address.toString() - conversationViewDisplayNameTextView.text = senderDisplayName - timestampTextView.text = DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), thread.date) - val recipient = thread.recipient - muteIndicatorImageView.isVisible = recipient.isMuted || recipient.notifyType != RecipientDatabase.NOTIFY_TYPE_ALL - val drawableRes = if (recipient.isMuted || recipient.notifyType == RecipientDatabase.NOTIFY_TYPE_NONE) { - R.drawable.ic_outline_notifications_off_24 - } else { - R.drawable.ic_notifications_mentions - } - muteIndicatorImageView.setImageResource(drawableRes) - val rawSnippet = thread.getDisplayBody(context) - val snippet = highlightMentions(rawSnippet, thread.threadId, context) - snippetTextView.text = snippet - snippetTextView.typeface = if (unreadCount > 0) Typeface.DEFAULT_BOLD else Typeface.DEFAULT - snippetTextView.visibility = if (isTyping) View.GONE else View.VISIBLE - if (isTyping) { - typingIndicatorView.startAnimation() - } else { - typingIndicatorView.stopAnimation() - } - typingIndicatorView.visibility = if (isTyping) View.VISIBLE else View.GONE - statusIndicatorImageView.visibility = View.VISIBLE - when { - !thread.isOutgoing -> statusIndicatorImageView.visibility = View.GONE - thread.isFailed -> { - val drawable = ContextCompat.getDrawable(context, R.drawable.ic_error)?.mutate() - drawable?.setTint(ContextCompat.getColor(context,R.color.destructive)) - statusIndicatorImageView.setImageDrawable(drawable) + post { + val unreadCount = thread.unreadCount + if (thread.recipient.isBlocked) { + accentView.setBackgroundResource(R.color.destructive) + accentView.visibility = View.VISIBLE + } else { + accentView.setBackgroundResource(R.color.accent) + accentView.visibility = if (unreadCount > 0) View.VISIBLE else View.INVISIBLE + } + val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+" + unreadCountTextView.text = formattedUnreadCount + val textSize = if (unreadCount < 100) 12.0f else 9.0f + unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize) + unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL) + unreadCountIndicator.isVisible = (unreadCount != 0) + val senderDisplayName = getUserDisplayName(thread.recipient) + ?: thread.recipient.address.toString() + conversationViewDisplayNameTextView.text = senderDisplayName + timestampTextView.text = DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), thread.date) + val recipient = thread.recipient + muteIndicatorImageView.isVisible = recipient.isMuted || recipient.notifyType != RecipientDatabase.NOTIFY_TYPE_ALL + val drawableRes = if (recipient.isMuted || recipient.notifyType == RecipientDatabase.NOTIFY_TYPE_NONE) { + R.drawable.ic_outline_notifications_off_24 + } else { + R.drawable.ic_notifications_mentions + } + muteIndicatorImageView.setImageResource(drawableRes) + val rawSnippet = thread.getDisplayBody(context) + val snippet = highlightMentions(rawSnippet, thread.threadId, context) + snippetTextView.text = snippet + snippetTextView.typeface = if (unreadCount > 0) Typeface.DEFAULT_BOLD else Typeface.DEFAULT + snippetTextView.visibility = if (isTyping) View.GONE else View.VISIBLE + if (isTyping) { + typingIndicatorView.startAnimation() + } else { + typingIndicatorView.stopAnimation() + } + typingIndicatorView.visibility = if (isTyping) View.VISIBLE else View.GONE + statusIndicatorImageView.visibility = View.VISIBLE + when { + !thread.isOutgoing -> statusIndicatorImageView.visibility = View.GONE + thread.isFailed -> { + val drawable = ContextCompat.getDrawable(context, R.drawable.ic_error)?.mutate() + drawable?.setTint(ContextCompat.getColor(context, R.color.destructive)) + statusIndicatorImageView.setImageDrawable(drawable) + } + thread.isPending -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_dot_dot_dot) + thread.isRead -> statusIndicatorImageView.setImageResource(R.drawable.ic_filled_circle_check) + else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check) + } + GlobalScope.launch(Dispatchers.IO) { + populateUserPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a bad place to do this + withContext(Dispatchers.Main) { + profilePictureView.update(thread.recipient, thread.threadId) + } } - thread.isPending -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_dot_dot_dot) - thread.isRead -> statusIndicatorImageView.setImageResource(R.drawable.ic_filled_circle_check) - else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index 4a59fcdba8..d8bc59d7da 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -80,8 +80,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis // Set up seed reminder view val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this) if (!hasViewedSeed) { - seedReminderStub.isVisible = true - seedReminderStub.apply { + seedReminderStub.inflate().apply { val seedReminderView = this.seedReminderView val seedReminderViewTitle = SpannableString("You're almost finished! 80%") // Intentionally not yet translated seedReminderViewTitle.setSpan(ForegroundColorSpan(resources.getColorWithID(R.color.accent, theme)), 24, 27, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) From 9b48d5d20315911d25067520e2d50b68c02405cb Mon Sep 17 00:00:00 2001 From: jubb Date: Tue, 3 Aug 2021 13:35:38 +1000 Subject: [PATCH 2/3] refactor: use simpler way to generate closed group profile pictures, limit the getConversation call in MentionManagerUtilities.kt to 200 to improve link-through performance to v2 conversation activity. fix notify type not being preloaded into settings --- app/build.gradle | 2 +- .../components/ProfilePictureView.kt | 16 ++- .../v2/utilities/MentionManagerUtilities.kt | 6 +- .../securesms/database/GroupDatabase.java | 15 +++ .../securesms/database/ThreadDatabase.java | 2 +- .../securesms/home/ConversationView.kt | 110 ++++++++---------- .../utilities/recipients/Recipient.java | 2 + 7 files changed, 80 insertions(+), 73 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0d7e670c79..1bbe66bea0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -142,7 +142,7 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.2' } -def canonicalVersionCode = 214 +def canonicalVersionCode = 215 def canonicalVersionName = "1.11.7" def postFixSize = 10 diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt index 6ae90d4270..eff857f699 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt @@ -53,17 +53,15 @@ class ProfilePictureView : RelativeLayout { return recipient.isOpenGroupRecipient && recipient.groupAvatarId != null } if (recipient.isGroupRecipient && !isOpenGroupWithProfilePicture(recipient)) { - val users = MentionsManager.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf() - users.remove(TextSecurePreferences.getLocalNumber(context)) - val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability - if (users.count() == 1) { - val userPublicKey = TextSecurePreferences.getLocalNumber(context)!! - randomUsers.add(0, userPublicKey) // Ensure the current user is at the back visually - } - val pk = randomUsers.getOrNull(0) ?: "" + val members = DatabaseFactory.getGroupDatabase(context) + .getGroupMemberAddresses(recipient.address.toGroupString(), true) + .sorted() + .take(2) + .toMutableList() + val pk = members.getOrNull(0)?.serialize() ?: "" publicKey = pk displayName = getUserDisplayName(pk) - val apk = randomUsers.getOrNull(1) ?: "" + val apk = members.getOrNull(1)?.serialize() ?: "" additionalPublicKey = apk additionalDisplayName = getUserDisplayName(apk) } else { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt index 4beb5e6d47..ca1aeeed2b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionManagerUtilities.kt @@ -13,13 +13,13 @@ object MentionManagerUtilities { if (MentionsManager.userPublicKeyCache[threadID] != null) return val result = mutableSetOf() - val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID) - if (recipient != null && recipient.address.isClosedGroup) { + val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID) ?: return + if (recipient.address.isClosedGroup) { val members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(recipient.address.toGroupString(), false).map { it.address.serialize() } result.addAll(members) } else { val messageDatabase = DatabaseFactory.getMmsSmsDatabase(context) - val reader = messageDatabase.readerFor(messageDatabase.getConversation(threadID)) + val reader = messageDatabase.readerFor(messageDatabase.getConversation(threadID, 0, 200)) var record: MessageRecord? = reader.next while (record != null) { result.add(record.individualRecipient.address.serialize()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/GroupDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/GroupDatabase.java index 340506ac30..78cc9b405d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/GroupDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/GroupDatabase.java @@ -14,6 +14,7 @@ import com.annimon.stream.Stream; import net.sqlcipher.database.SQLiteDatabase; +import org.session.libsession.utilities.TextSecurePreferences; import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; import org.thoughtcrime.securesms.util.BitmapUtil; @@ -155,6 +156,20 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt return recipients; } + public @NonNull List
getGroupMemberAddresses(String groupId, boolean includeSelf) { + List
members = getCurrentMembers(groupId, false); + if (!includeSelf) { + String ownNumber = TextSecurePreferences.getLocalNumber(context); + if (ownNumber == null) return members; + Address ownAddress = Address.fromSerialized(ownNumber); + int indexOfSelf = members.indexOf(ownAddress); + if (indexOfSelf >= 0) { + members.remove(indexOfSelf); + } + } + return members; + } + public @NonNull List getGroupZombieMembers(String groupId) { List
members = getCurrentZombieMembers(groupId); List recipients = new LinkedList<>(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java index 9852fdd2e7..c9fa010e8b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -651,7 +651,7 @@ public class ThreadDatabase extends Database { groupRecord = Optional.absent(); } - Recipient recipient = Recipient.from(context, address, settings, groupRecord, false); + Recipient recipient = Recipient.from(context, address, settings, groupRecord, true); String body = cursor.getString(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET)); long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE)); long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT)); diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt index 4a34b15ff2..b72b4fb79e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt @@ -12,11 +12,8 @@ import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.view_conversation.view.* -import kotlinx.android.synthetic.main.view_profile_picture.view.* -import kotlinx.coroutines.* import network.loki.messenger.R import org.session.libsession.utilities.recipients.Recipient -import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities.highlightMentions import org.thoughtcrime.securesms.database.RecipientDatabase import org.thoughtcrime.securesms.database.model.ThreadRecord @@ -42,63 +39,58 @@ class ConversationView : LinearLayout { // region Updating fun bind(thread: ThreadRecord, isTyping: Boolean, glide: GlideRequests) { this.thread = thread - profilePictureView.glide = glide + val unreadCount = thread.unreadCount + if (thread.recipient.isBlocked) { + accentView.setBackgroundResource(R.color.destructive) + accentView.visibility = View.VISIBLE + } else { + accentView.setBackgroundResource(R.color.accent) + accentView.visibility = if (unreadCount > 0) View.VISIBLE else View.INVISIBLE + } + val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+" + unreadCountTextView.text = formattedUnreadCount + val textSize = if (unreadCount < 100) 12.0f else 9.0f + unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize) + unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL) + unreadCountIndicator.isVisible = (unreadCount != 0) + val senderDisplayName = getUserDisplayName(thread.recipient) + ?: thread.recipient.address.toString() + conversationViewDisplayNameTextView.text = senderDisplayName + timestampTextView.text = DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), thread.date) + val recipient = thread.recipient + muteIndicatorImageView.isVisible = recipient.isMuted || recipient.notifyType != RecipientDatabase.NOTIFY_TYPE_ALL + val drawableRes = if (recipient.isMuted || recipient.notifyType == RecipientDatabase.NOTIFY_TYPE_NONE) { + R.drawable.ic_outline_notifications_off_24 + } else { + R.drawable.ic_notifications_mentions + } + muteIndicatorImageView.setImageResource(drawableRes) + val rawSnippet = thread.getDisplayBody(context) + val snippet = highlightMentions(rawSnippet, thread.threadId, context) + snippetTextView.text = snippet + snippetTextView.typeface = if (unreadCount > 0) Typeface.DEFAULT_BOLD else Typeface.DEFAULT + snippetTextView.visibility = if (isTyping) View.GONE else View.VISIBLE + if (isTyping) { + typingIndicatorView.startAnimation() + } else { + typingIndicatorView.stopAnimation() + } + typingIndicatorView.visibility = if (isTyping) View.VISIBLE else View.GONE + statusIndicatorImageView.visibility = View.VISIBLE + when { + !thread.isOutgoing -> statusIndicatorImageView.visibility = View.GONE + thread.isFailed -> { + val drawable = ContextCompat.getDrawable(context, R.drawable.ic_error)?.mutate() + drawable?.setTint(ContextCompat.getColor(context, R.color.destructive)) + statusIndicatorImageView.setImageDrawable(drawable) + } + thread.isPending -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_dot_dot_dot) + thread.isRead -> statusIndicatorImageView.setImageResource(R.drawable.ic_filled_circle_check) + else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check) + } post { - val unreadCount = thread.unreadCount - if (thread.recipient.isBlocked) { - accentView.setBackgroundResource(R.color.destructive) - accentView.visibility = View.VISIBLE - } else { - accentView.setBackgroundResource(R.color.accent) - accentView.visibility = if (unreadCount > 0) View.VISIBLE else View.INVISIBLE - } - val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+" - unreadCountTextView.text = formattedUnreadCount - val textSize = if (unreadCount < 100) 12.0f else 9.0f - unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize) - unreadCountTextView.setTypeface(Typeface.DEFAULT, if (unreadCount < 100) Typeface.BOLD else Typeface.NORMAL) - unreadCountIndicator.isVisible = (unreadCount != 0) - val senderDisplayName = getUserDisplayName(thread.recipient) - ?: thread.recipient.address.toString() - conversationViewDisplayNameTextView.text = senderDisplayName - timestampTextView.text = DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), thread.date) - val recipient = thread.recipient - muteIndicatorImageView.isVisible = recipient.isMuted || recipient.notifyType != RecipientDatabase.NOTIFY_TYPE_ALL - val drawableRes = if (recipient.isMuted || recipient.notifyType == RecipientDatabase.NOTIFY_TYPE_NONE) { - R.drawable.ic_outline_notifications_off_24 - } else { - R.drawable.ic_notifications_mentions - } - muteIndicatorImageView.setImageResource(drawableRes) - val rawSnippet = thread.getDisplayBody(context) - val snippet = highlightMentions(rawSnippet, thread.threadId, context) - snippetTextView.text = snippet - snippetTextView.typeface = if (unreadCount > 0) Typeface.DEFAULT_BOLD else Typeface.DEFAULT - snippetTextView.visibility = if (isTyping) View.GONE else View.VISIBLE - if (isTyping) { - typingIndicatorView.startAnimation() - } else { - typingIndicatorView.stopAnimation() - } - typingIndicatorView.visibility = if (isTyping) View.VISIBLE else View.GONE - statusIndicatorImageView.visibility = View.VISIBLE - when { - !thread.isOutgoing -> statusIndicatorImageView.visibility = View.GONE - thread.isFailed -> { - val drawable = ContextCompat.getDrawable(context, R.drawable.ic_error)?.mutate() - drawable?.setTint(ContextCompat.getColor(context, R.color.destructive)) - statusIndicatorImageView.setImageDrawable(drawable) - } - thread.isPending -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_dot_dot_dot) - thread.isRead -> statusIndicatorImageView.setImageResource(R.drawable.ic_filled_circle_check) - else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check) - } - GlobalScope.launch(Dispatchers.IO) { - populateUserPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a bad place to do this - withContext(Dispatchers.Main) { - profilePictureView.update(thread.recipient, thread.threadId) - } - } + profilePictureView.glide = glide + profilePictureView.update(thread.recipient, thread.threadId) } } diff --git a/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java b/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java index 5b31ded3c5..3018286423 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java +++ b/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java @@ -153,6 +153,7 @@ public class Recipient implements RecipientModifiedListener { this.profileSharing = stale.profileSharing; this.unidentifiedAccessMode = stale.unidentifiedAccessMode; this.forceSmsSelection = stale.forceSmsSelection; + this.notifyType = stale.notifyType; this.participants.clear(); this.participants.addAll(stale.participants); @@ -180,6 +181,7 @@ public class Recipient implements RecipientModifiedListener { this.profileSharing = details.get().profileSharing; this.unidentifiedAccessMode = details.get().unidentifiedAccessMode; this.forceSmsSelection = details.get().forceSmsSelection; + this.notifyType = details.get().notifyType; this.participants.clear(); this.participants.addAll(details.get().participants); From e064a6d7c33a09ca86cefda9d027dc83de4dfa9c Mon Sep 17 00:00:00 2001 From: jubb Date: Tue, 3 Aug 2021 13:42:15 +1000 Subject: [PATCH 3/3] refactor: move glide assignment into bind --- .../java/org/thoughtcrime/securesms/home/ConversationView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt index b72b4fb79e..28531ff4cc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt @@ -39,6 +39,7 @@ class ConversationView : LinearLayout { // region Updating fun bind(thread: ThreadRecord, isTyping: Boolean, glide: GlideRequests) { this.thread = thread + profilePictureView.glide = glide val unreadCount = thread.unreadCount if (thread.recipient.isBlocked) { accentView.setBackgroundResource(R.color.destructive) @@ -89,7 +90,6 @@ class ConversationView : LinearLayout { else -> statusIndicatorImageView.setImageResource(R.drawable.ic_circle_check) } post { - profilePictureView.glide = glide profilePictureView.update(thread.recipient, thread.threadId) } }