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

Commit 30afdcad authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Fixed a visual stack collapsing bug"

parents 7e6c3bf2 d83771ee
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -254,6 +254,9 @@
    <!-- The minimum amount of top overscroll to go to the quick settings. -->
    <dimen name="min_top_overscroll_to_qs">36dp</dimen>

    <!-- The padding to the second card when the notifications collapse. -->
    <dimen name="notification_collapse_second_card_padding">8dp</dimen>

    <!-- The height of the speed bump view. -->
    <dimen name="speed_bump_height">16dp</dimen>

+7 −5
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    private int mPaddingBetweenElementsDimmed;
    private int mPaddingBetweenElementsNormal;
    private int mTopPadding;
    private int mCollapseSecondCardPadding;

    /**
     * The algorithm which calculates the properties for our children
@@ -263,6 +264,8 @@ public class NotificationStackScrollLayout extends ViewGroup
                R.dimen.min_top_overscroll_to_qs);
        mNotificationTopPadding = getResources().getDimensionPixelSize(
                R.dimen.notifications_top_padding);
        mCollapseSecondCardPadding = getResources().getDimensionPixelSize(
                R.dimen.notification_collapse_second_card_padding);
    }

    private void updatePadding(boolean dimmed) {
@@ -420,9 +423,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void setStackHeight(float height) {
        setIsExpanded(height > 0.0f);
        int newStackHeight = (int) height;
        int itemHeight = getItemHeight();
        int bottomStackPeekSize = mBottomStackPeekSize;
        int minStackHeight = itemHeight + bottomStackPeekSize;
        int minStackHeight = getMinStackHeight();
        int stackHeight;
        if (newStackHeight - mTopPadding >= minStackHeight || getNotGoneChildCount() == 0) {
            setTranslationY(mTopPaddingOverflow);
@@ -436,7 +437,8 @@ public class NotificationStackScrollLayout extends ViewGroup
            // the top card.
            float partiallyThere = (float) (newStackHeight - mTopPadding) / minStackHeight;
            partiallyThere = Math.max(0, partiallyThere);
            translationY += (1 - partiallyThere) * bottomStackPeekSize;
            translationY += (1 - partiallyThere) * (mBottomStackPeekSize +
                    mCollapseSecondCardPadding);
            setTranslationY(translationY - mTopPadding);
            stackHeight = (int) (height - (translationY - mTopPadding));
        }
@@ -1306,7 +1308,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public int getMinStackHeight() {
        return mCollapsedSize + mBottomStackPeekSize;
        return mCollapsedSize + mBottomStackPeekSize + mCollapseSecondCardPadding;
    }

    public float getTopPaddingOverflow() {
+10 −4
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public class StackScrollAlgorithm {
    private int mPaddingBetweenElementsNormal;
    private int mBottomStackSlowDownLength;
    private int mTopStackSlowDownLength;
    private int mCollapseSecondCardPadding;

    public StackScrollAlgorithm(Context context) {
        initConstants(context);
@@ -118,6 +119,8 @@ public class StackScrollAlgorithm {
                .getDimensionPixelSize(R.dimen.top_stack_slow_down_length);
        mRoundedRectCornerRadius = context.getResources().getDimensionPixelSize(
                R.dimen.notification_material_rounded_rect_radius);
        mCollapseSecondCardPadding = context.getResources().getDimensionPixelSize(
                R.dimen.notification_collapse_second_card_padding);
    }


@@ -403,9 +406,11 @@ public class StackScrollAlgorithm {
            if (i == 0) {
                childViewState.alpha = 1.0f;
                childViewState.yTranslation = Math.max(mCollapsedSize - algorithmState.scrollY, 0);
                if (childViewState.yTranslation + childViewState.height > bottomPeekStart) {
                if (childViewState.yTranslation + childViewState.height
                        > bottomPeekStart - mCollapseSecondCardPadding) {
                    childViewState.height = (int) Math.max(
                            bottomPeekStart - childViewState.yTranslation, mCollapsedSize);
                            bottomPeekStart - mCollapseSecondCardPadding
                                    - childViewState.yTranslation, mCollapsedSize);
                }
                childViewState.location = StackScrollState.ViewState.LOCATION_FIRST_CARD;
            }
@@ -440,7 +445,7 @@ public class StackScrollAlgorithm {
    private void clampPositionToBottomStackStart(StackScrollState.ViewState childViewState,
            int childHeight) {
        childViewState.yTranslation = Math.min(childViewState.yTranslation,
                mInnerHeight - mBottomStackPeekSize - childHeight);
                mInnerHeight - mBottomStackPeekSize - mCollapseSecondCardPadding - childHeight);
    }

    /**
@@ -588,7 +593,8 @@ public class StackScrollAlgorithm {
                if (i == 0 && algorithmState.scrollY <= mCollapsedSize) {

                    // The starting position of the bottom stack peek
                    int bottomPeekStart = mInnerHeight - mBottomStackPeekSize;
                    int bottomPeekStart = mInnerHeight - mBottomStackPeekSize -
                            mCollapseSecondCardPadding;
                    // Collapse and expand the first child while the shade is being expanded
                    float maxHeight = mIsExpansionChanging && child == mFirstChildWhileExpanding
                            ? mFirstChildMaxHeight