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

Commit bbea5a6f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I17de7467,I317ebb37 into main

* changes:
  Deduplicate storage of topPadding
  Deduplicate storage of StackTranslation
parents 7ce86578 4c93bec9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -414,7 +414,7 @@ public class AmbientState implements Dumpable {
        return mLayoutMaxHeight;
    }

    public float getTopPadding() {
    public int getTopPadding() {
        return mTopPadding;
    }

+23 −26
Original line number Diff line number Diff line
@@ -201,7 +201,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private float mIntrinsicContentHeight;
    private int mPaddingBetweenElements;
    private int mMaxTopPadding;
    private int mTopPadding;
    private boolean mAnimateNextTopPaddingChange;
    private int mBottomPadding;
    @VisibleForTesting
@@ -282,7 +281,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     */
    private float mMinTopOverScrollToEscape;
    private int mIntrinsicPadding;
    private float mStackTranslation;
    private float mTopPaddingOverflow;
    private boolean mDontReportNextOverScroll;
    private boolean mDontClampNextScroll;
@@ -820,8 +818,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        int y = 0;
        drawDebugInfo(canvas, y, Color.RED, /* label= */ "y = " + y);

        y = mTopPadding;
        drawDebugInfo(canvas, y, Color.RED, /* label= */ "mTopPadding = " + y);
        y = getTopPadding();
        drawDebugInfo(canvas, y, Color.RED, /* label= */ "getTopPadding() = " + y);

        y = getLayoutHeight();
        drawDebugInfo(canvas, y, Color.YELLOW, /* label= */ "getLayoutHeight() = " + y);
@@ -1159,7 +1157,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mAmbientState.setLayoutHeight(getLayoutHeight());
        mAmbientState.setLayoutMaxHeight(mMaxLayoutHeight);
        updateAlgorithmLayoutMinHeight();
        mAmbientState.setTopPadding(mTopPadding);
    }

    private void updateAlgorithmLayoutMinHeight() {
@@ -1252,13 +1249,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    public int getTopPadding() {
        return mTopPadding;
        return mAmbientState.getTopPadding();
    }

    private void setTopPadding(int topPadding, boolean animate) {
        if (mTopPadding != topPadding) {
        if (getTopPadding() != topPadding) {
            mAmbientState.setTopPadding(topPadding);
            boolean shouldAnimate = animate || mAnimateNextTopPaddingChange;
            mTopPadding = topPadding;
            updateAlgorithmHeightAndPadding();
            updateContentHeight();
            if (mAmbientState.isOnKeyguard()
@@ -1303,7 +1300,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void updateStackPosition(boolean listenerNeedsAnimation) {
        float topOverscrollAmount = mShouldUseSplitNotificationShade
                ? getCurrentOverScrollAmount(true /* top */) : 0f;
        final float endTopPosition = mTopPadding + mExtraTopInsetForFullShadeTransition
        final float endTopPosition = getTopPadding() + mExtraTopInsetForFullShadeTransition
                + mAmbientState.getOverExpansion()
                + topOverscrollAmount
                - getCurrentOverScrollAmount(false /* top */);
@@ -1316,7 +1313,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        // 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(mTopPadding);
            mAmbientState.setStackY(getTopPadding());
        } else {
            final float stackY = MathUtils.lerp(0, endTopPosition, fraction);
            mAmbientState.setStackY(stackY);
@@ -1333,7 +1330,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        final float oldStackHeight = mAmbientState.getStackHeight();
        if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) {
            final float endHeight = updateStackEndHeight(
                    getHeight(), getEmptyBottomMargin(), mTopPadding);
                    getHeight(), getEmptyBottomMargin(), getTopPadding());
            updateStackHeight(endHeight, fraction);
        } else {
            // Always updateStackHeight to prevent jumps in the stack height when this fraction
@@ -1420,9 +1417,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (!appearing) {
            translationY = 0;
            if (mShouldShowShelfOnly) {
                stackHeight = mTopPadding + mShelf.getIntrinsicHeight();
                stackHeight = getTopPadding() + mShelf.getIntrinsicHeight();
            } else if (mQsFullScreen) {
                int stackStartPosition = mContentHeight - mTopPadding + mIntrinsicPadding;
                int stackStartPosition = mContentHeight - getTopPadding() + mIntrinsicPadding;
                int stackEndPosition = mMaxTopPadding + mShelf.getIntrinsicHeight();
                if (stackStartPosition <= stackEndPosition) {
                    stackHeight = stackEndPosition;
@@ -1451,7 +1448,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            stackHeight = (int) (height - translationY);
            if (isHeadsUpTransition() && appearFraction >= 0) {
                int topSpacing = mShouldUseSplitNotificationShade
                        ? mAmbientState.getStackTopMargin() : mTopPadding;
                        ? mAmbientState.getStackTopMargin() : getTopPadding();
                float startPos = mHeadsUpInset - topSpacing;
                translationY = MathUtils.lerp(startPos, 0, appearFraction);
            }
@@ -1524,7 +1521,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     * Measured relative to the resting position.
     */
    private float getExpandTranslationStart() {
        return -mTopPadding + getMinExpansionHeight() - mShelf.getIntrinsicHeight();
        return -getTopPadding() + getMinExpansionHeight() - mShelf.getIntrinsicHeight();
    }

    /**
@@ -1593,7 +1590,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        } else {
            appearPosition = mEmptyShadeView.getHeight();
        }
        return appearPosition + (onKeyguard() ? mTopPadding : mIntrinsicPadding);
        return appearPosition + (onKeyguard() ? getTopPadding() : mIntrinsicPadding);
    }

    /**
@@ -1619,7 +1616,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        } else {
            appearPosition = mEmptyShadeView.getHeight();
        }
        return appearPosition + (onKeyguard() ? mTopPadding : mIntrinsicPadding);
        return appearPosition + (onKeyguard() ? getTopPadding() : mIntrinsicPadding);
    }

    private boolean isHeadsUpTransition() {
@@ -1653,12 +1650,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    public float getStackTranslation() {
        return mStackTranslation;
        return mAmbientState.getStackTranslation();
    }

    private void setStackTranslation(float stackTranslation) {
        if (stackTranslation != mStackTranslation) {
            mStackTranslation = stackTranslation;
        if (stackTranslation != getStackTranslation()) {
            mAmbientState.setStackTranslation(stackTranslation);
            requestChildrenUpdate();
        }
@@ -2322,7 +2318,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

        // The topPadding can be bigger than the regular padding when qs is expanded, in that
        // state the maxPanelHeight and the contentHeight should be bigger
        mContentHeight = (int) (height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomPadding);
        mContentHeight =
                (int) (height + Math.max(mIntrinsicPadding, getTopPadding()) + mBottomPadding);
        updateScrollability();
        clampScrollPosition();
        updateStackPosition();
@@ -2800,7 +2797,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (mShouldUseSplitNotificationShade) {
            return mSidePaddings;
        }
        return mTopPadding - mQsScrollBoundaryPosition;
        return getTopPadding() - mQsScrollBoundaryPosition;
    }

    private int getIntrinsicHeight(View view) {
@@ -3859,7 +3856,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                // fall through
            case android.R.id.accessibilityActionScrollUp:
                final int viewportHeight =
                        getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
                        getHeight() - mPaddingBottom - getTopPadding() - mPaddingTop
                                - mShelf.getIntrinsicHeight();
                final int targetScrollY = Math.max(0,
                        Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
@@ -4077,7 +4074,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                if (row.isChildInGroup()) {
                    endPosition += row.getNotificationParent().getTranslationY();
                }
                int layoutEnd = mMaxLayoutHeight + (int) mStackTranslation;
                int layoutEnd = mMaxLayoutHeight + (int) getStackTranslation();
                NotificationSection lastSection = getLastVisibleSection();
                ExpandableView lastVisibleChild =
                        lastSection == null ? null : lastSection.getLastVisibleChild();
@@ -4560,7 +4557,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                }
            }
        }
        return touchY > mTopPadding + mStackTranslation;
        return touchY > getTopPadding() + getStackTranslation();
    }

    /**
@@ -4943,7 +4940,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            println(pw, "intrinsicContentHeight", mIntrinsicContentHeight);
            println(pw, "contentHeight", mContentHeight);
            println(pw, "intrinsicPadding", mIntrinsicPadding);
            println(pw, "topPadding", mTopPadding);
            println(pw, "topPadding", getTopPadding());
            println(pw, "bottomPadding", mBottomPadding);
            dumpRoundedRectClipping(pw);
            println(pw, "requestedClipBounds", mRequestedClipBounds);
+2 −2
Original line number Diff line number Diff line
@@ -886,7 +886,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
    fun shadeClosed_hunShouldHaveFullShadow() {
        // Given: shade is closed, ambientState.stackTranslation == -ambientState.topPadding,
        // the height of HUN is equal to the height of QQS Panel,
        ambientState.stackTranslation = -ambientState.topPadding
        ambientState.stackTranslation = (-ambientState.topPadding).toFloat()
        // Mock the height of shade
        ambientState.setLayoutMinHeight(1000)
        val childHunView =
@@ -914,7 +914,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
    fun draggingHunToOpenShade_hunShouldHavePartialShadow() {
        // Given: shade is closed when HUN pops up,
        // now drags down the HUN to open shade
        ambientState.stackTranslation = -ambientState.topPadding
        ambientState.stackTranslation = (-ambientState.topPadding).toFloat()
        // Mock the height of shade
        ambientState.setLayoutMinHeight(1000)
        val childHunView =