Closes #16603: Disable pull down refresh when activity is in immersive mode (#16793)

upstream-sync
Roger Yang 4 years ago committed by GitHub
parent 0d85e50890
commit 26051f7c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -644,8 +644,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
.collect { tab -> pipModeChanged(tab) } .collect { tab -> pipModeChanged(tab) }
} }
view.swipeRefresh.isEnabled = view.swipeRefresh.isEnabled = shouldPullToRefreshBeEnabled()
FeatureFlags.pullToRefreshEnabled && context.settings().isPullToRefreshEnabledInBrowser
if (view.swipeRefresh.isEnabled) { if (view.swipeRefresh.isEnabled) {
val primaryTextColor = val primaryTextColor =
ThemeManager.resolveAttribute(R.attr.primaryText, context) ThemeManager.resolveAttribute(R.attr.primaryText, context)
@ -771,6 +771,13 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
browserToolbarView.expand() browserToolbarView.expand()
} }
@VisibleForTesting
internal fun shouldPullToRefreshBeEnabled(): Boolean {
return FeatureFlags.pullToRefreshEnabled &&
requireContext().settings().isPullToRefreshEnabledInBrowser &&
!(requireActivity() as HomeActivity).isImmersive
}
private fun initializeEngineView(toolbarHeight: Int) { private fun initializeEngineView(toolbarHeight: Int) {
val context = requireContext() val context = requireContext()

@ -38,6 +38,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.BrowserToolbarView import org.mozilla.fenix.components.toolbar.BrowserToolbarView
import org.mozilla.fenix.ext.application import org.mozilla.fenix.ext.application
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.onboarding.FenixOnboarding import org.mozilla.fenix.onboarding.FenixOnboarding
@ -284,6 +285,26 @@ class BrowserFragmentTest {
verify(exactly = 0) { onboarding.finish() } verify(exactly = 0) { onboarding.finish() }
} }
@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())
every { context.settings().isPullToRefreshEnabledInBrowser } returns false
assert(!browserFragment.shouldPullToRefreshBeEnabled())
}
@Test
fun `WHEN in immersive mode THEN pull down refresh is disabled`() {
every { homeActivity.isImmersive } returns false
every { context.settings().isPullToRefreshEnabledInBrowser } returns true
assert(browserFragment.shouldPullToRefreshBeEnabled())
every { homeActivity.isImmersive } returns true
assert(!browserFragment.shouldPullToRefreshBeEnabled())
}
private fun addAndSelectTab(tab: TabSessionState) { private fun addAndSelectTab(tab: TabSessionState) {
store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking()
store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking()

Loading…
Cancel
Save