From f7152b81b0910ef0399b7deed8eb3759ae3a8ebb Mon Sep 17 00:00:00 2001 From: Ionut Cristian Bedregeanu Date: Tue, 23 Nov 2021 13:43:10 +0200 Subject: [PATCH] For #5884 - Use the correct value of toolbar height at dynamic behavior --- .../java/org/mozilla/focus/ext/BrowserToolbar.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/mozilla/focus/ext/BrowserToolbar.kt b/app/src/main/java/org/mozilla/focus/ext/BrowserToolbar.kt index 586f76acf5a..3d8040eea6b 100644 --- a/app/src/main/java/org/mozilla/focus/ext/BrowserToolbar.kt +++ b/app/src/main/java/org/mozilla/focus/ext/BrowserToolbar.kt @@ -9,10 +9,11 @@ import android.view.View import androidx.coordinatorlayout.widget.CoordinatorLayout import mozilla.components.browser.toolbar.BrowserToolbar import mozilla.components.browser.toolbar.behavior.BrowserToolbarBehavior -import mozilla.components.browser.toolbar.behavior.ToolbarPosition import mozilla.components.concept.engine.EngineView import mozilla.components.feature.session.behavior.EngineViewBrowserToolbarBehavior import org.mozilla.focus.R +import mozilla.components.browser.toolbar.behavior.ToolbarPosition as browserToolbarPosition +import mozilla.components.feature.session.behavior.ToolbarPosition as engineToolbarPosition /** * Collapse the toolbar and block it from appearing until calling [enableDynamicBehavior]. @@ -38,15 +39,19 @@ fun BrowserToolbar.disableDynamicBehavior(engineView: EngineView) { */ fun BrowserToolbar.enableDynamicBehavior(context: Context, engineView: EngineView) { (layoutParams as? CoordinatorLayout.LayoutParams)?.behavior = BrowserToolbarBehavior( - context, null, ToolbarPosition.TOP + context, null, browserToolbarPosition.TOP ) - engineView.setDynamicToolbarMaxHeight(height) + val toolbarHeight = context.resources.getDimension(R.dimen.browser_toolbar_height).toInt() + engineView.setDynamicToolbarMaxHeight(toolbarHeight) (engineView.asView().layoutParams as? CoordinatorLayout.LayoutParams)?.apply { topMargin = 0 behavior = EngineViewBrowserToolbarBehavior( - context, null, engineView.asView(), context.resources.getDimension(R.dimen.browser_toolbar_height).toInt(), - mozilla.components.feature.session.behavior.ToolbarPosition.TOP + context, + null, + engineView.asView(), + toolbarHeight, + engineToolbarPosition.TOP ) } }