@ -6,13 +6,10 @@ package org.mozilla.fenix.utils
import android.content.Context
import android.content.Context
import android.view.View
import android.view.View
import androidx.appcompat.widget.ContentFrameLayout
import androidx.core.view.updatePadding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.launch
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.settings
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicBoolean
@ -66,7 +63,7 @@ fun CoroutineScope.allowUndo(
. make (
. make (
view = view ,
view = view ,
duration = FenixSnackbar . LENGTH _INDEFINITE ,
duration = FenixSnackbar . LENGTH _INDEFINITE ,
isDisplayedWithBrowserToolbar = false ,
isDisplayedWithBrowserToolbar = paddedForBottomToolbar ,
)
)
. setText ( message )
. setText ( message )
. setAnchorView ( anchorView )
. setAnchorView ( anchorView )
@ -81,27 +78,6 @@ fun CoroutineScope.allowUndo(
snackbar . view . elevation = it
snackbar . view . elevation = it
}
}
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 (
paddedForBottomToolbar &&
shouldUseBottomToolbar &&
// If the view passed in is a ContentFrameLayout, it does not matter
// if the user has a dynamicBottomToolbar or not, as the Android system
// 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 || ! dynamicToolbarEnabled )
) {
toolbarHeight
} else {
0
} ,
)
snackbar . show ( )
snackbar . show ( )
// Wait a bit, and if user didn't request cancellation, proceed with
// Wait a bit, and if user didn't request cancellation, proceed with