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

Commit 0b24137d authored by Chris Göllner's avatar Chris Göllner Committed by Android (Google) Code Review
Browse files

Merge "Fix status bar content not being vertically centered on external display" into main

parents 5441cd4e 2ba0baa9
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -720,6 +720,27 @@ class StatusBarContentInsetsProviderTest : SysuiTestCase() {
        assertThat(bounds.top).isEqualTo(expectedTopInset)
    }

    @Test
    fun calculateInsetsForRotationWithRotatedResources_bottomAlignedMargin_noCutout_topIsZero() {
        val bounds =
            calculateInsetsForRotationWithRotatedResources(
                currentRotation = ROTATION_NONE,
                targetRotation = ROTATION_NONE,
                sysUICutout = null,
                maxBounds = Rect(0, 0, 1080, 2160),
                statusBarHeight = 100,
                minLeft = 0,
                minRight = 0,
                isRtl = false,
                dotWidth = 10,
                bottomAlignedMargin = 5,
                statusBarContentHeight = 15,
            )

        // Bottom aligned margin should only be take into account for displays with a cutout.
        assertThat(bounds.top).isEqualTo(0)
    }

    @Test
    fun testCalculateInsetsForRotationWithRotatedResources_nonCornerCutout() {
        // GIVEN phone in portrait mode, where width < height and the cutout is not in the corner
+5 −2
Original line number Diff line number Diff line
@@ -573,7 +573,7 @@ private fun getStatusBarContentBounds(
    bottomAlignedMargin: Int,
    statusBarContentHeight: Int,
): Rect {
    val insetTop = getInsetTop(bottomAlignedMargin, statusBarContentHeight, sbHeight)
    val insetTop = getInsetTop(bottomAlignedMargin, statusBarContentHeight, sbHeight, sysUICutout)

    val logicalDisplayWidth = if (targetRotation.isHorizontal()) height else width

@@ -666,8 +666,11 @@ private fun getInsetTop(
    bottomAlignedMargin: Int,
    statusBarContentHeight: Int,
    statusBarHeight: Int,
    sysUICutout: SysUICutoutInformation?,
): Int {
    val bottomAlignmentEnabled = bottomAlignedMargin >= 0
    // This bottom aligned margin is only intended for displays with a cutout, so that the
    // content can be aligned with the cutout, when it isn't centered.
    val bottomAlignmentEnabled = bottomAlignedMargin >= 0 && sysUICutout != null
    if (!bottomAlignmentEnabled) {
        return 0
    }