Put redactions into bubbles, no matter what the original type was

Change-Id: I6b7e424a29b1f8eb54862fc0a58102dcfaa8642c
This commit is contained in:
SpiritCroc 2022-04-21 10:43:41 +02:00
parent 06ab920ef8
commit b3599aac23
1 changed files with 8 additions and 3 deletions

View File

@ -106,7 +106,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
val messageContent = event.getLastMessageContent() val messageContent = event.getLastMessageContent()
val isBubble = event.shouldBuildBubbleLayout() val isBubble = event.shouldBuildBubbleLayout()
val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START
val pseudoBubble = messageContent.isPseudoBubble() val pseudoBubble = messageContent.isPseudoBubble(event)
val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps() val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps()
return TimelineMessageLayout.ScBubble( return TimelineMessageLayout.ScBubble(
showAvatar = showInformation, showAvatar = showInformation,
@ -153,7 +153,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
addTopMargin = isFirstFromThisSender && isSentByMe, addTopMargin = isFirstFromThisSender && isSentByMe,
isIncoming = !isSentByMe, isIncoming = !isSentByMe,
cornersRadius = cornersRadius, cornersRadius = cornersRadius,
isPseudoBubble = messageContent.isPseudoBubble(), isPseudoBubble = messageContent.isPseudoBubble(event),
timestampAsOverlay = messageContent.timestampAsOverlay() timestampAsOverlay = messageContent.timestampAsOverlay()
) )
} else { } else {
@ -194,8 +194,9 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
} }
} }
private fun MessageContent?.isPseudoBubble(): Boolean { private fun MessageContent?.isPseudoBubble(event: TimelineEvent): Boolean {
if (this == null) return false if (this == null) return false
if (event.root.isRedacted()) return false
if (msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline() if (msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline()
return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT
} }
@ -212,6 +213,10 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
} }
private fun TimelineEvent.shouldBuildBubbleLayout(): Boolean { private fun TimelineEvent.shouldBuildBubbleLayout(): Boolean {
if (root.isRedacted()) {
// Redacted messages always go into bubbles
return true
}
val type = root.getClearType() val type = root.getClearType()
if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) { if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) {
val messageContent = getLastMessageContent() val messageContent = getLastMessageContent()