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

Commit 97924985 authored by lyn's avatar lyn
Browse files

[Dual Shade] Fix HUN position over LS QS

HUN showed lower than intended over lock screen quick settings
because the correct headsUpTop Y from the placeholder
was overridden by incorrect yTranslation

Propagate isQsOverlayVisible (and use placeholder Y when true):
SceneInteractor -> NotificationListViewBinder
-> NotificationStackScrollLayoutController
-> NotificationStackScrollLayout -> AmbientState
-> StackScrollAlgorithm

Fixes: 436730145
Test: StackScrollAlgorithmTest
Test: HUN shows at correct position over QS overlay in dual shade
Test: no change to HUN placement in classic shade with flexi on
Flag: com.android.systemui.scene_container
Change-Id: I5d41d0b0184e972af953b344fe168e0cbd6fe351
parent be5b3518
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1763,6 +1763,28 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    // endregion

    @Test
    @EnableSceneContainer
    fun resetViewStates_hunOverQsOverlay_yTranslationIsHeadsUpTop() {
        // GIVEN a HUN is visible on the lockscreen and QS is expanded
        val headsUpTop = 200f
        fakeHunInShade(
            headsUpTop = headsUpTop,
            stackTop = 100f,
            collapsedHeight = 100,
            intrinsicHeight = 300,
        )
        ambientState.fakeShowingStackOnLockscreen()
        ambientState.setApplyHunTranslation(true)
        ambientState.trackedHeadsUpRow = null

        // WHEN the view states are reset
        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        // THEN the HUN's yTranslation is exactly headsUpTop
        assertThat(notificationRow.viewState.yTranslation).isEqualTo(headsUpTop)
    }

    private fun createHunViewMock(
        isShadeOpen: Boolean,
        fullyVisible: Boolean,
+15 −0
Original line number Diff line number Diff line
@@ -101,6 +101,21 @@ public class AmbientState implements Dumpable {
    private boolean mPulsing;
    private float mHideAmount;
    private float mPulseHeight = MAX_PULSE_HEIGHT;
    private boolean mApplyHunTranslation;

    /**
     * Sets whether HUN translation should be applied to viewState.yTranslation
     */
    public void setApplyHunTranslation(boolean apply) {
        mApplyHunTranslation = apply;
    }

    /**
     * @return {@code true} if HUN translation should be applied to viewState.yTranslation
     */
    public boolean shouldApplyHunTranslation() {
        return mApplyHunTranslation;
    }

    /**
     * The ExpandableNotificationRow that is pulsing, or the one that was pulsing
+4 −0
Original line number Diff line number Diff line
@@ -1685,6 +1685,10 @@ public class NotificationStackScrollLayout
        clampScrollPosition();
    }

    public void setApplyHunTranslation(boolean apply) {
        mAmbientState.setApplyHunTranslation(apply);
    }

    private void updateForcedScroll() {
        if (mForcedScroll != null && (!mForcedScroll.hasFocus()
                || !mForcedScroll.isAttachedToWindow())) {
+4 −0
Original line number Diff line number Diff line
@@ -1028,6 +1028,10 @@ public class NotificationStackScrollLayoutController implements Dumpable {
        mViewBinder.bindWhileAttached(mView, this);
    }

    public void setApplyHunTranslation(boolean apply) {
        mView.setApplyHunTranslation(apply);
    }

    private boolean isInVisibleLocation(NotificationEntry entry) {
        ExpandableNotificationRow row = entry.getRow();
        if (row == null) {
+7 −0
Original line number Diff line number Diff line
@@ -964,6 +964,13 @@ public class StackScrollAlgorithm {
                                    : row.getEntryLegacy().isStickyAndNotDemoted())) {
                        // the height of this child before clamping it to the top
                        float unmodifiedChildHeight = childState.height;

                        // When HUN first shows above QS overlay in dual shade, we need to snap the
                        // HUN to the correct Y position from the placeholder.
                        boolean isHunToShadeTransition = ambientState.getTrackedHeadsUpRow() == row;
                        if (ambientState.shouldApplyHunTranslation() && !isHunToShadeTransition) {
                            childState.setYTranslation(headsUpTranslation);
                        }
                        clampHunToTop(
                                /* headsUpTop = */ headsUpTranslation,
                                /* collapsedHeight = */ row.getCollapsedHeight(),
Loading