diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 19644bf42..3718b2dfe 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -1220,6 +1220,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit .setText(getString(R.string.full_screen_notification)) .show() activity?.enterToImmersiveMode() + browserToolbarView.collapse() browserToolbarView.view.isVisible = false val browserEngine = swipeRefresh.layoutParams as CoordinatorLayout.LayoutParams browserEngine.bottomMargin = 0 @@ -1227,7 +1228,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit swipeRefresh.translationY = 0f engineView.setDynamicToolbarMaxHeight(0) - browserToolbarView.expand() // Without this, fullscreen has a margin at the top. engineView.setVerticalClipping(0) @@ -1241,6 +1241,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit browserToolbarView.view.isVisible = true val toolbarHeight = resources.getDimensionPixelSize(R.dimen.browser_toolbar_height) initializeEngineView(toolbarHeight) + browserToolbarView.expand() } } diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt index d8e7e306f..1b25af105 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt @@ -215,6 +215,17 @@ class BrowserToolbarView( } } + fun collapse() { + // collapse only for normal tabs and custom tabs not for PWA or TWA. Mirror expand() + if (isPwaTabOrTwaTab) { + return + } + + (view.layoutParams as? CoordinatorLayout.LayoutParams)?.apply { + (behavior as? BrowserToolbarBehavior)?.forceCollapse(view) + } + } + fun dismissMenu() { view.dismissMenu() } diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarViewTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarViewTest.kt index f75b1d448..df34475e5 100644 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarViewTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarViewTest.kt @@ -5,6 +5,7 @@ package org.mozilla.fenix.components.toolbar import androidx.coordinatorlayout.widget.CoordinatorLayout +import io.mockk.confirmVerified import io.mockk.every import io.mockk.mockk @@ -193,4 +194,50 @@ class BrowserToolbarViewTest { assertNotNull((toolbar.layoutParams as CoordinatorLayout.LayoutParams).behavior) } + + @Test + fun `expand should not do anything if isPwaTabOrTwaTab`() { + val toolbarViewSpy = spyk(toolbarView) + every { toolbarViewSpy.isPwaTabOrTwaTab } returns true + + toolbarViewSpy.expand() + + verify { toolbarViewSpy.expand() } + verify { toolbarViewSpy.isPwaTabOrTwaTab } + // verify that no other interactions than the expected ones took place + confirmVerified(toolbarViewSpy) + } + + @Test + fun `expand should call forceExpand if not isPwaTabOrTwaTab`() { + val toolbarViewSpy = spyk(toolbarView) + every { toolbarViewSpy.isPwaTabOrTwaTab } returns false + + toolbarViewSpy.expand() + + verify { behavior.forceExpand(toolbar) } + } + + @Test + fun `collapse should not do anything if isPwaTabOrTwaTab`() { + val toolbarViewSpy = spyk(toolbarView) + every { toolbarViewSpy.isPwaTabOrTwaTab } returns true + + toolbarViewSpy.collapse() + + verify { toolbarViewSpy.collapse() } + verify { toolbarViewSpy.isPwaTabOrTwaTab } + // verify that no other interactions than the expected ones took place + confirmVerified(toolbarViewSpy) + } + + @Test + fun `collapse should call forceExpand if not isPwaTabOrTwaTab`() { + val toolbarViewSpy = spyk(toolbarView) + every { toolbarViewSpy.isPwaTabOrTwaTab } returns false + + toolbarViewSpy.collapse() + + verify { behavior.forceCollapse(toolbar) } + } }