For #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.
This commit is contained in:
Alexander Gramiak 2022-10-23 00:12:09 -06:00 committed by mergify[bot]
parent ac64ec9eff
commit 3c0aaa75c0
1 changed files with 1 additions and 25 deletions

View File

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