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
This commit is contained in:
SpiritCroc 2022-03-10 13:42:48 +01:00
parent 27fd6a2819
commit 10c77f2b59
2 changed files with 14 additions and 2 deletions

View File

@ -50,6 +50,7 @@ import androidx.core.text.toSpannable
import androidx.core.util.Pair import androidx.core.util.Pair
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.forEach import androidx.core.view.forEach
import androidx.core.view.isGone
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.setFragmentResultListener import androidx.fragment.app.setFragmentResultListener
@ -1692,14 +1693,24 @@ class TimelineFragment @Inject constructor(
voiceMessageRecorderView.isVisible = false 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) { private fun renderTypingMessageNotification(roomSummary: RoomSummary?, state: RoomDetailViewState) {
if (!isThreadTimeLine() && roomSummary != null) { if (!isThreadTimeLine() && roomSummary != null) {
views.typingMessageView.isInvisible = state.typingUsers.isNullOrEmpty() views.typingMessageView.isInvisibleOrGone = state.typingUsers.isNullOrEmpty()
state.typingUsers state.typingUsers
?.take(MAX_TYPING_MESSAGE_USERS_COUNT) ?.take(MAX_TYPING_MESSAGE_USERS_COUNT)
?.let { senders -> views.typingMessageView.render(senders, avatarRenderer) } ?.let { senders -> views.typingMessageView.render(senders, avatarRenderer) }
} else { } else {
views.typingMessageView.isInvisible = true views.typingMessageView.isInvisibleOrGone = true
} }
} }

View File

@ -97,6 +97,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="20dp" android:paddingEnd="20dp"
android:visibility="gone"
tools:visibility="visible" tools:visibility="visible"
android:layout_height="20dp"/> android:layout_height="20dp"/>