From 2e189a1ab024eab1e8f421be973cf280151eb3dd Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 17 May 2022 11:53:44 +0200 Subject: [PATCH] Fix typing rendering #6063 --- .../ui-styles/src/main/res/values/dimens.xml | 1 + .../app/core/ui/views/TypingMessageAvatar.kt | 13 +++++--- .../src/main/res/layout/fragment_timeline.xml | 31 +++++++------------ .../main/res/layout/typing_message_layout.xml | 21 +++++++------ 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/library/ui-styles/src/main/res/values/dimens.xml b/library/ui-styles/src/main/res/values/dimens.xml index 81d5a77297..468af5d9dd 100644 --- a/library/ui-styles/src/main/res/values/dimens.xml +++ b/library/ui-styles/src/main/res/values/dimens.xml @@ -9,6 +9,7 @@ 32dp 50dp + 20dp 16dp 32dp diff --git a/vector/src/main/java/im/vector/app/core/ui/views/TypingMessageAvatar.kt b/vector/src/main/java/im/vector/app/core/ui/views/TypingMessageAvatar.kt index 22312f36fa..63c5c2947e 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/TypingMessageAvatar.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/TypingMessageAvatar.kt @@ -22,7 +22,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout -import im.vector.app.core.utils.DimensionConverter +import im.vector.app.R import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.session.room.sender.SenderInfo import org.matrix.android.sdk.api.util.toMatrixItem @@ -34,19 +34,22 @@ class TypingMessageAvatar @JvmOverloads constructor( ) : LinearLayout(context, attrs, defStyleAttr) { companion object { - const val AVATAR_SIZE_DP = 20 const val OVERLAP_FACT0R = -3 // =~ 30% to left } + private val typingAvatarSize by lazy { + context.resources.getDimension(R.dimen.typing_avatar_size).toInt() + } + fun render(typingUsers: List, avatarRenderer: AvatarRenderer) { removeAllViews() for ((index, value) in typingUsers.withIndex()) { val avatar = ImageView(context) avatar.id = View.generateViewId() val layoutParams = MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) - if (index != 0) layoutParams.marginStart = DimensionConverter(resources).dpToPx(AVATAR_SIZE_DP / OVERLAP_FACT0R) - layoutParams.width = DimensionConverter(resources).dpToPx(AVATAR_SIZE_DP) - layoutParams.height = DimensionConverter(resources).dpToPx(AVATAR_SIZE_DP) + if (index != 0) layoutParams.marginStart = typingAvatarSize / OVERLAP_FACT0R + layoutParams.width = typingAvatarSize + layoutParams.height = typingAvatarSize avatar.layoutParams = layoutParams avatarRenderer.render(value.toMatrixItem(), avatar) addView(avatar) diff --git a/vector/src/main/res/layout/fragment_timeline.xml b/vector/src/main/res/layout/fragment_timeline.xml index fcded76268..ea35d82886 100644 --- a/vector/src/main/res/layout/fragment_timeline.xml +++ b/vector/src/main/res/layout/fragment_timeline.xml @@ -37,13 +37,6 @@ - - + app:layout_constraintTop_toBottomOf="@id/timelineRecyclerView" /> + app:layout_constraintStart_toStartOf="parent" + tools:layout_height="300dp" /> + app:layout_constraintStart_toStartOf="parent" + tools:visibility="visible" /> + app:constraint_referenced_ids="composerLayout,notificationAreaView,failedMessagesWarningStub" /> diff --git a/vector/src/main/res/layout/typing_message_layout.xml b/vector/src/main/res/layout/typing_message_layout.xml index ceaea8991c..22fd29ca0b 100644 --- a/vector/src/main/res/layout/typing_message_layout.xml +++ b/vector/src/main/res/layout/typing_message_layout.xml @@ -3,39 +3,40 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:paddingTop="2dp"> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" />