From 2a83e93265ae867ae850cb8aab75412b58f7360a Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Mon, 29 Nov 2021 15:00:27 +0200 Subject: [PATCH] Delete root message UI --- .../im/vector/app/core/extensions/TextView.kt | 4 ++++ .../room/threads/list/model/ThreadListModel.kt | 15 ++++++++++++--- .../list/viewmodel/ThreadListController.kt | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/TextView.kt b/vector/src/main/java/im/vector/app/core/extensions/TextView.kt index adb655f169..c0911aec8b 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TextView.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TextView.kt @@ -125,6 +125,10 @@ fun TextView.setLeftDrawable(@DrawableRes iconRes: Int, @AttrRes tintColor: Int? setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null) } +fun TextView.clearDrawables() { + this.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) +} + /** * Set long click listener to copy the current text of the TextView to the clipboard and show a Snackbar */ diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListModel.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListModel.kt index 887a6acb4b..f47f6f46cc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListModel.kt @@ -26,6 +26,9 @@ import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.epoxy.onClick +import im.vector.app.core.extensions.clearDrawables +import im.vector.app.core.extensions.setLeftDrawable +import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.displayname.getBestName import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.util.MatrixItem @@ -40,6 +43,7 @@ abstract class ThreadListModel : VectorEpoxyModel() { @EpoxyAttribute lateinit var rootMessage: String @EpoxyAttribute lateinit var lastMessage: String @EpoxyAttribute lateinit var lastMessageCounter: String + @EpoxyAttribute var rootMessageDeleted: Boolean = false @EpoxyAttribute var lastMessageMatrixItem: MatrixItem? = null @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null @@ -50,8 +54,14 @@ abstract class ThreadListModel : VectorEpoxyModel() { holder.avatarImageView.contentDescription = matrixItem.getBestName() holder.titleTextView.text = title holder.dateTextView.text = date - holder.rootMessageTextView.text = rootMessage - + if (rootMessageDeleted){ + holder.rootMessageTextView.text = holder.view.context.getString(R.string.event_redacted) + holder.rootMessageTextView.setLeftDrawable(R.drawable.ic_trash_16, R.attr.colorOnPrimary) + holder.rootMessageTextView.compoundDrawablePadding = DimensionConverter(holder.view.context.resources).dpToPx(10) + }else{ + holder.rootMessageTextView.text = rootMessage + holder.rootMessageTextView.clearDrawables() + } // Last message summary lastMessageMatrixItem?.let { avatarRenderer.render(it, holder.lastMessageAvatarImageView) @@ -59,7 +69,6 @@ abstract class ThreadListModel : VectorEpoxyModel() { holder.lastMessageAvatarImageView.contentDescription = lastMessageMatrixItem?.getBestName() holder.lastMessageTextView.text = lastMessage holder.lastMessageCounterTextView.text = lastMessageCounter - } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt index f0f9d1e9a2..d17dee6e51 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt @@ -52,6 +52,7 @@ class ThreadListController @Inject constructor( matrixItem(timelineEvent.senderInfo.toMatrixItem()) title(timelineEvent.senderInfo.displayName) date(date) + rootMessageDeleted(timelineEvent.root.isRedacted()) rootMessage(timelineEvent.root.getDecryptedTextSummary()) lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage.orEmpty()) lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString())