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

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

Reusing the notification algorithm now when rotating

The notification algorithm had some state which was simply
dropped on rotation and therefore weird things could happen.
This is now fixed.

Change-Id: Ibb3d007b3298f745743bd3a5889bccebebf8105a
parent d84a5930
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    /**
     * The algorithm which calculates the properties for our children
     */
    private StackScrollAlgorithm mStackScrollAlgorithm;
    private final StackScrollAlgorithm mStackScrollAlgorithm;

    /**
     * The current State this Layout is in
@@ -258,6 +258,7 @@ public class NotificationStackScrollLayout extends ViewGroup

        mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, getContext());
        mSwipeHelper.setLongPressListener(mLongPressListener);
        mStackScrollAlgorithm = new StackScrollAlgorithm(context);
        initView(context);
        if (DEBUG) {
            setWillNotDraw(false);
@@ -303,8 +304,7 @@ public class NotificationStackScrollLayout extends ViewGroup
                .getDimensionPixelSize(R.dimen.notification_min_height);
        mBottomStackPeekSize = context.getResources()
                .getDimensionPixelSize(R.dimen.bottom_stack_peek_amount);
        mStackScrollAlgorithm = new StackScrollAlgorithm(context);
        mStackScrollAlgorithm.setDimmed(mAmbientState.isDimmed());
        mStackScrollAlgorithm.initView(context);
        mPaddingBetweenElementsDimmed = context.getResources()
                .getDimensionPixelSize(R.dimen.notification_padding_dimmed);
        mPaddingBetweenElementsNormal = context.getResources()
@@ -367,6 +367,7 @@ public class NotificationStackScrollLayout extends ViewGroup
            mRequestViewResizeAnimationOnLayout = false;
        }
        requestChildrenUpdate();
        mStackScrollAlgorithm.notifyChildrenSizesChanged(this);
    }

    private void requestAnimationOnViewResize() {
@@ -1639,7 +1640,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    private void onViewRemovedInternal(View child) {
        mStackScrollAlgorithm.notifyChildrenChanged(this);
        mStackScrollAlgorithm.notifyChildrenSizesChanged(this);
        if (mChangePositionInProgress) {
            // This is only a position change, don't do anything special
            return;
@@ -1793,7 +1794,7 @@ public class NotificationStackScrollLayout extends ViewGroup

    private void onViewAddedInternal(View child) {
        updateHideSensitiveForChild(child);
        mStackScrollAlgorithm.notifyChildrenChanged(this);
        mStackScrollAlgorithm.notifyChildrenSizesChanged(this);
        ((ExpandableView) child).setOnHeightChangedListener(this);
        generateAddAnimation(child, false /* fromMoreCard */);
        updateAnimationState(child);
+11 −5
Original line number Diff line number Diff line
@@ -73,14 +73,19 @@ public class StackScrollAlgorithm {
    private boolean mScaleDimmed;
    private HeadsUpManager mHeadsUpManager;
    private int mFirstChildMinHeight;
    private boolean mDimmed;

    public StackScrollAlgorithm(Context context) {
        initView(context);
    }

    public void initView(Context context) {
        initConstants(context);
        updatePadding(false);
        updatePadding();
    }

    private void updatePadding(boolean dimmed) {
        mPaddingBetweenElements = dimmed && mScaleDimmed
    private void updatePadding() {
        mPaddingBetweenElements = mDimmed && mScaleDimmed
                ? mPaddingBetweenElementsDimmed
                : mPaddingBetweenElementsNormal;
        mTopStackTotalSize = mTopStackSlowDownLength + mPaddingBetweenElements
@@ -932,7 +937,7 @@ public class StackScrollAlgorithm {
        this.mIsExpanded = isExpanded;
    }

    public void notifyChildrenChanged(final NotificationStackScrollLayout hostView) {
    public void notifyChildrenSizesChanged(final NotificationStackScrollLayout hostView) {
        int firstItemMinHeight = hostView.getFirstItemMinHeight();
        if (firstItemMinHeight != mFirstChildMinHeight) {
            mFirstChildMinHeight = firstItemMinHeight;
@@ -948,7 +953,8 @@ public class StackScrollAlgorithm {
    }

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

    public void onReset(ExpandableView view) {