Skip to content

Commit

Permalink
Show undo snackbars with padding with static bottom toolbar
Browse files Browse the repository at this point in the history
This specifically fixes the close tab snackbar.  This commit mirrors
the logic when not using Undo from
9e876eb.  References mozilla-mobile#14982.
  • Loading branch information
gaul authored and pocmo committed Sep 29, 2020
1 parent 01e802f commit cfbad1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
{
requireComponents.useCases.tabsUseCases.undo.invoke()
},
paddedForBottomToolbar = true,
operation = { }
)
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/org/mozilla/fenix/utils/Undo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fun CoroutineScope.allowUndo(
// writing a volatile variable.
val requestedUndo = AtomicBoolean(false)

@Suppress("ComplexCondition")
fun showUndoSnackbar() {
val snackbar = FenixSnackbar
.make(
Expand All @@ -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 (
Expand All @@ -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 {
Expand Down

0 comments on commit cfbad1d

Please sign in to comment.