mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Fix SC bubbles crash for chats with verification-request
Change-Id: Ie5527a5bf5d89b8421759f9acab3c426a8a09cfa
This commit is contained in:
parent
ead93dc8ad
commit
b9b5bd6519
1 changed files with 31 additions and 22 deletions
|
@ -99,28 +99,32 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
|
|||
|
||||
val messageLayout = when (layoutSettingsProvider.getLayoutSettings()) {
|
||||
TimelineLayoutSettings.SC_BUBBLE -> {
|
||||
val messageContent = event.getLastMessageContent()
|
||||
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,
|
||||
// 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,
|
||||
bubbleAppearance = bubbleThemeUtils.getBubbleAppearance(),
|
||||
isIncoming = !isSentByMe,
|
||||
isNotice = messageContent is MessageNoticeContent,
|
||||
reverseBubble = isSentByMe && !singleSidedLayout,
|
||||
singleSidedLayout = singleSidedLayout,
|
||||
isRealBubble = isBubble && !pseudoBubble,
|
||||
isPseudoBubble = pseudoBubble,
|
||||
timestampAsOverlay = messageContent.timestampAsOverlay()
|
||||
)
|
||||
if (event.shouldNeverUseScLayout()) {
|
||||
buildModernLayout(showInformation)
|
||||
} else {
|
||||
val messageContent = event.getLastMessageContent()
|
||||
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,
|
||||
// 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,
|
||||
bubbleAppearance = bubbleThemeUtils.getBubbleAppearance(),
|
||||
isIncoming = !isSentByMe,
|
||||
isNotice = messageContent is MessageNoticeContent,
|
||||
reverseBubble = isSentByMe && !singleSidedLayout,
|
||||
singleSidedLayout = singleSidedLayout,
|
||||
isRealBubble = isBubble && !pseudoBubble,
|
||||
isPseudoBubble = pseudoBubble,
|
||||
timestampAsOverlay = messageContent.timestampAsOverlay()
|
||||
)
|
||||
}
|
||||
}
|
||||
TimelineLayoutSettings.MODERN -> {
|
||||
buildModernLayout(showInformation)
|
||||
|
@ -214,6 +218,11 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
|
|||
return false
|
||||
}
|
||||
|
||||
private fun TimelineEvent.shouldNeverUseScLayout(): Boolean {
|
||||
val messageContent = getLastMessageContent()
|
||||
return messageContent?.msgType in MSG_TYPES_WITHOUT_BUBBLE_LAYOUT
|
||||
}
|
||||
|
||||
private fun buildModernLayout(showInformation: Boolean, forScBubbles: Boolean = false): TimelineMessageLayout.Default {
|
||||
return TimelineMessageLayout.Default(
|
||||
showAvatar = showInformation,
|
||||
|
|
Loading…
Add table
Reference in a new issue