From 0c11778d3354387de0f6762bb3590855318648b9 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Thu, 1 Dec 2022 11:26:55 +0100 Subject: [PATCH] Rich Text Editor: fix several inset issues in room screen (#7681) --- changelog.d/7680.bugfix | 3 +++ .../utils/ExpandingBottomSheetBehavior.kt | 23 ++++++++++++------- .../composer/MessageComposerFragment.kt | 2 +- .../src/main/res/layout/fragment_timeline.xml | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 changelog.d/7680.bugfix diff --git a/changelog.d/7680.bugfix b/changelog.d/7680.bugfix new file mode 100644 index 0000000000..2e3b4b2e48 --- /dev/null +++ b/changelog.d/7680.bugfix @@ -0,0 +1,3 @@ +Rich Text Editor: fix several issues related to insets: +* Empty space displayed at the bottom when you don't have permissions to send messages into a room. +* Wrong insets being kept when you exit the room screen and the keyboard is displayed, then come back to it. diff --git a/vector/src/main/java/im/vector/app/core/utils/ExpandingBottomSheetBehavior.kt b/vector/src/main/java/im/vector/app/core/utils/ExpandingBottomSheetBehavior.kt index 0474cdea7e..47326bca76 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExpandingBottomSheetBehavior.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExpandingBottomSheetBehavior.kt @@ -608,26 +608,33 @@ class ExpandingBottomSheetBehavior : CoordinatorLayout.Behavior { initialPaddingBottom = view.paddingBottom // This should only be used to set initial insets and other edge cases where the insets can't be applied using an animation. - var applyInsetsFromAnimation = false + var isAnimating = false - // This will animated inset changes, making them look a lot better. However, it won't update initial insets. + // This will animate inset changes, making them look a lot better. However, it won't update initial insets. ViewCompat.setWindowInsetsAnimationCallback(view, object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) { + override fun onPrepare(animation: WindowInsetsAnimationCompat) { + isAnimating = true + } + override fun onProgress(insets: WindowInsetsCompat, runningAnimations: MutableList): WindowInsetsCompat { - return applyInsets(view, insets) + return if (isAnimating) { + applyInsets(view, insets) + } else { + insets + } } override fun onEnd(animation: WindowInsetsAnimationCompat) { - applyInsetsFromAnimation = false + isAnimating = false view.requestApplyInsets() } }) ViewCompat.setOnApplyWindowInsetsListener(view) { _: View, insets: WindowInsetsCompat -> - if (!applyInsetsFromAnimation) { - applyInsetsFromAnimation = true - applyInsets(view, insets) - } else { + if (isAnimating) { insets + } else { + applyInsets(view, insets) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt index d551850ff3..97e74785ec 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerFragment.kt @@ -255,7 +255,7 @@ class MessageComposerFragment : VectorBaseFragment(), A ) { mainState, messageComposerState, attachmentState -> if (mainState.tombstoneEvent != null) return@withState - (composer as? View)?.isInvisible = !messageComposerState.isComposerVisible + (composer as? View)?.isVisible = messageComposerState.isComposerVisible composer.sendButton.isInvisible = !messageComposerState.isSendButtonVisible (composer as? RichTextComposerLayout)?.isTextFormattingEnabled = attachmentState.isTextFormattingEnabled } diff --git a/vector/src/main/res/layout/fragment_timeline.xml b/vector/src/main/res/layout/fragment_timeline.xml index 6597b464ac..6e83dbe8fd 100644 --- a/vector/src/main/res/layout/fragment_timeline.xml +++ b/vector/src/main/res/layout/fragment_timeline.xml @@ -75,7 +75,7 @@ android:layout_width="0dp" android:layout_height="0dp" android:overScrollMode="always" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toTopOf="@id/notificationAreaView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/removeJitsiWidgetView"