From baa112c4aedc732d348a5b0611f0a1e408407ae7 Mon Sep 17 00:00:00 2001 From: indu Date: Mon, 30 May 2022 18:19:26 +0530 Subject: [PATCH] For #12215 : Expand toolbar when url changes This fix allows the toolbar to be visible after the user clicks on a link and scrolls Co-Authored-By: Mugurell --- .../toolbar/ToolbarBehaviorController.kt | 2 +- .../toolbar/ToolbarBehaviorControllerTest.kt | 17 +++++++++++++++++ docs/changelog.md | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarBehaviorController.kt b/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarBehaviorController.kt index d0645522015..4b6e89f7744 100644 --- a/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarBehaviorController.kt +++ b/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarBehaviorController.kt @@ -7,7 +7,6 @@ package mozilla.components.feature.toolbar import androidx.annotation.VisibleForTesting import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.cancel -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.mapNotNull import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.selector.findCustomTabOrSelectedTab @@ -47,6 +46,7 @@ class ToolbarBehaviorController( } if (state.content.loading) { + expandToolbar() disableScrolling() } else if (!state.content.loading) { enableScrolling() diff --git a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarBehaviorControllerTest.kt b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarBehaviorControllerTest.kt index d6bdaafb730..1ee1133fe96 100644 --- a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarBehaviorControllerTest.kt +++ b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarBehaviorControllerTest.kt @@ -180,4 +180,21 @@ class ToolbarBehaviorControllerTest { verify(controller, never()).expandToolbar() } + + @Test + fun `GIVEN the current tab is loading an url WHEN the page is scrolled THEN expand toolbar`() { + val tabContent = ContentState("loading", loading = true) + val store = BrowserStore( + BrowserState( + tabs = listOf(TabSessionState("tab_1", tabContent)), + selectedTabId = "tab_1" + ) + ) + val controller = spy(ToolbarBehaviorController(mock(), store)) + + controller.start() + shadowOf(getMainLooper()).idle() + + verify(controller).expandToolbar() + } } diff --git a/docs/changelog.md b/docs/changelog.md index fcf9b0ec4ee..7232a3a3bce 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -66,6 +66,9 @@ permalink: /changelog/ * ⚠️ **This is a breaking change**: When constructing a `RemoteTabsStorage` object you must now a `Context` which is used to determine the location of the sqlite database which is used to persist the remote tabs [#11799](https://github.com/mozilla-mobile/android-components/pull/11799). * Fixed a low frequency crasher that might occur when the app attempts to delete all history. [#12112](https://github.com/mozilla-mobile/android-components/pull/12112) +* **browser-toolbar** + * Expand toolbar when url changes + [issue # 12215](https://github.com/mozilla-mobile/android-components/issues/12215#issuecomment-1141822240) * **feature-syncedtabs** * ⚠️ **This is a breaking change**: When constructing a `SyncedTabsStorage`, the `tabsStorage: RemoteTabsStorage` parameter is no longer optional so must be supplied [#11799](https://github.com/mozilla-mobile/android-components/pull/11799).