Delete root message UI

This commit is contained in:
ariskotsomitopoulos 2021-11-29 15:00:27 +02:00
parent c4967a2871
commit 2a83e93265
3 changed files with 17 additions and 3 deletions

View file

@ -125,6 +125,10 @@ fun TextView.setLeftDrawable(@DrawableRes iconRes: Int, @AttrRes tintColor: Int?
setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null) 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 * Set long click listener to copy the current text of the TextView to the clipboard and show a Snackbar
*/ */

View file

@ -26,6 +26,9 @@ import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick 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.displayname.getBestName
import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.MatrixItem
@ -40,6 +43,7 @@ abstract class ThreadListModel : VectorEpoxyModel<ThreadListModel.Holder>() {
@EpoxyAttribute lateinit var rootMessage: String @EpoxyAttribute lateinit var rootMessage: String
@EpoxyAttribute lateinit var lastMessage: String @EpoxyAttribute lateinit var lastMessage: String
@EpoxyAttribute lateinit var lastMessageCounter: String @EpoxyAttribute lateinit var lastMessageCounter: String
@EpoxyAttribute var rootMessageDeleted: Boolean = false
@EpoxyAttribute var lastMessageMatrixItem: MatrixItem? = null @EpoxyAttribute var lastMessageMatrixItem: MatrixItem? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null
@ -50,8 +54,14 @@ abstract class ThreadListModel : VectorEpoxyModel<ThreadListModel.Holder>() {
holder.avatarImageView.contentDescription = matrixItem.getBestName() holder.avatarImageView.contentDescription = matrixItem.getBestName()
holder.titleTextView.text = title holder.titleTextView.text = title
holder.dateTextView.text = date 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 // Last message summary
lastMessageMatrixItem?.let { lastMessageMatrixItem?.let {
avatarRenderer.render(it, holder.lastMessageAvatarImageView) avatarRenderer.render(it, holder.lastMessageAvatarImageView)
@ -59,7 +69,6 @@ abstract class ThreadListModel : VectorEpoxyModel<ThreadListModel.Holder>() {
holder.lastMessageAvatarImageView.contentDescription = lastMessageMatrixItem?.getBestName() holder.lastMessageAvatarImageView.contentDescription = lastMessageMatrixItem?.getBestName()
holder.lastMessageTextView.text = lastMessage holder.lastMessageTextView.text = lastMessage
holder.lastMessageCounterTextView.text = lastMessageCounter holder.lastMessageCounterTextView.text = lastMessageCounter
} }
class Holder : VectorEpoxyHolder() { class Holder : VectorEpoxyHolder() {

View file

@ -52,6 +52,7 @@ class ThreadListController @Inject constructor(
matrixItem(timelineEvent.senderInfo.toMatrixItem()) matrixItem(timelineEvent.senderInfo.toMatrixItem())
title(timelineEvent.senderInfo.displayName) title(timelineEvent.senderInfo.displayName)
date(date) date(date)
rootMessageDeleted(timelineEvent.root.isRedacted())
rootMessage(timelineEvent.root.getDecryptedTextSummary()) rootMessage(timelineEvent.root.getDecryptedTextSummary())
lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage.orEmpty()) lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage.orEmpty())
lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString()) lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString())