From 43778cf3cb58aaac9a88db780a92b3d767b65636 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 24 Sep 2020 19:39:22 +0900 Subject: [PATCH] [fenix] Show undo snackbars with padding with static bottom toolbar This specifically fixes the close tab snackbar. This commit mirrors the logic when not using Undo from e14bf8e791aa56ded47812018f32ee9801a5b4f9. References https://github.com/mozilla-mobile/fenix/issues/14982. --- .../java/org/mozilla/fenix/browser/BaseBrowserFragment.kt | 1 + app/src/main/java/org/mozilla/fenix/utils/Undo.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 352fcc5226..9c6e9aa5d1 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -275,6 +275,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session { requireComponents.useCases.tabsUseCases.undo.invoke() }, + paddedForBottomToolbar = true, operation = { } ) } diff --git a/app/src/main/java/org/mozilla/fenix/utils/Undo.kt b/app/src/main/java/org/mozilla/fenix/utils/Undo.kt index 6dd272f5ad..7ba20701b6 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Undo.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Undo.kt @@ -60,6 +60,7 @@ fun CoroutineScope.allowUndo( // writing a volatile variable. val requestedUndo = AtomicBoolean(false) + @Suppress("ComplexCondition") fun showUndoSnackbar() { val snackbar = FenixSnackbar .make( @@ -82,6 +83,7 @@ fun CoroutineScope.allowUndo( val shouldUseBottomToolbar = view.context.settings().shouldUseBottomToolbar val toolbarHeight = view.resources.getDimensionPixelSize(R.dimen.browser_toolbar_height) + val dynamicToolbarEnabled = view.context.settings().isDynamicToolbarEnabled snackbar.view.updatePadding( bottom = if ( @@ -92,7 +94,7 @@ fun CoroutineScope.allowUndo( // can't intelligently position the snackbar on the upper most view. // Ideally we should not pass ContentFrameLayout in, but it's the only // way to display snackbars through a fragment transition. - view is ContentFrameLayout + (view is ContentFrameLayout || !dynamicToolbarEnabled) ) { toolbarHeight } else {