For #2315: Hides URL bar when scrolling in custom tab (#2485)

nightly-build-test
Sawyer Blatz 5 years ago committed by Jeff Boek
parent e0e7ba5a43
commit 03ca975795

@ -6,6 +6,7 @@ package org.mozilla.fenix.customtabs
import android.app.Activity
import android.content.Context
import com.google.android.material.appbar.AppBarLayout
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.feature.customtabs.CustomTabsToolbarFeature
@ -22,6 +23,10 @@ class CustomTabsIntegration(
onItemTapped: (ToolbarMenu.Item) -> Unit = {}
) : LifecycleAwareFeature, BackHandler {
init {
enableToolbarCollapse()
}
private val customTabToolbarMenu by lazy {
CustomTabToolbarMenu(
context,
@ -51,7 +56,16 @@ class CustomTabsIntegration(
return feature.onBackPressed()
}
private fun enableToolbarCollapse() {
val params = toolbar.layoutParams as AppBarLayout.LayoutParams
params.scrollFlags = DEFAULT_SCROLL_FLAGS
}
companion object {
const val DEFAULT_SCROLL_FLAGS = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or
AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS or
AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP or
AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
const val START_OF_MENU_ITEMS_INDEX = 2
}
}

Loading…
Cancel
Save