From de8bd1d605a6ad1c672dc08f4c8a11653b47d41a Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sun, 29 Nov 2020 15:45:24 +0100 Subject: [PATCH] View stub minimum width: read from informationData Change-Id: If0ea41028044750ff540dc6a1bee2d1143715321 --- .../home/room/detail/timeline/item/AbsMessageItem.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt index 6808704015..007b9ecfae 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt @@ -247,12 +247,14 @@ abstract class AbsMessageItem : AbsBaseMessageItem } open fun getViewStubMinimumWidth(holder: H, contentInBubble: Boolean, showInformation: Boolean): Int { + val memberName = attributes.informationData.memberName.toString() + val time = attributes.informationData.time.toString() return if (contentInBubble) { if (BubbleThemeUtils.getBubbleTimeLocation(holder.bubbleTimeView.context) == BubbleThemeUtils.BUBBLE_TIME_BOTTOM) { if (attributes.informationData.showInformation) { // Since timeView automatically gets enough space, either within or outside the viewStub, we just need to ensure the member name view has enough space // Somehow not enough without extra space... - ceil(BubbleThemeUtils.guessTextWidth(holder.bubbleMemberNameView, holder.bubbleMemberNameView.text.toString() + " ")).toInt() + ceil(BubbleThemeUtils.guessTextWidth(holder.bubbleMemberNameView, "$memberName ")).toInt() } else { // wrap_content works! 0 @@ -260,9 +262,9 @@ abstract class AbsMessageItem : AbsBaseMessageItem } else if (attributes.informationData.showInformation || attributes.informationData.forceShowTimestamp) { // Guess text width for name and time next to each other val text = if (attributes.informationData.showInformation) { - holder.bubbleMemberNameView.text.toString() + " " + holder.bubbleTimeView.text.toString() + "$memberName $time" } else { - holder.bubbleTimeView.text.toString() + time } val textSize = if (attributes.informationData.showInformation) { max(holder.bubbleMemberNameView.textSize, holder.bubbleTimeView.textSize)