[fenix] For https://github.com/mozilla-mobile/fenix/issues/27511: Remove duplicate padding update code

This padding update is already performed in FenixSnackbar.make when
isDisplayedWithBrowserToolbar is true, and that variable has no other
side-effects, so simply use that code.
pull/600/head
Alexander Gramiak 2 years ago committed by mergify[bot]
parent 9c9c17b959
commit c67c455439

@ -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

Loading…
Cancel
Save