Bug 1875465 - Part 1: Set toolbar position if tablet

fenix/125.0
rahulsainani 4 months ago committed by mergify[bot]
parent 398071e988
commit 8a32c516df

@ -134,6 +134,7 @@ import org.mozilla.fenix.components.toolbar.BrowserToolbarView
import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarController
import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarMenuController
import org.mozilla.fenix.components.toolbar.ToolbarIntegration
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.components.toolbar.interactor.BrowserToolbarInteractor
import org.mozilla.fenix.components.toolbar.interactor.DefaultBrowserToolbarInteractor
import org.mozilla.fenix.crashes.CrashContentIntegration
@ -463,7 +464,7 @@ abstract class BaseBrowserFragment :
toolbarInfo = FindInPageIntegration.ToolbarInfo(
browserToolbarView.view,
!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled,
!context.settings().shouldUseBottomToolbar,
context.settings().toolbarPosition == ToolbarPosition.TOP,
),
),
owner = this,
@ -820,7 +821,7 @@ abstract class BaseBrowserFragment :
browserStore = requireComponents.core.store,
appStore = requireComponents.appStore,
toolbar = browserToolbarView.view,
isToolbarPlacedAtTop = !context.settings().shouldUseBottomToolbar,
isToolbarPlacedAtTop = context.settings().toolbarPosition == ToolbarPosition.TOP,
crashReporterView = binding.crashReporterView,
components = requireComponents,
settings = context.settings(),
@ -1155,10 +1156,9 @@ abstract class BaseBrowserFragment :
if (!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled) {
getEngineView().setDynamicToolbarMaxHeight(toolbarHeight)
val toolbarPosition = if (context.settings().shouldUseBottomToolbar) {
MozacToolbarPosition.BOTTOM
} else {
MozacToolbarPosition.TOP
val toolbarPosition = when (context.settings().toolbarPosition) {
ToolbarPosition.BOTTOM -> MozacToolbarPosition.BOTTOM
ToolbarPosition.TOP -> MozacToolbarPosition.TOP
}
(getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams).behavior =
EngineViewClippingBehavior(
@ -1175,10 +1175,10 @@ abstract class BaseBrowserFragment :
// Effectively place the engineView on top/below of the toolbar if that is not dynamic.
val swipeRefreshParams =
getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams
if (context.settings().shouldUseBottomToolbar) {
swipeRefreshParams.bottomMargin = toolbarHeight
} else {
if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
swipeRefreshParams.topMargin = toolbarHeight
} else {
swipeRefreshParams.bottomMargin = toolbarHeight
}
}
}

@ -18,6 +18,7 @@ import mozilla.components.browser.state.selector.selectedTab
import mozilla.components.browser.thumbnails.loader.ThumbnailLoader
import mozilla.components.concept.base.images.ImageLoadRequest
import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.databinding.TabPreviewBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
@ -34,7 +35,7 @@ class TabPreview @JvmOverloads constructor(
private val thumbnailLoader = ThumbnailLoader(context.components.core.thumbnailStorage)
init {
if (!context.settings().shouldUseBottomToolbar) {
if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
binding.fakeToolbar.updateLayoutParams<LayoutParams> {
gravity = Gravity.TOP
}
@ -59,7 +60,7 @@ class TabPreview @JvmOverloads constructor(
binding.tabButton.setCount(count)
}
binding.previewThumbnail.translationY = if (!context.settings().shouldUseBottomToolbar) {
binding.previewThumbnail.translationY = if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
binding.fakeToolbar.height.toFloat()
} else {
0f

@ -854,6 +854,9 @@ class Settings(private val appContext: Context) : PreferencesHolder {
return touchExplorationIsEnabled || switchServiceIsEnabled
}
private val isTablet: Boolean
get() = appContext.resources.getBoolean(R.bool.tablet)
var lastKnownMode: BrowsingMode = BrowsingMode.Normal
get() {
val lastKnownModeWasPrivate = preferences.getBoolean(
@ -922,7 +925,13 @@ class Settings(private val appContext: Context) : PreferencesHolder {
)
val toolbarPosition: ToolbarPosition
get() = if (shouldUseBottomToolbar) ToolbarPosition.BOTTOM else ToolbarPosition.TOP
get() = if (isTablet) {
ToolbarPosition.TOP
} else if (shouldUseBottomToolbar) {
ToolbarPosition.BOTTOM
} else {
ToolbarPosition.TOP
}
/**
* Check each active accessibility service to see if it can perform gestures, if any can,

Loading…
Cancel
Save