Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3baad21 authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Move the window inset out of composition for the tooltip positioning

Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Bug: 426039077
Test: manually - expanding QS to trigger the tooltip
Change-Id: I848e0b830c40e19adaeee5196ea291ae0d1dbfac
parent 0bb87e65
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -178,13 +178,9 @@ private fun rememberTooltipPositionProvider(
    windowInsets: WindowInsets,
    spacingBetweenTooltipAndAnchor: Dp = SpacingBetweenTooltipAndAnchor,
): PopupPositionProvider {
    // We grab the top window inset and remove it manually from the position as it is not consumed
    // in the QS panel (b/424438896)
    val topInset = windowInsets.getTop(LocalDensity.current)

    val tooltipAnchorSpacing =
        with(LocalDensity.current) { spacingBetweenTooltipAndAnchor.roundToPx() }
    return remember(tooltipAnchorSpacing, topInset) {
    val density = LocalDensity.current
    val tooltipAnchorSpacing = with(density) { spacingBetweenTooltipAndAnchor.roundToPx() }
    return remember(tooltipAnchorSpacing, windowInsets, density) {
        object : PopupPositionProvider {
            override fun calculatePosition(
                anchorBounds: IntRect,
@@ -208,6 +204,11 @@ private fun rememberTooltipPositionProvider(
                    x = anchorBounds.right - popupContentSize.width
                }

                // We grab the top window inset and remove it manually from the position as it is
                // not consumed
                // in the QS panel (b/424438896)
                val topInset = windowInsets.getTop(density)

                // Tooltip prefers to be below the anchor,
                // but if this causes the tooltip to be outside the window
                // then we place it above the anchor