From 84efcd2f21e0a2268303be212aeeb789dcf0bdd6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 26 Jun 2024 21:39:19 +0930 Subject: [PATCH] Remove ribbon image for note to self in search --- .../components/ProfilePictureView.kt | 21 ++++++++++++------- .../home/search/GlobalSearchAdapterUtils.kt | 7 ++----- .../ic_outline_bookmark_border_24.xml | 10 --------- .../res/layout/view_global_search_result.xml | 9 -------- 4 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_outline_bookmark_border_24.xml 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 019d5808a9..a6739e207e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt @@ -38,22 +38,27 @@ class ProfilePictureView @JvmOverloads constructor( private val unknownOpenGroupDrawable by lazy { ResourceContactPhoto(R.drawable.ic_notification) .asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context), false) } - // endregion - constructor(context: Context, sender: Recipient): this(context) { update(sender) } - // region Updating fun update(recipient: Recipient) { + recipient.run { update(address, isClosedGroupRecipient, isOpenGroupInboxRecipient) } + } + + fun update( + address: Address, + isClosedGroupRecipient: Boolean = false, + isOpenGroupInboxRecipient: Boolean = false + ) { fun getUserDisplayName(publicKey: String): String { val contact = DatabaseComponent.get(context).sessionContactDatabase().getContactWithAccountID(publicKey) return contact?.displayName(Contact.ContactContext.REGULAR) ?: publicKey } - if (recipient.isClosedGroupRecipient) { + if (isClosedGroupRecipient) { val members = DatabaseComponent.get(context).groupDatabase() - .getGroupMemberAddresses(recipient.address.toGroupString(), true) + .getGroupMemberAddresses(address.toGroupString(), true) .sorted() .take(2) .toMutableList() @@ -70,13 +75,13 @@ class ProfilePictureView @JvmOverloads constructor( additionalPublicKey = apk additionalDisplayName = getUserDisplayName(apk) } - } else if(recipient.isOpenGroupInboxRecipient) { - val publicKey = GroupUtil.getDecodedOpenGroupInboxAccountId(recipient.address.serialize()) + } else if(isOpenGroupInboxRecipient) { + val publicKey = GroupUtil.getDecodedOpenGroupInboxAccountId(address.serialize()) this.publicKey = publicKey displayName = getUserDisplayName(publicKey) additionalPublicKey = null } else { - val publicKey = recipient.address.toString() + val publicKey = address.serialize() this.publicKey = publicKey displayName = getUserDisplayName(publicKey) additionalPublicKey = null diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt index e4cb498cb3..d77c8a5d68 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt @@ -90,7 +90,6 @@ private fun getHighlight(query: String?, toSearch: String): Spannable? { fun ContentView.bindModel(query: String?, model: GroupConversation) { binding.searchResultProfilePicture.isVisible = true - binding.searchResultSavedMessages.isVisible = false binding.searchResultSubtitle.isVisible = model.groupRecord.isClosedGroup binding.searchResultTimestamp.isVisible = false val threadRecipient = Recipient.from(binding.root.context, Address.fromSerialized(model.groupRecord.encodedId), false) @@ -111,7 +110,6 @@ fun ContentView.bindModel(query: String?, model: GroupConversation) { fun ContentView.bindModel(query: String?, model: ContactModel) { binding.searchResultProfilePicture.isVisible = true - binding.searchResultSavedMessages.isVisible = false binding.searchResultSubtitle.isVisible = false binding.searchResultTimestamp.isVisible = false binding.searchResultSubtitle.text = null @@ -126,13 +124,12 @@ fun ContentView.bindModel(model: SavedMessages) { binding.searchResultSubtitle.isVisible = false binding.searchResultTimestamp.isVisible = false binding.searchResultTitle.setText(R.string.note_to_self) - binding.searchResultProfilePicture.isVisible = false - binding.searchResultSavedMessages.isVisible = true + binding.searchResultProfilePicture.update(Address.fromSerialized(model.currentUserPublicKey)) + binding.searchResultProfilePicture.isVisible = true } fun ContentView.bindModel(query: String?, model: Message) { binding.searchResultProfilePicture.isVisible = true - binding.searchResultSavedMessages.isVisible = false binding.searchResultTimestamp.isVisible = true // val hasUnreads = model.unread > 0 // binding.unreadCountIndicator.isVisible = hasUnreads diff --git a/app/src/main/res/drawable/ic_outline_bookmark_border_24.xml b/app/src/main/res/drawable/ic_outline_bookmark_border_24.xml deleted file mode 100644 index 0cb95b7706..0000000000 --- a/app/src/main/res/drawable/ic_outline_bookmark_border_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/layout/view_global_search_result.xml b/app/src/main/res/layout/view_global_search_result.xml index b4d88e1823..d5b911eb82 100644 --- a/app/src/main/res/layout/view_global_search_result.xml +++ b/app/src/main/res/layout/view_global_search_result.xml @@ -24,15 +24,6 @@ android:layout_width="@dimen/medium_profile_picture_size" android:layout_height="@dimen/medium_profile_picture_size" /> -