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 ec2dc2fb71..b8c4a6b504 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -668,7 +668,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, .collect { tab -> pipModeChanged(tab) } } - view.swipeRefresh.isEnabled = shouldPullToRefreshBeEnabled() + view.swipeRefresh.isEnabled = shouldPullToRefreshBeEnabled(false) if (view.swipeRefresh.isEnabled) { val primaryTextColor = @@ -798,10 +798,10 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, } @VisibleForTesting - internal fun shouldPullToRefreshBeEnabled(): Boolean { + internal fun shouldPullToRefreshBeEnabled(inFullScreen: Boolean): Boolean { return FeatureFlags.pullToRefreshEnabled && requireContext().settings().isPullToRefreshEnabledInBrowser && - !(requireActivity() as HomeActivity).isImmersive + !inFullScreen } private fun initializeEngineView(toolbarHeight: Int) { @@ -1229,6 +1229,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, initializeEngineView(toolbarHeight) } } + + activity?.swipeRefresh?.isEnabled = shouldPullToRefreshBeEnabled(inFullScreen) } /* diff --git a/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt index 9a0fc2e4b5..846569d683 100644 --- a/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt @@ -287,22 +287,18 @@ class BrowserFragmentTest { @Test fun `WHEN isPullToRefreshEnabledInBrowser is disabled THEN pull down refresh is disabled`() { - every { homeActivity.isImmersive } returns false every { context.settings().isPullToRefreshEnabledInBrowser } returns true - assert(browserFragment.shouldPullToRefreshBeEnabled()) + assert(browserFragment.shouldPullToRefreshBeEnabled(false)) every { context.settings().isPullToRefreshEnabledInBrowser } returns false - assert(!browserFragment.shouldPullToRefreshBeEnabled()) + assert(!browserFragment.shouldPullToRefreshBeEnabled(false)) } @Test - fun `WHEN in immersive mode THEN pull down refresh is disabled`() { - every { homeActivity.isImmersive } returns false + fun `WHEN in fullscreen THEN pull down refresh is disabled`() { every { context.settings().isPullToRefreshEnabledInBrowser } returns true - assert(browserFragment.shouldPullToRefreshBeEnabled()) - - every { homeActivity.isImmersive } returns true - assert(!browserFragment.shouldPullToRefreshBeEnabled()) + assert(browserFragment.shouldPullToRefreshBeEnabled(false)) + assert(!browserFragment.shouldPullToRefreshBeEnabled(true)) } private fun addAndSelectTab(tab: TabSessionState) {