Bubbles: update sticker handling

This commit is contained in:
ganfra 2022-01-19 11:49:33 +01:00
parent 5ee4984ec8
commit ac0c2624f0
4 changed files with 10 additions and 5 deletions

View File

@ -89,7 +89,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
holder.mediaContentView.onClick(attributes.itemClickListener)
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
holder.playContentView.visibility = if (playable) View.VISIBLE else View.GONE
holder.overlayView.isVisible = messageLayout is TimelineMessageLayout.Bubble
holder.overlayView.isVisible = messageLayout is TimelineMessageLayout.Bubble && messageLayout.timestampAsOverlay
}
override fun unbind(holder: Holder) {

View File

@ -42,6 +42,7 @@ sealed interface TimelineMessageLayout : Parcelable {
val isFirstFromThisSender: Boolean,
val isLastFromThisSender: Boolean,
val isPseudoBubble: Boolean,
val timestampAsOverlay: Boolean,
override val layoutRes: Int = if (isIncoming) {
R.layout.item_timeline_event_bubble_incoming_base
} else {

View File

@ -40,6 +40,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
EventType.ENCRYPTED,
EventType.STICKER
)
// Can't be rendered in bubbles, so get back to default layout
private val MSG_TYPES_WITHOUT_BUBBLE_LAYOUT = setOf(
MessageType.MSGTYPE_VERIFICATION_REQUEST
@ -47,7 +48,10 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
// Use the bubble layout but without borders
private val MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT = setOf(
MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO,
MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_STICKER_LOCAL
)
private val MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY = setOf(
MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO
)
}
@ -93,7 +97,8 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
isIncoming = !isSentByMe,
isFirstFromThisSender = isFirstFromThisSender,
isLastFromThisSender = isLastFromThisSender,
isPseudoBubble = messageContent?.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT
isPseudoBubble = messageContent?.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT,
timestampAsOverlay = messageContent?.msgType in MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY
)
}
} else {

View File

@ -92,8 +92,7 @@ class MessageBubbleView @JvmOverloads constructor(context: Context, attrs: Attri
ConstraintSet().apply {
clone(views.bubbleView)
clear(R.id.viewStubContainer, ConstraintSet.END)
val showTimeAsOverlay = messageLayout.isPseudoBubble
if (showTimeAsOverlay) {
if (messageLayout.timestampAsOverlay) {
val timeColor = ContextCompat.getColor(context, R.color.palette_white)
views.messageTimeView.setTextColor(timeColor)
connect(R.id.viewStubContainer, ConstraintSet.END, R.id.parent, ConstraintSet.END, 0)