For #17899 - Expand toolbar when returning from fullscreen video

This was the previous behavior for both the top and bottom toolbars.
Regressed when changing to use a new custom behavior for the top toolbar.

When entering fullscreen we will now collapse and hide the toolbar, allow the
browser to expand to the entire screen estate and then, when exiting fullscreen
expand the toolbar.
Collapsing and then expanding the toolbar will trigger the
EngineViewBrowserToolbarBehavior to place the browser below the toolbar.
upstream-sync
Mugurell 3 years ago
parent 64f32b9d95
commit 6e0a64897b

@ -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()
}
}

@ -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()
}

@ -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) }
}
}

Loading…
Cancel
Save