From 10c77f2b5917e54aa6b68d1c654b0b3a2cac0dfb Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 10 Mar 2022 13:42:48 +0100 Subject: [PATCH] Don't reserve space for typing view until somebody is typing Once we show it, keep it, to not make the timeline jump around too much. Change-Id: I8f863d8d21f3b06ff86f62615d8e6aefe81bde2e --- .../features/home/room/detail/TimelineFragment.kt | 15 +++++++++++++-- vector/src/main/res/layout/fragment_timeline.xml | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 5c12f7ed39..44af7d9345 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -50,6 +50,7 @@ import androidx.core.text.toSpannable import androidx.core.util.Pair import androidx.core.view.ViewCompat import androidx.core.view.forEach +import androidx.core.view.isGone import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.fragment.app.setFragmentResultListener @@ -1692,14 +1693,24 @@ class TimelineFragment @Inject constructor( voiceMessageRecorderView.isVisible = false } + // Fully hide the typing message view with isGone, until the first user actually types + inline var View.isInvisibleOrGone: Boolean + get() = visibility != View.VISIBLE + set(value) { + // Set to invisible, unless it is already gone. + if (!value || !isGone) { + visibility = if (value) View.INVISIBLE else View.VISIBLE + } + } + private fun renderTypingMessageNotification(roomSummary: RoomSummary?, state: RoomDetailViewState) { if (!isThreadTimeLine() && roomSummary != null) { - views.typingMessageView.isInvisible = state.typingUsers.isNullOrEmpty() + views.typingMessageView.isInvisibleOrGone = state.typingUsers.isNullOrEmpty() state.typingUsers ?.take(MAX_TYPING_MESSAGE_USERS_COUNT) ?.let { senders -> views.typingMessageView.render(senders, avatarRenderer) } } else { - views.typingMessageView.isInvisible = true + views.typingMessageView.isInvisibleOrGone = true } } diff --git a/vector/src/main/res/layout/fragment_timeline.xml b/vector/src/main/res/layout/fragment_timeline.xml index 221e46bf00..d0984ca928 100644 --- a/vector/src/main/res/layout/fragment_timeline.xml +++ b/vector/src/main/res/layout/fragment_timeline.xml @@ -97,6 +97,7 @@ android:layout_width="0dp" android:paddingStart="20dp" android:paddingEnd="20dp" + android:visibility="gone" tools:visibility="visible" android:layout_height="20dp"/>