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

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

Merge "[Flexiglass] Replace StackY with StackTop" into main

parents 748b51d0 140caf6d
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class AmbientState implements Dumpable {
     *  Used to read bouncer states.
     */
    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
    private float mStackTop;
    private float mStackCutoff;
    private int mScrollY;
    private float mOverScrollTopAmount;
@@ -186,6 +187,7 @@ public class AmbientState implements Dumpable {
     * @param stackY Distance of top of notifications panel from top of screen.
     */
    public void setStackY(float stackY) {
        SceneContainerFlag.assertInLegacyMode();
        mStackY = stackY;
    }

@@ -193,6 +195,7 @@ public class AmbientState implements Dumpable {
     * @return Distance of top of notifications panel from top of screen.
     */
    public float getStackY() {
        SceneContainerFlag.assertInLegacyMode();
        return mStackY;
    }

@@ -348,6 +351,18 @@ public class AmbientState implements Dumpable {
        return mZDistanceBetweenElements;
    }

    /** Y coordinate in view pixels of the top of the notification stack */
    public float getStackTop() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f;
        return mStackTop;
    }

    /** @see #getStackTop() */
    public void setStackTop(float mStackTop) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        this.mStackTop = mStackTop;
    }

    /**
     * Y coordinate in view pixels above which the bottom of the notification stack / shelf / footer
     * must be.
@@ -769,6 +784,8 @@ public class AmbientState implements Dumpable {

    @Override
    public void dump(PrintWriter pw, String[] args) {
        pw.println("mStackTop=" + mStackTop);
        pw.println("mStackCutoff" + mStackCutoff);
        pw.println("mTopPadding=" + mTopPadding);
        pw.println("mStackTopMargin=" + mStackTopMargin);
        pw.println("mStackTranslation=" + mStackTranslation);
+4 −8
Original line number Diff line number Diff line
@@ -834,7 +834,7 @@ public class NotificationStackScrollLayout
        drawDebugInfo(canvas, y, Color.RED, /* label= */ "y = " + y);

        if (SceneContainerFlag.isEnabled()) {
            y = (int) mScrollViewFields.getStackTop();
            y = (int) mAmbientState.getStackTop();
            drawDebugInfo(canvas, y, Color.RED, /* label= */ "getStackTop() = " + y);

            y = (int) mAmbientState.getStackCutoff();
@@ -1216,7 +1216,7 @@ public class NotificationStackScrollLayout

    @Override
    public void setStackTop(float stackTop) {
        mScrollViewFields.setStackTop(stackTop);
        mAmbientState.setStackTop(stackTop);
        // TODO(b/332574413): replace the following with using stackTop
        updateTopPadding(stackTop, isAddOrRemoveAnimationPending());
    }
@@ -1426,11 +1426,7 @@ public class NotificationStackScrollLayout
        if (mAmbientState.isBouncerInTransit() && mQsExpansionFraction > 0f) {
            fraction = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(fraction);
        }
        // TODO(b/322228881): Clean up scene container vs legacy behavior in NSSL
        if (SceneContainerFlag.isEnabled()) {
            // stackY should be driven by scene container, not NSSL
            mAmbientState.setStackY(getTopPadding());
        } else {
        if (!SceneContainerFlag.isEnabled()) {
            final float stackY = MathUtils.lerp(0, endTopPosition, fraction);
            mAmbientState.setStackY(stackY);
        }
@@ -3726,7 +3722,7 @@ public class NotificationStackScrollLayout

    protected boolean isInsideQsHeader(MotionEvent ev) {
        if (SceneContainerFlag.isEnabled()) {
            return ev.getY() < mScrollViewFields.getStackTop();
            return ev.getY() < mAmbientState.getStackTop();
        }

        mQsHeader.getBoundsOnScreen(mQsHeaderBound);
+0 −3
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import java.util.function.Consumer
class ScrollViewFields {
    /** Used to produce the clipping path */
    var scrimClippingShape: ShadeScrimShape? = null
    /** Y coordinate in view pixels of the top of the notification stack */
    var stackTop: Float = 0f
    /** Y coordinate in view pixels of the top of the HUN */
    var headsUpTop: Float = 0f
    /** Whether the notifications are scrolled all the way to the top (i.e. when freshly opened) */
@@ -76,7 +74,6 @@ class ScrollViewFields {
    fun dump(pw: IndentingPrintWriter) {
        pw.printSection("StackViewStates") {
            pw.println("scrimClippingShape", scrimClippingShape)
            pw.println("stackTop", stackTop)
            pw.println("headsUpTop", headsUpTop)
            pw.println("isScrolledToTop", isScrolledToTop)
        }
+16 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.policy.SystemBarUtils;
import com.android.keyguard.BouncerPanelExpansionCalculator;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.res.R;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.NotificationShelf;
@@ -332,8 +333,10 @@ public class StackScrollAlgorithm {

    private void updateClipping(StackScrollAlgorithmState algorithmState,
            AmbientState ambientState) {
        float drawStart = ambientState.isOnKeyguard() ? 0
        float stackTop = SceneContainerFlag.isEnabled() ? ambientState.getStackTop()
                : ambientState.getStackY() - ambientState.getScrollY();
        float drawStart = ambientState.isOnKeyguard() ? 0
                : stackTop;
        float clipStart = 0;
        int childCount = algorithmState.visibleChildren.size();
        boolean firstHeadsUp = true;
@@ -641,7 +644,10 @@ public class StackScrollAlgorithm {
        // Incoming views have yTranslation=0 by default.
        viewState.setYTranslation(algorithmState.mCurrentYPosition);

        float viewEnd = viewState.getYTranslation() + viewState.height + ambientState.getStackY();
        float stackTop = SceneContainerFlag.isEnabled()
                ? ambientState.getStackTop()
                : ambientState.getStackY();
        float viewEnd = stackTop + viewState.getYTranslation() + viewState.height;
        maybeUpdateHeadsUpIsVisible(viewState, ambientState.isShadeExpanded(),
                view.mustStayOnScreen(),
                /* topVisible= */ viewState.getYTranslation() >= mNotificationScrimPadding,
@@ -681,7 +687,9 @@ public class StackScrollAlgorithm {
            }
        } else {
            if (view instanceof EmptyShadeView) {
                float fullHeight = ambientState.getLayoutMaxHeight() + mMarginBottom
                float fullHeight = SceneContainerFlag.isEnabled()
                        ? ambientState.getStackCutoff() - ambientState.getStackTop()
                        : ambientState.getLayoutMaxHeight() + mMarginBottom
                        - ambientState.getStackY();
                viewState.setYTranslation((fullHeight - getMaxAllowedChildHeight(view)) / 2f);
            } else if (view != ambientState.getTrackedHeadsUpRow()) {
@@ -726,7 +734,7 @@ public class StackScrollAlgorithm {
                + mPaddingBetweenElements;

        setLocation(view.getViewState(), algorithmState.mCurrentYPosition, i);
        viewState.setYTranslation(viewState.getYTranslation() + ambientState.getStackY());
        viewState.setYTranslation(viewState.getYTranslation() + stackTop);
    }

    @VisibleForTesting
@@ -1002,8 +1010,11 @@ public class StackScrollAlgorithm {
        // Animate pinned HUN bottom corners to and from original roundness.
        final float originalCornerRadius =
                row.isLastInSection() ? 1f : (mSmallCornerRadius / mLargeCornerRadius);
        final float stackTop = SceneContainerFlag.isEnabled()
                ? ambientState.getStackTop()
                : ambientState.getStackY();
        final float bottomValue = computeCornerRoundnessForPinnedHun(mHostView.getHeight(),
                ambientState.getStackY(), getMaxAllowedChildHeight(row), originalCornerRadius);
                stackTop, getMaxAllowedChildHeight(row), originalCornerRadius);
        row.requestBottomRoundness(bottomValue, STACK_SCROLL_ALGO);
        row.addOnDetachResetRoundness(STACK_SCROLL_ALGO);
    }
+2 −0
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableSceneContainer // TODO(b/332574413) cover stack bounds integration with tests
    public void testUpdateStackHeight_qsExpansionGreaterThanZero() {
        final float expansionFraction = 0.2f;
        final float overExpansion = 50f;
@@ -891,6 +892,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @DisableSceneContainer // NSSL has no more scroll logic when SceneContainer is on
    public void testNormalShade_hasNoTopOverscroll() {
        mTestableResources
                .addOverride(R.bool.config_use_split_notification_shade, /* value= */ false);
Loading