From b4802c4bf68f7704d41e2568574c90b501d86ec6 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Thu, 30 Oct 2025 13:13:19 -0300 Subject: [PATCH] Wait for global layout before animating in bottom action bar. --- .../conversation/v2/ConversationFragment.kt | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt index c7e23cb73c..be8befc4cd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt @@ -2283,9 +2283,7 @@ class ConversationFragment : } bottomActionBar.setItems(items) - bottomActionBar.doAfterNextLayout { - setBottomActionBarVisibility(true) - } + setBottomActionBarVisibility(true) } private fun setBottomActionBarVisibility(isVisible: Boolean) { @@ -2300,24 +2298,21 @@ class ConversationFragment : val additionalScrollOffset = 54.dp if (isVisible) { - ViewUtil.animateIn(bottomActionBar, bottomActionBar.enterAnimation) - container.hideInput() - inputPanel.setHideForSelection(true) + bottomActionBar.visibility = View.INVISIBLE animationsAllowed = false - bottomActionBar.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { - override fun onPreDraw(): Boolean { - if (bottomActionBar.measuredHeight == 0 && bottomActionBar.visible) { - return false - } + bottomActionBar.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() { + bottomActionBar.viewTreeObserver.removeOnGlobalLayoutListener(this) - bottomActionBar.viewTreeObserver.removeOnPreDrawListener(this) + ViewUtil.animateIn(bottomActionBar, bottomActionBar.enterAnimation) + container.hideInput() + inputPanel.setHideForSelection(true) val bottomPadding = bottomActionBar.measuredHeight + ((bottomActionBar.layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 18.dp) ViewUtil.setPaddingBottom(binding.conversationItemRecycler, bottomPadding) binding.conversationItemRecycler.scrollBy(0, -(bottomPadding - additionalScrollOffset)) animationsAllowed = true - return false } }) } else {