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

Commit 266e4cf2 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[Flexiglass] Fix the height of HUNs in QuickSettings" into main

parents 63aea4d0 f16289fd
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