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

Commit a2e03b16 authored by Selim Cinek's avatar Selim Cinek Committed by Android Git Automerger
Browse files

am 3838b611: Improved the notification stack logic further

* commit '3838b6116b72cce25b49ba7bbce63b7ac00820af':
  Improved the notification stack logic further
parents 0a079fcd 34c0a8d7
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -243,7 +243,10 @@
    <dimen name="top_stack_peek_amount">12dp</dimen>

    <!-- Space reserved for the cards behind the top card in the bottom stack -->
    <dimen name="bottom_stack_peek_amount">18dp</dimen>
    <dimen name="bottom_stack_peek_amount">12dp</dimen>

    <!-- The height of the area before the bottom stack in which the notifications slow down -->
    <dimen name="bottom_stack_slow_down_length">12dp</dimen>

    <!-- The side padding of the notifications-->
    <dimen name="notification_side_padding">8dp</dimen>
@@ -251,8 +254,11 @@
    <!-- Z distance between notifications if they are in the stack -->
    <dimen name="z_distance_between_notifications">2dp</dimen>

    <!-- The padding between the individual notification cards when dimmed. -->
    <dimen name="notification_padding_dimmed">0dp</dimen>

    <!-- The padding between the individual notification cards. -->
    <dimen name="notification_padding">3dp</dimen>
    <dimen name="notification_padding">4dp</dimen>

    <!-- The total height of the stack in its collapsed size (i.e. when quick settings is open) -->
    <dimen name="collapsed_stack_height">94dp</dimen>
+6 −1
Original line number Diff line number Diff line
@@ -153,7 +153,10 @@ public class NotificationStackScrollLayout extends ViewGroup
        if (DEBUG) {
            int y = mCollapsedSize;
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
            y = (int) (getLayoutHeight() - mBottomStackPeekSize - mCollapsedSize);
            y = (int) (getLayoutHeight() - mBottomStackPeekSize
                    - mStackScrollAlgorithm.getBottomStackSlowDownLength());
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
            y = (int) (getLayoutHeight() - mBottomStackPeekSize);
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
            y = (int) getLayoutHeight();
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
@@ -1226,6 +1229,7 @@ public class NotificationStackScrollLayout extends ViewGroup
     * See {@link AmbientState#setDimmed}.
     */
    public void setDimmed(boolean dimmed, boolean animate) {
        mStackScrollAlgorithm.setDimmed(dimmed);
        mAmbientState.setDimmed(dimmed);
        if (animate) {
            mDimmedNeedsAnimation = true;
@@ -1311,6 +1315,7 @@ public class NotificationStackScrollLayout extends ViewGroup

                // ANIMATION_TYPE_DIMMED
                new AnimationFilter()
                        .animateY()
                        .animateScale()
                        .animateDimmed()
        };
+9 −10
Original line number Diff line number Diff line
@@ -38,27 +38,26 @@ public class PiecewiseLinearIndentationFunctor extends StackIndentationFunctor {
     *                 the actual visual distance below the top card but is a maximum,
     *                 achieved when the next card just starts transitioning into the stack and
     *                 the stack is full.
     *                 If totalTransitionDistance is equal to this, we directly start at the peek,
     *                 otherwise the first element transitions between 0 and
     *                 totalTransitionDistance - peekSize.
     *                 If distanceToPeekStart is 0, we directly start at the peek, otherwise the
     *                 first element transitions between 0 and distanceToPeekStart.
     *                 Visualization:
     *           ---------------------------------------------------   ---
     *          |                                                   |   |
     *          |                  FIRST ITEM                       |   | <- totalTransitionDistance
     *          |                  FIRST ITEM                       |   | <- distanceToPeekStart
     *          |                                                   |   |
     *          |---------------------------------------------------|   |   ---
     *          |__________________SECOND ITEM______________________|   |    |  <- peekSize
     *          |===================================================|  _|_  _|_
     *          |---------------------------------------------------|  ---  ---
     *          |__________________SECOND ITEM______________________|        |  <- peekSize
     *          |===================================================|       _|_
     *
     * @param totalTransitionDistance The total transition distance an element has to go through
     * @param distanceToPeekStart The distance to the start of the peak.
     * @param linearPart The interpolation factor between the linear and the quadratic amount taken.
     *                   This factor must be somewhere in [0 , 1]
     */
    PiecewiseLinearIndentationFunctor(int maxItemsInStack,
                                      int peekSize,
                                      int totalTransitionDistance,
                                      int distanceToPeekStart,
                                      float linearPart) {
        super(maxItemsInStack, peekSize, totalTransitionDistance);
        super(maxItemsInStack, peekSize, distanceToPeekStart);
        mBaseValues = new ArrayList<Float>(maxItemsInStack+1);
        initBaseValues();
        mLinearPart = linearPart;
+23 −13
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ package com.android.systemui.statusbar.stack;
 */
public abstract class StackIndentationFunctor {

    protected final int mTotalTransitionDistance;
    protected final int mDistanceToPeekStart;
    protected int mTotalTransitionDistance;
    protected int mDistanceToPeekStart;
    protected int mMaxItemsInStack;
    protected int mPeekSize;
    protected boolean mStackStartsAtPeek;
@@ -37,31 +37,41 @@ public abstract class StackIndentationFunctor {
     *                 the actual visual distance below the top card but is a maximum,
     *                 achieved when the next card just starts transitioning into the stack and
     *                 the stack is full.
     *                 If totalTransitionDistance is equal to this, we directly start at the peek,
     *                 otherwise the first element transitions between 0 and
     *                 totalTransitionDistance - peekSize.
     *                 If distanceToPeekStart is 0, we directly start at the peek, otherwise the
     *                 first element transitions between 0 and distanceToPeekStart.
     *                 Visualization:
     *           ---------------------------------------------------   ---
     *          |                                                   |   |
     *          |                  FIRST ITEM                       |   | <- totalTransitionDistance
     *          |                  FIRST ITEM                       |   | <- distanceToPeekStart
     *          |                                                   |   |
     *          |---------------------------------------------------|   |   ---
     *          |__________________SECOND ITEM______________________|   |    |  <- peekSize
     *          |===================================================|  _|_  _|_
     *          |---------------------------------------------------|  ---  ---
     *          |__________________SECOND ITEM______________________|        |  <- peekSize
     *          |===================================================|       _|_
     *
     * @param totalTransitionDistance The total transition distance an element has to go through
     * @param distanceToPeekStart The distance to the start of the peak.
     */
    StackIndentationFunctor(int maxItemsInStack, int peekSize, int totalTransitionDistance) {
        mTotalTransitionDistance = totalTransitionDistance;
        mDistanceToPeekStart = mTotalTransitionDistance - peekSize;
    StackIndentationFunctor(int maxItemsInStack, int peekSize, int distanceToPeekStart) {
        mDistanceToPeekStart = distanceToPeekStart;
        mStackStartsAtPeek = mDistanceToPeekStart == 0;
        mMaxItemsInStack = maxItemsInStack;
        mPeekSize = peekSize;
        updateTotalTransitionDistance();

    }

    private void updateTotalTransitionDistance() {
        mTotalTransitionDistance = mDistanceToPeekStart + mPeekSize;
    }

    public void setPeekSize(int mPeekSize) {
        this.mPeekSize = mPeekSize;
        updateTotalTransitionDistance();
    }

    public void setDistanceToPeekStart(int distanceToPeekStart) {
        mDistanceToPeekStart = distanceToPeekStart;
        mStackStartsAtPeek = mDistanceToPeekStart == 0;
        updateTotalTransitionDistance();
    }

    /**
+36 −14
Original line number Diff line number Diff line
@@ -65,13 +65,40 @@ public class StackScrollAlgorithm {
    private ExpandableView mFirstChildWhileExpanding;
    private boolean mExpandedOnStart;
    private int mTopStackTotalSize;
    private int mPaddingBetweenElementsDimmed;
    private int mPaddingBetweenElementsNormal;
    private int mBottomStackSlowDownLength;

    public StackScrollAlgorithm(Context context) {
        initConstants(context);
        updatePadding(false);
    }

    private void updatePadding(boolean dimmed) {
        mPaddingBetweenElements = dimmed
                ? mPaddingBetweenElementsDimmed
                : mPaddingBetweenElementsNormal;
        mTopStackTotalSize = mCollapsedSize + mPaddingBetweenElements;
        mTopStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
                MAX_ITEMS_IN_TOP_STACK,
                mTopStackPeekSize,
                mTopStackTotalSize,
                0.5f);
        mBottomStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
                MAX_ITEMS_IN_BOTTOM_STACK,
                mBottomStackPeekSize,
                getBottomStackSlowDownLength(),
                0.5f);
    }

    public int getBottomStackSlowDownLength() {
        return mBottomStackSlowDownLength + mPaddingBetweenElements;
    }

    private void initConstants(Context context) {
        mPaddingBetweenElements = context.getResources()
        mPaddingBetweenElementsDimmed = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding_dimmed);
        mPaddingBetweenElementsNormal = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding);
        mCollapsedSize = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_min_height);
@@ -82,17 +109,8 @@ public class StackScrollAlgorithm {
        mZDistanceBetweenElements = context.getResources()
                .getDimensionPixelSize(R.dimen.z_distance_between_notifications);
        mZBasicHeight = (MAX_ITEMS_IN_BOTTOM_STACK + 1) * mZDistanceBetweenElements;
        mTopStackTotalSize = mCollapsedSize + mPaddingBetweenElements;
        mTopStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
                MAX_ITEMS_IN_TOP_STACK,
                mTopStackPeekSize,
                mTopStackTotalSize,
                0.5f);
        mBottomStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
                MAX_ITEMS_IN_BOTTOM_STACK,
                mBottomStackPeekSize,
                mCollapsedSize + mBottomStackPeekSize + mPaddingBetweenElements,
                0.5f);
        mBottomStackSlowDownLength = context.getResources()
                .getDimensionPixelSize(R.dimen.bottom_stack_slow_down_length);
    }


@@ -206,7 +224,7 @@ public class StackScrollAlgorithm {
        float bottomPeekStart = mInnerHeight - mBottomStackPeekSize;

        // The position where the bottom stack starts.
        float bottomStackStart = bottomPeekStart - mCollapsedSize;
        float bottomStackStart = bottomPeekStart - mBottomStackSlowDownLength;

        // The y coordinate of the current child.
        float currentYPosition = 0.0f;
@@ -621,6 +639,10 @@ public class StackScrollAlgorithm {
        }
    }

    public void setDimmed(boolean dimmed) {
        updatePadding(dimmed);
    }

    class StackScrollAlgorithmState {

        /**