Skip to content

Commit 8c15b2e

Browse files
committed
Add padding before our first message
Signed-off-by: sim <[email protected]>
1 parent b226ab5 commit 8c15b2e

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

changelog.d/5384.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add top margin before our first message

vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import android.widget.RelativeLayout
2525
import android.widget.TextView
2626
import androidx.annotation.IdRes
2727
import androidx.constraintlayout.widget.ConstraintLayout
28+
import androidx.core.view.isGone
2829
import androidx.core.view.isVisible
2930
import androidx.core.view.updateLayoutParams
3031
import com.airbnb.epoxy.EpoxyAttribute
@@ -105,6 +106,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
105106
} else {
106107
holder.timeView.isVisible = false
107108
}
109+
110+
holder.additionalTopSpace.isVisible = attributes.informationData.messageLayout.addTopMargin
111+
108112
// Render send state indicator
109113
holder.sendStateImageView.render(attributes.informationData.sendStateDecoration)
110114
holder.eventSendingIndicator.isVisible = attributes.informationData.sendStateDecoration == SendStateDecoration.SENDING_MEDIA
@@ -154,6 +158,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
154158

155159
abstract class Holder(@IdRes stubId: Int) : AbsBaseMessageItem.Holder(stubId) {
156160

161+
val additionalTopSpace by bind<View>(R.id.additionalTopSpace)
157162
val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
158163
val memberNameView by bind<TextView>(R.id.messageMemberNameView)
159164
val timeView by bind<TextView>(R.id.messageTimeView)

vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayout.kt

+3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ sealed interface TimelineMessageLayout : Parcelable {
2424
val layoutRes: Int
2525
val showAvatar: Boolean
2626
val showDisplayName: Boolean
27+
val addTopMargin: Boolean
2728
val showTimestamp: Boolean
2829

2930
@Parcelize
3031
data class Default(override val showAvatar: Boolean,
3132
override val showDisplayName: Boolean,
3233
override val showTimestamp: Boolean,
34+
override val addTopMargin: Boolean = false,
3335
// Keep defaultLayout generated on epoxy items
3436
override val layoutRes: Int = 0) : TimelineMessageLayout
3537

@@ -38,6 +40,7 @@ sealed interface TimelineMessageLayout : Parcelable {
3840
override val showAvatar: Boolean,
3941
override val showDisplayName: Boolean,
4042
override val showTimestamp: Boolean = true,
43+
override val addTopMargin: Boolean = false,
4144
val isIncoming: Boolean,
4245
val isPseudoBubble: Boolean,
4346
val cornersRadius: CornersRadius,

vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess
118118
TimelineMessageLayout.Bubble(
119119
showAvatar = showInformation && !isSentByMe,
120120
showDisplayName = showInformation && !isSentByMe,
121+
addTopMargin = isFirstFromThisSender && isSentByMe,
121122
isIncoming = !isSentByMe,
122123
cornersRadius = cornersRadius,
123124
isPseudoBubble = messageContent.isPseudoBubble(),

vector/src/main/res/layout/view_message_bubble.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@
2626
android:padding="2dp"
2727
tools:src="@sample/user_round_avatars" />
2828

29+
<View
30+
android:id="@+id/additionalTopSpace"
31+
android:layout_height="12dp"
32+
android:layout_width="0dp"
33+
android:layout_toEndOf="@id/messageStartGuideline" />
34+
2935
<TextView
3036
android:id="@+id/messageMemberNameView"
3137
style="@style/Widget.Vector.TextView.Subtitle"
3238
android:layout_width="wrap_content"
3339
android:layout_height="wrap_content"
34-
android:layout_alignParentTop="true"
40+
android:layout_below="@id/additionalTopSpace"
3541
android:layout_alignParentEnd="true"
3642
android:layout_marginStart="12dp"
3743
android:layout_marginEnd="4dp"

0 commit comments

Comments
 (0)