From 17d58f24d209f0cf85c83fb7a31f9b056e248565 Mon Sep 17 00:00:00 2001 From: sim Date: Tue, 1 Mar 2022 00:26:26 +0100 Subject: [PATCH] Add padding before our first message Signed-off-by: sim --- changelog.d/5384.misc | 1 + .../home/room/detail/timeline/item/AbsMessageItem.kt | 4 ++++ .../room/detail/timeline/style/TimelineMessageLayout.kt | 3 +++ .../detail/timeline/style/TimelineMessageLayoutFactory.kt | 1 + vector/src/main/res/layout/view_message_bubble.xml | 8 +++++++- 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelog.d/5384.misc diff --git a/changelog.d/5384.misc b/changelog.d/5384.misc new file mode 100644 index 00000000000..dca87422bb3 --- /dev/null +++ b/changelog.d/5384.misc @@ -0,0 +1 @@ +Add top margin before our first message 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 9e8f86c26ef..ac5d943cf6f 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 @@ -105,6 +105,9 @@ abstract class AbsMessageItem : AbsBaseMessageItem } else { holder.timeView.isVisible = false } + + holder.additionalTopSpace.isVisible = attributes.informationData.messageLayout.addTopMargin + // Render send state indicator holder.sendStateImageView.render(attributes.informationData.sendStateDecoration) holder.eventSendingIndicator.isVisible = attributes.informationData.sendStateDecoration == SendStateDecoration.SENDING_MEDIA @@ -154,6 +157,7 @@ abstract class AbsMessageItem : AbsBaseMessageItem abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) { + val additionalTopSpace by bind(R.id.additionalTopSpace) val avatarImageView by bind(R.id.messageAvatarImageView) val memberNameView by bind(R.id.messageMemberNameView) val timeView by bind(R.id.messageTimeView) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayout.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayout.kt index c87680de0ab..202d8b05da5 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayout.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayout.kt @@ -24,12 +24,14 @@ sealed interface TimelineMessageLayout : Parcelable { val layoutRes: Int val showAvatar: Boolean val showDisplayName: Boolean + val addTopMargin: Boolean val showTimestamp: Boolean @Parcelize data class Default(override val showAvatar: Boolean, override val showDisplayName: Boolean, override val showTimestamp: Boolean, + override val addTopMargin: Boolean = false, // Keep defaultLayout generated on epoxy items override val layoutRes: Int = 0) : TimelineMessageLayout @@ -38,6 +40,7 @@ sealed interface TimelineMessageLayout : Parcelable { override val showAvatar: Boolean, override val showDisplayName: Boolean, override val showTimestamp: Boolean = true, + override val addTopMargin: Boolean = false, val isIncoming: Boolean, val isPseudoBubble: Boolean, val cornersRadius: CornersRadius, 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 8c1c308bb5a..a614015f461 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 @@ -118,6 +118,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess TimelineMessageLayout.Bubble( showAvatar = showInformation && !isSentByMe, showDisplayName = showInformation && !isSentByMe, + addTopMargin = isFirstFromThisSender && isSentByMe, isIncoming = !isSentByMe, cornersRadius = cornersRadius, isPseudoBubble = messageContent.isPseudoBubble(), diff --git a/vector/src/main/res/layout/view_message_bubble.xml b/vector/src/main/res/layout/view_message_bubble.xml index 5ae5afc329f..d56bdb659d4 100644 --- a/vector/src/main/res/layout/view_message_bubble.xml +++ b/vector/src/main/res/layout/view_message_bubble.xml @@ -26,12 +26,18 @@ android:padding="2dp" tools:src="@sample/user_round_avatars" /> + +