From edb73b00c1e4b277db53218791850246d5bca10a Mon Sep 17 00:00:00 2001 From: "mike a." Date: Wed, 12 Jun 2024 06:15:54 +0000 Subject: [PATCH] Bug 1895573 - Fix showing display and edit mode at the same time r=android-reviewers,petru Differential Revision: https://phabricator.services.mozilla.com/D210501 --- .../org/mozilla/fenix/home/HomeFragment.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 62906426647e..d9d753d491b4 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -150,6 +150,7 @@ import org.mozilla.fenix.messaging.MessagingFeature import org.mozilla.fenix.microsurvey.ui.MicrosurveyRequestPrompt import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.perf.MarkersFragmentLifecycleCallbacks +import org.mozilla.fenix.search.SearchDialogFragment import org.mozilla.fenix.search.toolbar.DefaultSearchSelectorController import org.mozilla.fenix.search.toolbar.SearchSelectorMenu import org.mozilla.fenix.tabstray.Page @@ -512,7 +513,10 @@ class HomeFragment : Fragment() { } private fun reinitializeNavBar() { - initializeNavBar(activity = requireActivity() as HomeActivity) + initializeNavBar( + activity = requireActivity() as HomeActivity, + isConfigChange = true, + ) } override fun onConfigurationChanged(newConfig: Configuration) { @@ -556,7 +560,10 @@ class HomeFragment : Fragment() { IncompleteRedesignToolbarFeature(context.settings()).isEnabled && !context.isLandscape() && !isTablet() @Suppress("LongMethod") - private fun initializeNavBar(activity: HomeActivity) { + private fun initializeNavBar( + activity: HomeActivity, + isConfigChange: Boolean = false, + ) { val context = requireContext() val isToolbarAtBottom = isToolbarAtBottom(context) @@ -641,7 +648,14 @@ class HomeFragment : Fragment() { } } }, - ) + ).apply { + // When HomeFragment is initializing, SearchDialogFragment might already be visible. Navbar and search + // dialog positioned at bottom shouldn't be visible at the same time. + val searchFragmentAlreadyAdded = parentFragmentManager.fragments.any { it is SearchDialogFragment } + val searchFragmentShouldBeAdded = !isConfigChange && bundleArgs.getBoolean(FOCUS_ON_ADDRESS_BAR) + val shouldShowNavbar = !isToolbarAtBottom || !searchFragmentAlreadyAdded && !searchFragmentShouldBeAdded + composeView.isVisible = shouldShowNavbar + } bottomToolbarContainerIntegration.set( feature = BottomToolbarContainerIntegration(