For #4383: Add feature flag
parent
009a7f3020
commit
13c9c39658
|
@ -44,6 +44,11 @@ object FeatureFlags {
|
||||||
*/
|
*/
|
||||||
const val asFeatureFxAPairingDisabled = false
|
const val asFeatureFxAPairingDisabled = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables dynamic bottom toolbar
|
||||||
|
*/
|
||||||
|
val dynamicBottomToolbar = Config.channel.isNightlyOrDebug
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the new language picker
|
* Enables the new language picker
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -389,17 +389,23 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
activity?.enterToImmersiveMode()
|
activity?.enterToImmersiveMode()
|
||||||
browserToolbarView.view.visibility = View.GONE
|
browserToolbarView.view.visibility = View.GONE
|
||||||
|
|
||||||
// TODO We need to call force expand here to update verticalClipping #8697
|
if (FeatureFlags.dynamicBottomToolbar) {
|
||||||
// Without this, fullscreen has a margin at the top.
|
engineView.setDynamicToolbarMaxHeight(0)
|
||||||
engineView.setVerticalClipping(0)
|
// TODO We need to call force expand here to update verticalClipping #8697
|
||||||
|
// Without this, fullscreen has a margin at the top.
|
||||||
|
engineView.setVerticalClipping(0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activity?.exitImmersiveModeIfNeeded()
|
activity?.exitImmersiveModeIfNeeded()
|
||||||
(activity as? HomeActivity)?.let { activity ->
|
(activity as? HomeActivity)?.let { activity ->
|
||||||
activity.themeManager.applyStatusBarTheme(activity)
|
activity.themeManager.applyStatusBarTheme(activity)
|
||||||
}
|
}
|
||||||
browserToolbarView.view.visibility = View.VISIBLE
|
browserToolbarView.view.visibility = View.VISIBLE
|
||||||
engineView.setDynamicToolbarMaxHeight(toolbarHeight)
|
if (FeatureFlags.dynamicBottomToolbar) {
|
||||||
|
engineView.setDynamicToolbarMaxHeight(toolbarHeight)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!FeatureFlags.dynamicBottomToolbar) { updateLayoutMargins(inFullScreen) }
|
||||||
},
|
},
|
||||||
owner = this,
|
owner = this,
|
||||||
view = view
|
view = view
|
||||||
|
@ -461,15 +467,21 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initializeEngineView(toolbarHeight: Int) {
|
private fun initializeEngineView(toolbarHeight: Int) {
|
||||||
engineView.setDynamicToolbarMaxHeight(toolbarHeight)
|
if (FeatureFlags.dynamicBottomToolbar) {
|
||||||
|
engineView.setDynamicToolbarMaxHeight(toolbarHeight)
|
||||||
|
|
||||||
val behavior = if (requireContext().settings().shouldUseBottomToolbar) {
|
val behavior = if (requireContext().settings().shouldUseBottomToolbar) {
|
||||||
EngineViewBottomBehavior(context, null)
|
EngineViewBottomBehavior(context, null)
|
||||||
|
} else {
|
||||||
|
AppBarLayout.ScrollingViewBehavior(context, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
(swipeRefresh.layoutParams as CoordinatorLayout.LayoutParams).behavior = behavior
|
||||||
} else {
|
} else {
|
||||||
AppBarLayout.ScrollingViewBehavior(context, null)
|
if (!requireContext().settings().shouldUseBottomToolbar) {
|
||||||
|
engineView.setDynamicToolbarMaxHeight(toolbarHeight)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(swipeRefresh.layoutParams as CoordinatorLayout.LayoutParams).behavior = behavior
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,7 +504,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
// If the bitmap is null, the best we can do to reduce the flash is set transparent
|
// If the bitmap is null, the best we can do to reduce the flash is set transparent
|
||||||
swipeRefresh.background = bitmap?.toDrawable(it.resources)
|
swipeRefresh.background = bitmap?.toDrawable(it.resources)
|
||||||
?: ColorDrawable(Color.TRANSPARENT)
|
?: ColorDrawable(Color.TRANSPARENT)
|
||||||
|
|
||||||
engineView.asView().visibility = View.GONE
|
engineView.asView().visibility = View.GONE
|
||||||
findNavController().nav(R.id.browserFragment, directions)
|
findNavController().nav(R.id.browserFragment, directions)
|
||||||
}
|
}
|
||||||
|
@ -629,12 +641,35 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||||
|
|
||||||
protected abstract fun navToTrackingProtectionPanel(session: Session)
|
protected abstract fun navToTrackingProtectionPanel(session: Session)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the top and bottom margins.
|
||||||
|
*/
|
||||||
|
private fun getEngineMargins(): Pair<Int, Int> =
|
||||||
|
if (context?.settings()?.shouldUseBottomToolbar == true) {
|
||||||
|
val toolbarSize = resources.getDimensionPixelSize(R.dimen.browser_toolbar_height)
|
||||||
|
0 to toolbarSize
|
||||||
|
} else {
|
||||||
|
0 to 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the layout [android.view.Gravity] for the quick settings and ETP dialog.
|
* Returns the layout [android.view.Gravity] for the quick settings and ETP dialog.
|
||||||
*/
|
*/
|
||||||
protected fun getAppropriateLayoutGravity(): Int =
|
protected fun getAppropriateLayoutGravity(): Int =
|
||||||
if (context?.settings()?.shouldUseBottomToolbar == true) Gravity.BOTTOM else Gravity.TOP
|
if (context?.settings()?.shouldUseBottomToolbar == true) Gravity.BOTTOM else Gravity.TOP
|
||||||
|
|
||||||
|
protected fun updateLayoutMargins(inFullScreen: Boolean) {
|
||||||
|
view?.swipeRefresh?.apply {
|
||||||
|
val (topMargin, bottomMargin) = if (inFullScreen) 0 to 0 else getEngineMargins()
|
||||||
|
(layoutParams as CoordinatorLayout.LayoutParams).setMargins(
|
||||||
|
0,
|
||||||
|
topMargin,
|
||||||
|
0,
|
||||||
|
bottomMargin
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the site permissions rules based on user settings.
|
* Updates the site permissions rules based on user settings.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,8 +9,10 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.transition.TransitionInflater
|
import androidx.transition.TransitionInflater
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import kotlinx.android.synthetic.main.fragment_browser.*
|
||||||
import kotlinx.android.synthetic.main.fragment_browser.view.*
|
import kotlinx.android.synthetic.main.fragment_browser.view.*
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
|
@ -24,6 +26,7 @@ import mozilla.components.feature.tabs.WindowFeature
|
||||||
import mozilla.components.lib.state.ext.consumeFrom
|
import mozilla.components.lib.state.ext.consumeFrom
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.FenixSnackbar
|
import org.mozilla.fenix.components.FenixSnackbar
|
||||||
|
@ -126,6 +129,16 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateEngineBottomMargin() {
|
private fun updateEngineBottomMargin() {
|
||||||
|
if (!FeatureFlags.dynamicBottomToolbar) {
|
||||||
|
val browserEngine = swipeRefresh.layoutParams as CoordinatorLayout.LayoutParams
|
||||||
|
|
||||||
|
browserEngine.bottomMargin = if (requireContext().settings().shouldUseBottomToolbar) {
|
||||||
|
requireContext().resources.getDimensionPixelSize(R.dimen.browser_toolbar_height)
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val toolbarSessionObserver = TrackingProtectionOverlay(
|
val toolbarSessionObserver = TrackingProtectionOverlay(
|
||||||
context = requireContext(),
|
context = requireContext(),
|
||||||
settings = requireContext().settings()
|
settings = requireContext().settings()
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
package org.mozilla.fenix.customtabs
|
package org.mozilla.fenix.customtabs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||||
|
@ -12,6 +14,7 @@ import mozilla.components.browser.toolbar.display.DisplayToolbar
|
||||||
import mozilla.components.feature.customtabs.CustomTabsToolbarFeature
|
import mozilla.components.feature.customtabs.CustomTabsToolbarFeature
|
||||||
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.toolbar.ToolbarMenu
|
import org.mozilla.fenix.components.toolbar.ToolbarMenu
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
@ -21,6 +24,7 @@ class CustomTabsIntegration(
|
||||||
toolbar: BrowserToolbar,
|
toolbar: BrowserToolbar,
|
||||||
sessionId: String,
|
sessionId: String,
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
engineLayout: View,
|
||||||
onItemTapped: (ToolbarMenu.Item) -> Unit = {},
|
onItemTapped: (ToolbarMenu.Item) -> Unit = {},
|
||||||
shouldReverseItems: Boolean,
|
shouldReverseItems: Boolean,
|
||||||
isPrivate: Boolean
|
isPrivate: Boolean
|
||||||
|
@ -30,6 +34,16 @@ class CustomTabsIntegration(
|
||||||
// Remove toolbar shadow
|
// Remove toolbar shadow
|
||||||
toolbar.elevation = 0f
|
toolbar.elevation = 0f
|
||||||
|
|
||||||
|
if (!FeatureFlags.dynamicBottomToolbar) {
|
||||||
|
// Reduce margin height of EngineView from the top for the toolbar
|
||||||
|
engineLayout.run {
|
||||||
|
(layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||||
|
val toolbarHeight = resources.getDimension(R.dimen.browser_toolbar_height).toInt()
|
||||||
|
setMargins(0, toolbarHeight, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val uncoloredEtpShield = AppCompatResources.getDrawable(
|
val uncoloredEtpShield = AppCompatResources.getDrawable(
|
||||||
activity,
|
activity,
|
||||||
R.drawable.ic_tracking_protection_enabled
|
R.drawable.ic_tracking_protection_enabled
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import kotlinx.android.synthetic.main.component_browser_top_toolbar.*
|
import kotlinx.android.synthetic.main.component_browser_top_toolbar.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_browser.view.*
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.concept.engine.manifest.WebAppManifestParser
|
import mozilla.components.concept.engine.manifest.WebAppManifestParser
|
||||||
|
@ -26,6 +27,7 @@ import mozilla.components.lib.state.ext.consumeFrom
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
|
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.browser.BaseBrowserFragment
|
import org.mozilla.fenix.browser.BaseBrowserFragment
|
||||||
|
@ -66,6 +68,7 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
|
||||||
toolbar = toolbar,
|
toolbar = toolbar,
|
||||||
sessionId = customTabSessionId,
|
sessionId = customTabSessionId,
|
||||||
activity = activity,
|
activity = activity,
|
||||||
|
engineLayout = view.swipeRefresh,
|
||||||
onItemTapped = { browserInteractor.onBrowserToolbarMenuItemTapped(it) },
|
onItemTapped = { browserInteractor.onBrowserToolbarMenuItemTapped(it) },
|
||||||
isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate,
|
isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate,
|
||||||
shouldReverseItems = !activity.settings().shouldUseBottomToolbar
|
shouldReverseItems = !activity.settings().shouldUseBottomToolbar
|
||||||
|
@ -90,7 +93,8 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
|
||||||
toolbar,
|
toolbar,
|
||||||
customTabSessionId,
|
customTabSessionId,
|
||||||
trustedScopes
|
trustedScopes
|
||||||
) {
|
) { toolbarVisible ->
|
||||||
|
if (!FeatureFlags.dynamicBottomToolbar) { updateLayoutMargins(inFullScreen = !toolbarVisible) }
|
||||||
},
|
},
|
||||||
owner = this,
|
owner = this,
|
||||||
view = toolbar
|
view = toolbar
|
||||||
|
|
|
@ -25,6 +25,7 @@ import mozilla.components.browser.toolbar.behavior.BrowserToolbarBottomBehavior
|
||||||
import mozilla.components.concept.storage.HistoryStorage
|
import mozilla.components.concept.storage.HistoryStorage
|
||||||
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
|
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
|
||||||
import mozilla.components.support.ktx.android.util.dpToPx
|
import mozilla.components.support.ktx.android.util.dpToPx
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.getColorFromAttr
|
import org.mozilla.fenix.ext.getColorFromAttr
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
@ -181,11 +182,12 @@ class ToolbarView(
|
||||||
fun BrowserToolbar.setScrollFlagsForTopToolbar() {
|
fun BrowserToolbar.setScrollFlagsForTopToolbar() {
|
||||||
// Don't set scroll flags for bottom toolbar
|
// Don't set scroll flags for bottom toolbar
|
||||||
if (context.settings().shouldUseBottomToolbar) {
|
if (context.settings().shouldUseBottomToolbar) {
|
||||||
if (layoutParams is CoordinatorLayout.LayoutParams) {
|
if (FeatureFlags.dynamicBottomToolbar && layoutParams is CoordinatorLayout.LayoutParams) {
|
||||||
(layoutParams as CoordinatorLayout.LayoutParams).apply {
|
(layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||||
behavior = BrowserToolbarBottomBehavior(context, null)
|
behavior = BrowserToolbarBottomBehavior(context, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ class Settings private constructor(
|
||||||
companion object {
|
companion object {
|
||||||
const val showLoginsSecureWarningSyncMaxCount = 1
|
const val showLoginsSecureWarningSyncMaxCount = 1
|
||||||
const val showLoginsSecureWarningMaxCount = 1
|
const val showLoginsSecureWarningMaxCount = 1
|
||||||
const val autoBounceMaximumCount = 2
|
|
||||||
const val trackingProtectionOnboardingMaximumCount = 2
|
const val trackingProtectionOnboardingMaximumCount = 2
|
||||||
const val FENIX_PREFERENCES = "fenix_preferences"
|
const val FENIX_PREFERENCES = "fenix_preferences"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
android:id="@+id/swipeRefresh"
|
android:id="@+id/swipeRefresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="mozilla.components.feature.session.behavior.EngineViewBottomBehavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
<mozilla.components.concept.engine.EngineView
|
<mozilla.components.concept.engine.EngineView
|
||||||
android:id="@+id/engineView"
|
android:id="@+id/engineView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue