Fix / Hide reactions on redacted message

This commit is contained in:
Valere 2019-05-19 12:07:40 +02:00
parent 054d339b48
commit 71e364b42f
3 changed files with 25 additions and 5 deletions

View File

@ -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 {

View File

@ -80,17 +80,23 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
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<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
}
}

open fun shouldShowReactionAtBottom() : Boolean {
return true
}

protected fun View.renderSendState() {
isClickable = informationData.sendState.isSent()
alpha = if (informationData.sendState.isSent()) 1f else 0.5f

View File

@ -12,6 +12,8 @@ abstract class RedactedMessageItem : AbsMessageItem<RedactedMessageItem.Holder>(

override fun getStubType(): Int = STUB_ID

override fun shouldShowReactionAtBottom() = false

class Holder : AbsMessageItem.Holder() {
override fun getStubId(): Int = STUB_ID
}