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)
}
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
*/

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.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<ThreadListModel.Holder>() {
@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<ThreadListModel.Holder>() {
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<ThreadListModel.Holder>() {
holder.lastMessageAvatarImageView.contentDescription = lastMessageMatrixItem?.getBestName()
holder.lastMessageTextView.text = lastMessage
holder.lastMessageCounterTextView.text = lastMessageCounter
}
class Holder : VectorEpoxyHolder() {

View File

@ -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())