Bubbles: make round style algorithm more accurate
This commit is contained in:
parent
608d8a5d54
commit
8f0e1039aa
@ -81,16 +81,16 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
|
|||||||
buildModernLayout(showInformation)
|
buildModernLayout(showInformation)
|
||||||
}
|
}
|
||||||
TimelineLayoutSettings.BUBBLE -> {
|
TimelineLayoutSettings.BUBBLE -> {
|
||||||
val type = event.root.getClearType()
|
val shouldBuildBubbleLayout = event.shouldBuildBubbleLayout()
|
||||||
if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) {
|
if (shouldBuildBubbleLayout) {
|
||||||
val messageContent = event.getLastMessageContent()
|
val isFirstFromThisSender = nextDisplayableEvent == null || !nextDisplayableEvent.shouldBuildBubbleLayout() ||
|
||||||
if (messageContent?.msgType in MSG_TYPES_WITHOUT_BUBBLE_LAYOUT) {
|
nextDisplayableEvent.root.senderId != event.root.senderId || addDaySeparator
|
||||||
buildModernLayout(showInformation)
|
|
||||||
} else {
|
|
||||||
val isFirstFromThisSender = nextDisplayableEvent?.root?.senderId != event.root.senderId || addDaySeparator
|
|
||||||
val isLastFromThisSender = prevDisplayableEvent?.root?.senderId != event.root.senderId ||
|
|
||||||
prevDisplayableEvent?.root?.localDateTime()?.toLocalDate() != date.toLocalDate()
|
|
||||||
|
|
||||||
|
val isLastFromThisSender = prevDisplayableEvent == null || !prevDisplayableEvent.shouldBuildBubbleLayout() ||
|
||||||
|
prevDisplayableEvent.root.senderId != event.root.senderId ||
|
||||||
|
prevDisplayableEvent.root.localDateTime().toLocalDate() != date.toLocalDate()
|
||||||
|
|
||||||
|
val messageContent = event.getLastMessageContent()
|
||||||
TimelineMessageLayout.Bubble(
|
TimelineMessageLayout.Bubble(
|
||||||
showAvatar = showInformation && !isSentByMe,
|
showAvatar = showInformation && !isSentByMe,
|
||||||
showDisplayName = showInformation && !isSentByMe,
|
showDisplayName = showInformation && !isSentByMe,
|
||||||
@ -100,7 +100,6 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
|
|||||||
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
|
timestampAsOverlay = messageContent?.msgType in MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY
|
||||||
)
|
)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
buildModernLayout(showInformation)
|
buildModernLayout(showInformation)
|
||||||
}
|
}
|
||||||
@ -109,6 +108,18 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
|
|||||||
return messageLayout
|
return messageLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun TimelineEvent.shouldBuildBubbleLayout(): Boolean {
|
||||||
|
val type = root.getClearType()
|
||||||
|
if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) {
|
||||||
|
val messageContent = getLastMessageContent()
|
||||||
|
if (messageContent?.msgType in MSG_TYPES_WITHOUT_BUBBLE_LAYOUT) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private fun buildModernLayout(showInformation: Boolean): TimelineMessageLayout.Default {
|
private fun buildModernLayout(showInformation: Boolean): TimelineMessageLayout.Default {
|
||||||
return TimelineMessageLayout.Default(
|
return TimelineMessageLayout.Default(
|
||||||
showAvatar = showInformation,
|
showAvatar = showInformation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user