From 71e364b42fcb36cc9d7d73d549525badecf7022d Mon Sep 17 00:00:00 2001 From: Valere Date: Sun, 19 May 2019 12:07:40 +0200 Subject: [PATCH] Fix / Hide reactions on redacted message --- .../timeline/factory/MessageItemFactory.kt | 12 ++++++++++-- .../room/detail/timeline/item/AbsMessageItem.kt | 16 +++++++++++++--- .../detail/timeline/item/RedactedMessageItem.kt | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 3217e6e549..b4374c0c6e 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -85,7 +85,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider, if (event.root.unsignedData?.redactedEvent != null) { //message is redacted - return buildRedactedItem(informationData) + return buildRedactedItem(informationData, callback) } val messageContent: MessageContent = event.root.content.toModel() ?: return null @@ -350,9 +350,17 @@ class MessageItemFactory(private val colorProvider: ColorProvider, } } - private fun buildRedactedItem(informationData: MessageInformationData): RedactedMessageItem? { + private fun buildRedactedItem(informationData: MessageInformationData, callback: TimelineEventController.Callback?): RedactedMessageItem? { return RedactedMessageItem_() .informationData(informationData) + .avatarClickListener( + DebouncedClickListener(View.OnClickListener { view -> + callback?.onAvatarClicked(informationData) + })) + .memberClickListener( + DebouncedClickListener(View.OnClickListener { view -> + callback?.onMemberNameClicked(informationData) + })) } private fun linkifyBody(body: CharSequence, callback: TimelineEventController.Callback?): CharSequence { diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt index ee0f6e4195..e24139b004 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt @@ -80,17 +80,23 @@ abstract class AbsMessageItem : BaseEventItem() { holder.timeView.text = informationData.time holder.memberNameView.text = informationData.memberName AvatarRenderer.render(informationData.avatarUrl, informationData.senderId, informationData.memberName?.toString(), holder.avatarImageView) + holder.view.setOnClickListener(cellClickListener) + holder.view.setOnLongClickListener(longClickListener) + holder.avatarImageView.setOnLongClickListener(longClickListener) + holder.memberNameView.setOnLongClickListener(longClickListener) } else { holder.avatarImageView.setOnClickListener(null) holder.memberNameView.setOnClickListener(null) holder.avatarImageView.visibility = View.GONE holder.memberNameView.visibility = View.GONE holder.timeView.visibility = View.GONE + holder.view.setOnClickListener(null) + holder.view.setOnLongClickListener(null) + holder.avatarImageView.setOnLongClickListener(null) + holder.memberNameView.setOnLongClickListener(null) } - holder.view.setOnClickListener(cellClickListener) - holder.view.setOnLongClickListener(longClickListener) - if (informationData.orderedReactionList.isNullOrEmpty()) { + if (!shouldShowReactionAtBottom() || informationData.orderedReactionList.isNullOrEmpty()) { holder.reactionWrapper?.isVisible = false } else { //inflate if needed @@ -123,6 +129,10 @@ abstract class AbsMessageItem : BaseEventItem() { } } + open fun shouldShowReactionAtBottom() : Boolean { + return true + } + protected fun View.renderSendState() { isClickable = informationData.sendState.isSent() alpha = if (informationData.sendState.isSent()) 1f else 0.5f diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/RedactedMessageItem.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/RedactedMessageItem.kt index e713284415..7331a6f34b 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/RedactedMessageItem.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/RedactedMessageItem.kt @@ -12,6 +12,8 @@ abstract class RedactedMessageItem : AbsMessageItem( override fun getStubType(): Int = STUB_ID + override fun shouldShowReactionAtBottom() = false + class Holder : AbsMessageItem.Holder() { override fun getStubId(): Int = STUB_ID }