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

Commit 048cabdb authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Ensure background is shown behind gear when notifications overlap" into nyc-dev

parents e821f3d0 c128f227
Loading
Loading
Loading
Loading
+3 −18
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ public abstract class ExpandableView extends FrameLayout {
    protected int mClipTopAmount;
    private boolean mDark;
    private ArrayList<View> mMatchParentViews = new ArrayList<View>();
    private int mClipTopOptimization;
    private static Rect mClipRect = new Rect();
    private boolean mWillBeGone;
    private int mMinClipTopAmount = 0;
@@ -218,6 +217,7 @@ public abstract class ExpandableView extends FrameLayout {
     */
    public void setClipTopAmount(int clipTopAmount) {
        mClipTopAmount = clipTopAmount;
        updateClipping();
    }

    public int getClipTopAmount() {
@@ -306,7 +306,7 @@ public abstract class ExpandableView extends FrameLayout {
    public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
        super.getBoundsOnScreen(outRect, clipToParent);
        outRect.bottom = outRect.top + getActualHeight();
        outRect.top += getClipTopOptimization();
        outRect.top += getClipTopAmount();
    }

    public boolean isSummaryWithChildren() {
@@ -319,7 +319,7 @@ public abstract class ExpandableView extends FrameLayout {

    private void updateClipping() {
        if (mClipToActualHeight) {
            int top = mClipTopOptimization;
            int top = getClipTopAmount();
            if (top >= getActualHeight()) {
                top = getActualHeight() - 1;
            }
@@ -335,21 +335,6 @@ public abstract class ExpandableView extends FrameLayout {
        updateClipping();
    }

    public int getClipTopOptimization() {
        return mClipTopOptimization;
    }

    /**
     * Set that the view will be clipped by a given amount from the top. Contrary to
     * {@link #setClipTopAmount} this amount doesn't effect shadows and the background.
     *
     * @param clipTopOptimization the amount to clip from the top
     */
    public void setClipTopOptimization(int clipTopOptimization) {
        mClipTopOptimization = clipTopOptimization;
        updateClipping();
    }

    public boolean willBeGone() {
        return mWillBeGone;
    }
+0 −1
Original line number Diff line number Diff line
@@ -430,7 +430,6 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged

    private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) {
        return notificationGroup.summary == null
                || notificationGroup.summary.row.getClipTopOptimization() > 0
                || notificationGroup.summary.row.getClipTopAmount() > 0
                || notificationGroup.summary.row.getTranslationY() < 0;
    }
+0 −1
Original line number Diff line number Diff line
@@ -393,7 +393,6 @@ public class NotificationChildrenContainer extends ViewGroup {
            childState.hideSensitive = parentState.hideSensitive;
            childState.belowSpeedBump = parentState.belowSpeedBump;
            childState.clipTopAmount = 0;
            childState.topOverLap = 0;
            childState.alpha = 0;
            if (i < firstOverflowIndex) {
                childState.alpha = 1;
+1 −15
Original line number Diff line number Diff line
@@ -2214,7 +2214,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        updateAnimationState(false, child);

        // Make sure the clipRect we might have set is removed
        expandableView.setClipTopOptimization(0);
        expandableView.setClipTopAmount(0);
    }

    private boolean isChildInGroup(View child) {
@@ -3398,9 +3398,6 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void setDismissAllInProgress(boolean dismissAllInProgress) {
        mDismissAllInProgress = dismissAllInProgress;
        mAmbientState.setDismissAllInProgress(dismissAllInProgress);
        if (dismissAllInProgress) {
            disableClipOptimization();
        }
        handleDismissAllClipping();
    }

@@ -3421,17 +3418,6 @@ public class NotificationStackScrollLayout extends ViewGroup
        }
    }

    private void disableClipOptimization() {
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            ExpandableView child = (ExpandableView) getChildAt(i);
            if (child.getVisibility() == GONE) {
                continue;
            }
            child.setClipTopOptimization(0);
        }
    }

    public boolean isDismissViewNotGone() {
        return mDismissView.getVisibility() != View.GONE && !mDismissView.willBeGone();
    }
+7 −49
Original line number Diff line number Diff line
@@ -138,11 +138,9 @@ public class StackScrollAlgorithm {

    private void updateClipping(StackScrollState resultState,
            StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
        boolean dismissAllInProgress = ambientState.isDismissAllInProgress();
        float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation();
        float previousNotificationEnd = 0;
        float previousNotificationStart = 0;
        boolean previousNotificationIsSwiped = false;
        int childCount = algorithmState.visibleChildren.size();
        for (int i = 0; i < childCount; i++) {
            ExpandableView child = algorithmState.visibleChildren.get(i);
@@ -153,36 +151,21 @@ public class StackScrollAlgorithm {
            }
            float newYTranslation = state.yTranslation;
            float newHeight = state.height;
            // apply clipping and shadow
            float newNotificationEnd = newYTranslation + newHeight;

            float clipHeight;
            if (previousNotificationIsSwiped) {
                // When the previous notification is swiped, we don't clip the content to the
                // bottom of it.
                clipHeight = newHeight;
            if (newYTranslation < previousNotificationEnd) {
                // The previous view is overlapping on top, clip!
                float overlapAmount = previousNotificationEnd - newYTranslation;
                state.clipTopAmount = (int) overlapAmount;
            } else {
                clipHeight = newNotificationEnd - previousNotificationEnd;
                clipHeight = Math.max(0.0f, clipHeight);
            }

            updateChildClippingAndBackground(state, newHeight, clipHeight,
                    newHeight - (previousNotificationStart - newYTranslation));

            if (dismissAllInProgress) {
                state.clipTopAmount = Math.max(child.getMinClipTopAmount(), state.clipTopAmount);
                state.clipTopAmount = 0;
            }

            if (!child.isTransparent()) {
                // Only update the previous values if we are not transparent,
                // otherwise we would clip to a transparent view.
                if ((dismissAllInProgress && canChildBeDismissed(child))) {
                    previousNotificationIsSwiped = true;
                } else {
                    previousNotificationIsSwiped = ambientState.getDraggedViews().contains(child);
                previousNotificationEnd = newNotificationEnd;
                    previousNotificationStart =newYTranslation + state.clipTopAmount;
                }
                previousNotificationStart = newYTranslation;
            }
        }
    }
@@ -192,31 +175,6 @@ public class StackScrollAlgorithm {
        return (veto != null && veto.getVisibility() != View.GONE);
    }

    /**
     * Updates the shadow outline and the clipping for a view.
     *
     * @param state the viewState to update
     * @param realHeight the currently applied height of the view
     * @param clipHeight the desired clip height, the rest of the view will be clipped from the top
     * @param backgroundHeight the desired background height. The shadows of the view will be
     *                         based on this height and the content will be clipped from the top
     */
    private void updateChildClippingAndBackground(StackViewState state, float realHeight,
            float clipHeight, float backgroundHeight) {
        if (realHeight > clipHeight) {
            // Rather overlap than create a hole.
            state.topOverLap = (int) Math.floor(realHeight - clipHeight);
        } else {
            state.topOverLap = 0;
        }
        if (realHeight > backgroundHeight) {
            // Rather overlap than create a hole.
            state.clipTopAmount = (int) Math.floor(realHeight - backgroundHeight);
        } else {
            state.clipTopAmount = 0;
        }
    }

    /**
     * Updates the dimmed, activated and hiding sensitive states of the children.
     */
Loading