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

Commit f16289fd authored by András Kurucz's avatar András Kurucz
Browse files

[Flexiglass] Fix the height of HUNs in QuickSettings

HUNs had a negative height, when they were displayed in the
QuickSettings, because we've calculated it wrong.

Bug: 339181697
Test: check the height of HUNs in QuickSettings
Test: atest StackScrollAlgorithmTest
Flag: com.android.systemui.scene_container
Change-Id: I853be7d7c367b957f28d3a999f75d8207737221d
parent 95fad256
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1066,7 +1066,7 @@ public class StackScrollAlgorithm {
    private void clampHunToMaxTranslation(float headsUpTop, float headsUpBottom,
            ExpandableViewState viewState) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        final float maxHeight = headsUpTop - headsUpBottom;
        final float maxHeight = Math.max(0f, headsUpBottom - headsUpTop);
        viewState.setYTranslation(Math.min(headsUpTop, viewState.getYTranslation()));
        viewState.height = (int) Math.min(maxHeight, viewState.height);
    }
+12 −3
Original line number Diff line number Diff line
@@ -279,16 +279,23 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
    fun resetViewStates_defaultHun_showingQS_hunTranslatedToHeadsUpTop() {
        // Given: the shade is open and scrolled to the bottom to show the QuickSettings
        val headsUpTop = 2000f
        val intrinsicHunHeight = 300
        fakeHunInShade(
            headsUpTop = headsUpTop,
            stackTop = 2600f, // stack scrolled below the screen
            stackCutoff = 4000f,
            collapsedHeight = 100,
            intrinsicHeight = 300
            intrinsicHeight = intrinsicHunHeight,
        )
        whenever(notificationRow.isAboveShelf).thenReturn(true)

        resetViewStates_hunYTranslationIs(headsUpTop)
        // When
        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        // Then: HUN is translated to the headsUpTop
        assertThat(notificationRow.viewState.yTranslation).isEqualTo(headsUpTop)
        // And: HUN maintained its full height
        assertThat(notificationRow.viewState.height).isEqualTo(intrinsicHunHeight)
    }

    @Test
@@ -1419,14 +1426,16 @@ class StackScrollAlgorithmTest : SysuiTestCase() {

    /** fakes the notification row under test, to be a HUN in a fully opened shade */
    private fun fakeHunInShade(
        headsUpTop: Float,
        collapsedHeight: Int,
        intrinsicHeight: Int,
        headsUpTop: Float,
        headsUpBottom: Float = headsUpTop + intrinsicHeight, // assume all the space available
        stackTop: Float,
        stackCutoff: Float = 2000f,
        fullStackHeight: Float = 3000f
    ) {
        ambientState.headsUpTop = headsUpTop
        ambientState.headsUpBottom = headsUpBottom
        ambientState.stackTop = stackTop
        ambientState.stackCutoff = stackCutoff