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

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

[Flexiglass] ScrollViewFields gardening

Use @JvmField for ScrollViewFields, because we want to treat these
properties as NSSL's private fields, so why bother with the getters.

Also update ScrollViewFields dumps.

Bug: 417965077
Test: dumpsysui NotificationStackScrollLayout
Flag: com.android.systemui.scene_container
Change-Id: I879c347573c1862b656a34abe69ac5873f76fe25
parent 1f9783b7
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -626,7 +626,7 @@ public class NotificationStackScrollLayout
        @Override
        public boolean isScrolledToTop() {
            if (SceneContainerFlag.isEnabled()) {
                return mScrollViewFields.getScrollState().isScrolledToTop();
                return mScrollViewFields.scrollState.isScrolledToTop();
            } else {
                return getOwnScrollY() == 0;
            }
@@ -818,7 +818,7 @@ public class NotificationStackScrollLayout
            y = (int) mAmbientState.getHeadsUpTop();
            drawDebugInfo(canvas, y, Color.GREEN, /* label= */ "getHeadsUpTop() = " + y);

            y = (int) (mAmbientState.getStackTop() + mScrollViewFields.getIntrinsicStackHeight());
            y = (int) (mAmbientState.getStackTop() + mScrollViewFields.intrinsicStackHeight);
            drawDebugInfo(canvas, y, Color.BLUE,
                    /* label= */ "getStackTop() + getIntrinsicStackHeight() = " + y);

@@ -1232,9 +1232,9 @@ public class NotificationStackScrollLayout
        mForwardScrollable = forwardScrollable;
        mBackwardScrollable = backwardScrollable;

        boolean scrollPositionChanged = mScrollViewFields.getScrollState().getScrollPosition()
        boolean scrollPositionChanged = mScrollViewFields.scrollState.getScrollPosition()
                != scrollState.getScrollPosition();
        mScrollViewFields.setScrollState(scrollState);
        mScrollViewFields.scrollState = scrollState;

        if (scrollPositionChanged) {
            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED);
@@ -1563,7 +1563,7 @@ public class NotificationStackScrollLayout
        if (mMaxDisplayedNotifications != -1) {
            // The stack intrinsic height already contains the correct value when there is a limit
            // in the max number of notifications (e.g. as in keyguard).
            height = mScrollViewFields.getIntrinsicStackHeight();
            height = mScrollViewFields.intrinsicStackHeight;
        } else {
            height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop());
        }
@@ -2588,8 +2588,8 @@ public class NotificationStackScrollLayout
                shelfIntrinsicHeight,
                "updateIntrinsicStackHeight"
        );
        if (mScrollViewFields.getIntrinsicStackHeight() != notificationsHeight) {
            mScrollViewFields.setIntrinsicStackHeight(notificationsHeight);
        if (mScrollViewFields.intrinsicStackHeight != notificationsHeight) {
            mScrollViewFields.intrinsicStackHeight = notificationsHeight;
            notifyStackHeightChangedListeners();
        }
    }
@@ -2622,7 +2622,7 @@ public class NotificationStackScrollLayout
    @Override
    public int getIntrinsicStackHeight() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0;
        return mScrollViewFields.getIntrinsicStackHeight();
        return mScrollViewFields.intrinsicStackHeight;
    }

    @Override
@@ -3931,7 +3931,7 @@ public class NotificationStackScrollLayout
        if (!SceneContainerFlag.isEnabled()) {
            return !isInsideQsHeader(ev);
        }
        ShadeScrimShape shape = mScrollViewFields.getClippingShape();
        ShadeScrimShape shape = mScrollViewFields.clippingShape;
        if (shape == null) {
            return true; // When there is no scrim, consider this event scrollable.
        }
@@ -4972,8 +4972,8 @@ public class NotificationStackScrollLayout
        event.setMaxScrollX(mScrollX);

        if (SceneContainerFlag.isEnabled()) {
            event.setScrollY(mScrollViewFields.getScrollState().getScrollPosition());
            event.setMaxScrollY(mScrollViewFields.getScrollState().getMaxScrollPosition());
            event.setScrollY(mScrollViewFields.scrollState.getScrollPosition());
            event.setMaxScrollY(mScrollViewFields.scrollState.getMaxScrollPosition());
        } else {
            event.setScrollY(getOwnScrollY());
            event.setMaxScrollY(getScrollRange());
@@ -5968,8 +5968,8 @@ public class NotificationStackScrollLayout
    @Override
    public void setClippingShape(@Nullable ShadeScrimShape shape) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        if (Objects.equals(mScrollViewFields.getClippingShape(), shape)) return;
        mScrollViewFields.setClippingShape(shape);
        if (Objects.equals(mScrollViewFields.clippingShape, shape)) return;
        mScrollViewFields.clippingShape = shape;
        mShouldUseRoundedRectClipping = shape != null;
        mRoundedClipPath.reset();
        if (shape != null) {
@@ -5996,9 +5996,8 @@ public class NotificationStackScrollLayout
    @Override
    public void setNegativeClippingShape(@Nullable ShadeScrimShape shape) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        if (Objects.equals(mScrollViewFields.getNegativeClippingShape(), shape)) return;

        mScrollViewFields.setNegativeClippingShape(shape);
        if (Objects.equals(mScrollViewFields.negativeClippingShape, shape)) return;
        mScrollViewFields.negativeClippingShape = shape;
        mShouldUseNegativeRoundedRectClipping = shape != null;
        mNegativeRoundedClipPath.reset();
        if (shape != null) {
@@ -6925,7 +6924,7 @@ public class NotificationStackScrollLayout
    }

    /**
     * Use {@link ScrollViewFields#intrinsicStackHeight}, when SceneContainerFlag is enabled.
     * Use {@link ScrollViewFields#intrinsicStackHeight}}, when SceneContainerFlag is enabled.
     * @return the height of the content ignoring the footer.
     */
    public float getIntrinsicContentHeight() {
+8 −7
Original line number Diff line number Diff line
@@ -33,24 +33,24 @@ import java.util.function.Consumer
 */
class ScrollViewFields {
    /** Used to produce the clipping path */
    var clippingShape: ShadeScrimShape? = null
    @JvmField var clippingShape: ShadeScrimShape? = null

    /** Used to produce a negative clipping path */
    var negativeClippingShape: ShadeScrimShape? = null
    /** Used to produce the negative clipping path */
    @JvmField var negativeClippingShape: ShadeScrimShape? = null

    /** Scroll state of the notification shade. */
    var scrollState: ShadeScrollState = ShadeScrollState()
    @JvmField var scrollState: ShadeScrollState = ShadeScrollState()

    /**
     * Height in view pixels at which the Notification Stack would like to be laid out, including
     * Notification rows, paddings the Shelf and the Footer.
     * Notification rows, the Shelf, the Footer, or the EmptyView.
     */
    var intrinsicStackHeight: Int = 0
    @JvmField var intrinsicStackHeight: Int = 0

    /**
     * When internal NSSL expansion requires the stack to be scrolled (e.g. to keep an expanding
     * notification in view), that scroll amount can be sent here and it will be handled by the
     * placeholder
     * placeholder.
     */
    var syntheticScrollConsumer: Consumer<Float>? = null

@@ -104,6 +104,7 @@ class ScrollViewFields {
            pw.println("scrimClippingShape", clippingShape)
            pw.println("negativeClippingShape", negativeClippingShape)
            pw.println("scrollState", scrollState)
            pw.println("intrinsicStackHeight", intrinsicStackHeight)
        }
    }
}