Bug 1875465 - Part 1: Set toolbar position if tablet

fenix/125.0
rahulsainani 5 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.DefaultBrowserToolbarController
import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarMenuController import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarMenuController
import org.mozilla.fenix.components.toolbar.ToolbarIntegration 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.BrowserToolbarInteractor
import org.mozilla.fenix.components.toolbar.interactor.DefaultBrowserToolbarInteractor import org.mozilla.fenix.components.toolbar.interactor.DefaultBrowserToolbarInteractor
import org.mozilla.fenix.crashes.CrashContentIntegration import org.mozilla.fenix.crashes.CrashContentIntegration
@ -463,7 +464,7 @@ abstract class BaseBrowserFragment :
toolbarInfo = FindInPageIntegration.ToolbarInfo( toolbarInfo = FindInPageIntegration.ToolbarInfo(
browserToolbarView.view, browserToolbarView.view,
!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled, !context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled,
!context.settings().shouldUseBottomToolbar, context.settings().toolbarPosition == ToolbarPosition.TOP,
), ),
), ),
owner = this, owner = this,
@ -820,7 +821,7 @@ abstract class BaseBrowserFragment :
browserStore = requireComponents.core.store, browserStore = requireComponents.core.store,
appStore = requireComponents.appStore, appStore = requireComponents.appStore,
toolbar = browserToolbarView.view, toolbar = browserToolbarView.view,
isToolbarPlacedAtTop = !context.settings().shouldUseBottomToolbar, isToolbarPlacedAtTop = context.settings().toolbarPosition == ToolbarPosition.TOP,
crashReporterView = binding.crashReporterView, crashReporterView = binding.crashReporterView,
components = requireComponents, components = requireComponents,
settings = context.settings(), settings = context.settings(),
@ -1155,10 +1156,9 @@ abstract class BaseBrowserFragment :
if (!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled) { if (!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled) {
getEngineView().setDynamicToolbarMaxHeight(toolbarHeight) getEngineView().setDynamicToolbarMaxHeight(toolbarHeight)
val toolbarPosition = if (context.settings().shouldUseBottomToolbar) { val toolbarPosition = when (context.settings().toolbarPosition) {
MozacToolbarPosition.BOTTOM ToolbarPosition.BOTTOM -> MozacToolbarPosition.BOTTOM
} else { ToolbarPosition.TOP -> MozacToolbarPosition.TOP
MozacToolbarPosition.TOP
} }
(getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams).behavior = (getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams).behavior =
EngineViewClippingBehavior( EngineViewClippingBehavior(
@ -1175,10 +1175,10 @@ abstract class BaseBrowserFragment :
// Effectively place the engineView on top/below of the toolbar if that is not dynamic. // Effectively place the engineView on top/below of the toolbar if that is not dynamic.
val swipeRefreshParams = val swipeRefreshParams =
getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams getSwipeRefreshLayout().layoutParams as CoordinatorLayout.LayoutParams
if (context.settings().shouldUseBottomToolbar) { if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
swipeRefreshParams.bottomMargin = toolbarHeight
} else {
swipeRefreshParams.topMargin = toolbarHeight 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.browser.thumbnails.loader.ThumbnailLoader
import mozilla.components.concept.base.images.ImageLoadRequest import mozilla.components.concept.base.images.ImageLoadRequest
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.databinding.TabPreviewBinding import org.mozilla.fenix.databinding.TabPreviewBinding
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
@ -34,7 +35,7 @@ class TabPreview @JvmOverloads constructor(
private val thumbnailLoader = ThumbnailLoader(context.components.core.thumbnailStorage) private val thumbnailLoader = ThumbnailLoader(context.components.core.thumbnailStorage)
init { init {
if (!context.settings().shouldUseBottomToolbar) { if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
binding.fakeToolbar.updateLayoutParams<LayoutParams> { binding.fakeToolbar.updateLayoutParams<LayoutParams> {
gravity = Gravity.TOP gravity = Gravity.TOP
} }
@ -59,7 +60,7 @@ class TabPreview @JvmOverloads constructor(
binding.tabButton.setCount(count) binding.tabButton.setCount(count)
} }
binding.previewThumbnail.translationY = if (!context.settings().shouldUseBottomToolbar) { binding.previewThumbnail.translationY = if (context.settings().toolbarPosition == ToolbarPosition.TOP) {
binding.fakeToolbar.height.toFloat() binding.fakeToolbar.height.toFloat()
} else { } else {
0f 0f

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

Loading…
Cancel
Save