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

Commit a5eaa603 authored by Selim Cinek's avatar Selim Cinek
Browse files

Improved stack scroll range logic and more card background bug

Change-Id: Id3e6dfc4de09c6853ea1973b287880ac5f32b40b
parent 1cb088c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public abstract class ExpandableView extends FrameLayout {
     * @return The desired notification height.
     */
    public int getIntrinsicHeight() {
        return mActualHeight;
        return getHeight();
    }

    /**
+0 −15
Original line number Diff line number Diff line
@@ -33,21 +33,6 @@ public class NotificationOverflowContainer extends ActivatableNotificationView {
        super(context, attrs);
    }

    @Override
    public void setActualHeight(int currentHeight, boolean notifyListeners) {
        // noop
    }

    @Override
    public int getActualHeight() {
        return getHeight();
    }

    @Override
    public void setClipTopAmount(int clipTopAmount) {
        // noop
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
+21 −11
Original line number Diff line number Diff line
@@ -80,9 +80,12 @@ public class NotificationStackScrollLayout extends ViewGroup
    private Paint mDebugPaint;
    private int mContentHeight;
    private int mCollapsedSize;
    private int mBottomStackSlowDownHeight;
    private int mBottomStackPeekSize;
    private int mEmptyMarginBottom;
    private int mPaddingBetweenElements;
    private int mPaddingBetweenElementsDimmed;
    private int mPaddingBetweenElementsNormal;
    private int mTopPadding;

    /**
@@ -154,7 +157,7 @@ public class NotificationStackScrollLayout extends ViewGroup
            int y = mCollapsedSize;
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
            y = (int) (getLayoutHeight() - mBottomStackPeekSize
                    - mStackScrollAlgorithm.getBottomStackSlowDownLength());
                    - mBottomStackSlowDownHeight);
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
            y = (int) (getLayoutHeight() - mBottomStackPeekSize);
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
@@ -186,9 +189,20 @@ public class NotificationStackScrollLayout extends ViewGroup
                .getDimensionPixelSize(R.dimen.bottom_stack_peek_amount);
        mEmptyMarginBottom = context.getResources().getDimensionPixelSize(
                R.dimen.notification_stack_margin_bottom);
        mPaddingBetweenElements = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding);
        mStackScrollAlgorithm = new StackScrollAlgorithm(context);
        mPaddingBetweenElementsDimmed = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding_dimmed);
        mPaddingBetweenElementsNormal = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding);
        updatePadding(false);
    }

    private void updatePadding(boolean dimmed) {
        mPaddingBetweenElements = dimmed
                ? mPaddingBetweenElementsDimmed
                : mPaddingBetweenElementsNormal;
        mBottomStackSlowDownHeight = mStackScrollAlgorithm.getBottomStackSlowDownLength();
        updateContentHeight();
    }

    @Override
@@ -742,15 +756,10 @@ public class NotificationStackScrollLayout extends ViewGroup
        if (firstChild != null) {
            int contentHeight = getContentHeight();
            int firstChildMaxExpandHeight = getMaxExpandHeight(firstChild);

            scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight + mBottomStackPeekSize);
            scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight + mBottomStackPeekSize
                    + mBottomStackSlowDownHeight);
            if (scrollRange > 0) {
                View lastChild = getLastChildNotGone();
                if (isViewExpanded(lastChild)) {
                    // last child is expanded, so we have to ensure that it can exit the
                    // bottom stack
                    scrollRange += mCollapsedSize + mPaddingBetweenElements;
                }
                // We want to at least be able collapse the first item and not ending in a weird
                // end state.
                scrollRange = Math.max(scrollRange, firstChildMaxExpandHeight - mCollapsedSize);
@@ -1184,7 +1193,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    public int getEmptyBottomMargin() {
        int emptyMargin = mMaxLayoutHeight - mContentHeight;
        if (needsHeightAdaption()) {
            emptyMargin = emptyMargin - mCollapsedSize - mBottomStackPeekSize;
            emptyMargin = emptyMargin - mBottomStackSlowDownHeight - mBottomStackPeekSize;
        }
        return Math.max(emptyMargin, 0);
    }
@@ -1231,6 +1240,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void setDimmed(boolean dimmed, boolean animate) {
        mStackScrollAlgorithm.setDimmed(dimmed);
        mAmbientState.setDimmed(dimmed);
        updatePadding(dimmed);
        if (animate) {
            mDimmedNeedsAnimation = true;
            mNeedsAnimation =  true;