From bd66326c4064cf5577b2e382cc00b7237bce6bc9 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 2 Mar 2022 16:22:26 +0100 Subject: [PATCH] Put emotes back into bubbles Change-Id: I2c80095104039081e32785d9fd83477e610fda21 --- .../style/TimelineMessageLayoutFactory.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt index a3b3325138..ff38d57909 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt @@ -61,7 +61,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_STICKER_LOCAL, - MessageType.MSGTYPE_EMOTE + //MessageType.MSGTYPE_EMOTE ) private val MSG_TYPES_WITH_TIMESTAMP_AS_OVERLAY = setOf( MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_VIDEO @@ -103,10 +103,15 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess val isBubble = event.shouldBuildBubbleLayout() val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START val pseudoBubble = messageContent.isPseudoBubble() + val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps() return TimelineMessageLayout.ScBubble( showAvatar = showInformation, - showDisplayName = showInformation, - showTimestamp = !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps(), + // Display names not required if + // - !showInformation -> multiple messages in a row, already had name before + // - redundantDisplayName -> message content already includes the display name (-> m.emote) + // Display name still required for single sided layout if timestamp is shown (empty space looks bad otherwise) + showDisplayName = showInformation && ((singleSidedLayout && showTimestamp) || !messageContent.redundantDisplayName()), + showTimestamp = showTimestamp, isIncoming = !isSentByMe, isNotice = messageContent is MessageNoticeContent, reverseBubble = isSentByMe && !singleSidedLayout, @@ -187,6 +192,11 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT } + private fun MessageContent?.redundantDisplayName(): Boolean { + if (this == null) return false + return msgType == MessageType.MSGTYPE_EMOTE + } + private fun MessageContent?.timestampAsOverlay(): Boolean { if (this == null) return false if (msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline()