Bubbles: fix avatar/name visibility in modern layout

This commit is contained in:
ganfra 2022-01-12 19:22:14 +01:00
parent 32e72f54b3
commit 37af93fba4

View File

@ -45,23 +45,28 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
val isNextMessageReceivedMoreThanOneHourAgo = nextDate?.isBefore(date.minusMinutes(60)) val isNextMessageReceivedMoreThanOneHourAgo = nextDate?.isBefore(date.minusMinutes(60))
?: false ?: false
val showInformation = val showInformation = addDaySeparator ||
(addDaySeparator || event.senderInfo.avatarUrl != nextDisplayableEvent?.senderInfo?.avatarUrl ||
event.senderInfo.avatarUrl != nextDisplayableEvent?.senderInfo?.avatarUrl || event.senderInfo.disambiguatedDisplayName != nextDisplayableEvent?.senderInfo?.disambiguatedDisplayName ||
event.senderInfo.disambiguatedDisplayName != nextDisplayableEvent?.senderInfo?.disambiguatedDisplayName || nextDisplayableEvent.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER, EventType.ENCRYPTED) ||
nextDisplayableEvent.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER, EventType.ENCRYPTED) || isNextMessageReceivedMoreThanOneHourAgo ||
isNextMessageReceivedMoreThanOneHourAgo || isTileTypeMessage(nextDisplayableEvent) ||
isTileTypeMessage(nextDisplayableEvent) || nextDisplayableEvent.isEdition()
nextDisplayableEvent.isEdition()) && !isSentByMe
val messageLayout = when (layoutSettingsProvider.getLayoutSettings()) { val messageLayout = when (layoutSettingsProvider.getLayoutSettings()) {
TimelineLayoutSettings.MODERN -> TimelineMessageLayout.Modern(showInformation, showInformation, showInformation || vectorPreferences.alwaysShowTimeStamps()) TimelineLayoutSettings.MODERN -> {
TimelineMessageLayout.Modern(
showAvatar = showInformation,
showDisplayName = showInformation,
showTimestamp = showInformation || vectorPreferences.alwaysShowTimeStamps()
)
}
TimelineLayoutSettings.BUBBLE -> { TimelineLayoutSettings.BUBBLE -> {
val isFirstFromThisSender = nextDisplayableEvent?.root?.senderId != event.root.senderId || addDaySeparator 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?.root?.senderId != event.root.senderId || prevDisplayableEvent?.root?.localDateTime()?.toLocalDate() != date.toLocalDate()
TimelineMessageLayout.Bubble( TimelineMessageLayout.Bubble(
showAvatar = showInformation, showAvatar = showInformation && !isSentByMe,
showDisplayName = showInformation, showDisplayName = showInformation && !isSentByMe,
isIncoming = !isSentByMe, isIncoming = !isSentByMe,
isFirstFromThisSender = isFirstFromThisSender, isFirstFromThisSender = isFirstFromThisSender,
isLastFromThisSender = isLastFromThisSender isLastFromThisSender = isLastFromThisSender