Bug 1910687 - The long press CFR should point at the back button. r=android-reviewers,skhan

Differential Revision: https://phabricator.services.mozilla.com/D228068
This commit is contained in:
Aaditya Dhingra 2024-11-12 14:13:47 +00:00
parent 2221f4f249
commit b8468ee680
3 changed files with 18 additions and 1 deletions

View File

@ -38,6 +38,7 @@ import java.lang.ref.WeakReference
* @property indicatorArrowStartOffset Maximum distance between the popup start and the indicator arrow.
* If there isn't enough space this could automatically be overridden up to 0 such that
* the indicator arrow will be pointing to the middle of the anchor.
* @property popupStartOffset Maximum distance between the popup and anchor start.
*/
data class CFRPopupProperties(
val popupWidth: Dp = CFRPopup.DEFAULT_WIDTH.dp,
@ -51,6 +52,7 @@ data class CFRPopupProperties(
val overlapAnchor: Boolean = false,
val indicatorDirection: IndicatorDirection = IndicatorDirection.UP,
val indicatorArrowStartOffset: Dp = CFRPopup.DEFAULT_INDICATOR_START_OFFSET.dp,
val popupStartOffset: Dp = CFRPopup.DEFAULT_EXTRA_HORIZONTAL_PADDING.dp,
)
/**
@ -144,6 +146,11 @@ class CFRPopup(
*/
BODY_TO_ANCHOR_START,
/**
* The popup body will be shown aligned to exactly the anchor start with offset.
*/
BODY_TO_ANCHOR_START_WITH_OFFSET,
/**
* The popup will be aligned such that the indicator arrow will point to exactly the middle of the anchor.
* Recommended to be used when there are multiple widgets displayed horizontally so that this will allow

View File

@ -40,6 +40,7 @@ import mozilla.components.compose.cfr.CFRPopup.IndicatorDirection.UP
import mozilla.components.compose.cfr.CFRPopup.PopupAlignment.BODY_CENTERED_IN_SCREEN
import mozilla.components.compose.cfr.CFRPopup.PopupAlignment.BODY_TO_ANCHOR_CENTER
import mozilla.components.compose.cfr.CFRPopup.PopupAlignment.BODY_TO_ANCHOR_START
import mozilla.components.compose.cfr.CFRPopup.PopupAlignment.BODY_TO_ANCHOR_START_WITH_OFFSET
import mozilla.components.compose.cfr.CFRPopup.PopupAlignment.INDICATOR_CENTERED_IN_ANCHOR
import mozilla.components.compose.cfr.CFRPopupShape.Companion
import mozilla.components.compose.cfr.helper.DisplayOrientationListener
@ -313,6 +314,10 @@ internal class CFRPopupFullscreenLayout(
Pixels(anchor.x.roundToInt() + leftInsets.value)
}
BODY_TO_ANCHOR_START_WITH_OFFSET -> {
Pixels(anchor.x.roundToInt() + leftInsets.value + properties.popupStartOffset.toPx())
}
BODY_TO_ANCHOR_CENTER -> {
Pixels(
anchor.x.roundToInt()
@ -394,6 +399,9 @@ internal class CFRPopupFullscreenLayout(
BODY_TO_ANCHOR_START -> {
Pixels(anchor.x.roundToInt() + anchor.width + leftInsets.value)
}
BODY_TO_ANCHOR_START_WITH_OFFSET -> {
Pixels(anchor.x.roundToInt() + anchor.width + leftInsets.value + properties.popupStartOffset.toPx())
}
BODY_TO_ANCHOR_CENTER -> {
val anchorEndCoord = anchor.x.roundToInt() + anchor.width
Pixels(
@ -477,6 +485,7 @@ internal class CFRPopupFullscreenLayout(
): Pixels {
return when (properties.popupAlignment) {
BODY_TO_ANCHOR_START,
BODY_TO_ANCHOR_START_WITH_OFFSET,
BODY_TO_ANCHOR_CENTER,
-> Pixels(properties.indicatorArrowStartOffset.toPx())
BODY_CENTERED_IN_SCREEN,

View File

@ -241,7 +241,7 @@ import mozilla.components.ui.widgets.behavior.ToolbarPosition as OldToolbarPosit
import org.mozilla.fenix.GleanMetrics.TabStrip as TabStripMetrics
private const val NAVIGATION_CFR_VERTICAL_OFFSET = 10
private const val NAVIGATION_CFR_ARROW_OFFSET = 48
private const val NAVIGATION_CFR_ARROW_OFFSET = 24
private const val NAVIGATION_CFR_MAX_MS_BETWEEN_CLICKS = 5000
/**
@ -1586,6 +1586,7 @@ abstract class BaseBrowserFragment :
indicatorDirection = CFRPopup.IndicatorDirection.DOWN,
popupVerticalOffset = NAVIGATION_CFR_VERTICAL_OFFSET.dp,
indicatorArrowStartOffset = NAVIGATION_CFR_ARROW_OFFSET.dp,
popupAlignment = CFRPopup.PopupAlignment.BODY_TO_ANCHOR_START_WITH_OFFSET,
),
onCFRShown = {
NavigationBar.navigationButtonsCfrShown.record(NoExtras())