From be2983053a9f5659ee480ca963cff6ad40cdfbda Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Mon, 2 Nov 2020 10:40:30 +0100 Subject: [PATCH] For bottom timestamps, we can hide member names also when hiding avatars Member names not really important in direct chats or for outgoing messages. Change-Id: I1d3328444daf571488b1d9b4d2d188d695c515b3 --- .../detail/timeline/item/AbsMessageItem.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 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 113da03eb9..0fb0cf9ffb 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 @@ -64,11 +64,13 @@ abstract class AbsMessageItem : AbsBaseMessageItem val contentInBubble = infoInBubbles(holder.memberNameView.context) val avatarImageView: ImageView? - val memberNameView: TextView? + var memberNameView: TextView? var timeView: TextView? val hiddenViews = ArrayList() val invisibleViews = ArrayList() + val avatarUnnecessary = canHideAvatars() + // Select which views are visible, based on bubble style and other criteria if (attributes.informationData.showInformation) { if (contentInBubble) { @@ -114,8 +116,15 @@ abstract class AbsMessageItem : AbsBaseMessageItem if (BubbleThemeUtils.getBubbleTimeLocation(holder.bubbleTimeView.context) == BubbleThemeUtils.BUBBLE_TIME_BOTTOM) { timeView = holder.bubbleFooterTimeView if (attributes.informationData.showInformation) { - // Don't hide, so our relative layout rules still work - invisibleViews.add(holder.bubbleTimeView) + if (avatarUnnecessary) { + // In the case of footer time, we can also hide the names without making it look awkward + hiddenViews.add(holder.bubbleMemberNameView) + memberNameView = null + hiddenViews.add(holder.bubbleTimeView) + } else { + // Don't completely remove, just hide, so our relative layout rules still work + invisibleViews.add(holder.bubbleTimeView) + } } else { // Do hide, or we accidentally reserve space hiddenViews.add(holder.bubbleTimeView) @@ -127,7 +136,7 @@ abstract class AbsMessageItem : AbsBaseMessageItem // Dual-side bubbles: hide own avatar, and all in direct chats if ((!attributes.informationData.showInformation) || - (contentInBubble && (attributes.informationData.sentByMe || attributes.informationData.isDirect))) { + (contentInBubble && avatarUnnecessary)) { avatarImageView = null hiddenViews.add(holder.avatarImageView) } else { @@ -293,6 +302,10 @@ abstract class AbsMessageItem : AbsBaseMessageItem open fun reserveFooterSpace(holder: H, width: Int, height: Int) { } + open fun canHideAvatars(): Boolean { + return attributes.informationData.sentByMe || attributes.informationData.isDirect + } + override fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) { super.setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble)