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

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

Fixed an issue where the shadow wasn't rounded properly

Previously the implementation required the bottom roundness
to be treated specially when it came to the outline and
the clip path but this isn't necessary anymore and was
leading to issues with the shadows.
We now always apply the clipBottomAmount to the outline and
the clipping and can remove the special case.

Test: add notification, observe rounded clipping on bottom
Test: add groups, observe normal rounded clipping
Fixes: 80431867
Change-Id: Id65d11ce48c08adc138e1177226a03bc25ef6345
parent b67d2d8d
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -2851,12 +2851,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    @Override
    public Path getCustomClipPath(View child) {
        if (child instanceof NotificationGuts) {
            return getClipPath(true, /* ignoreTranslation */
                    false /* clipRoundedToBottom */);
        }
        if (child instanceof NotificationChildrenContainer) {
            return getClipPath(false, /* ignoreTranslation */
                    true /* clipRoundedToBottom */);
            return getClipPath(true /* ignoreTranslation */);
        }
        return super.getCustomClipPath(child);
    }
+9 −29
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
    protected float mOutlineRadius;
    private boolean mAlwaysRoundBothCorners;
    private Path mTmpPath = new Path();
    private Path mTmpPath2 = new Path();
    private float mCurrentBottomRoundness;
    private float mCurrentTopRoundness;
    private float mBottomRoundness;
@@ -94,7 +93,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
                int bottom = Math.max(getActualHeight() - mClipBottomAmount, top);
                outline.setRect(left, top, right, bottom);
            } else {
                Path clipPath = getClipPath();
                Path clipPath = getClipPath(false /* ignoreTranslation */);
                if (clipPath != null && clipPath.isConvex()) {
                    // The path might not be convex in border cases where the view is small and
                    // clipped
@@ -105,36 +104,23 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        }
    };

    private Path getClipPath() {
        return getClipPath(false, /* ignoreTranslation */
                false /* clipRoundedToBottom */);
    }

    protected Path getClipPath(boolean ignoreTranslation, boolean clipRoundedToBottom) {
    protected Path getClipPath(boolean ignoreTranslation) {
        int left;
        int top;
        int right;
        int bottom;
        int height;
        Path intersectPath = null;
        float topRoundness = mAlwaysRoundBothCorners
                ? mOutlineRadius : getCurrentBackgroundRadiusTop();
        if (!mCustomOutline) {
            int translation = mShouldTranslateContents && !ignoreTranslation
                    ? (int) getTranslation() : 0;
            left = Math.max(translation, 0);
            top = mClipTopAmount + mBackgroundTop;
            right = getWidth() + Math.min(translation, 0);
            bottom = Math.max(getActualHeight(), top);
            int intersectBottom = Math.max(getActualHeight() - mClipBottomAmount, top);
            if (bottom != intersectBottom) {
                if (clipRoundedToBottom) {
                    bottom = intersectBottom;
                } else {
                    getRoundedRectPath(left, top, right,
                            intersectBottom, 0.0f,
                            0.0f, mTmpPath2);
                    intersectPath = mTmpPath2;
                }
            }
            // If the top is rounded we want the bottom to be at most at the top roundness, in order
            // to avoid the shadow changing when scrolling up.
            bottom = Math.max(getActualHeight() - mClipBottomAmount, (int) (top + topRoundness));
        } else {
            left = mOutlineRect.left;
            top = mOutlineRect.top;
@@ -145,8 +131,6 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        if (height == 0) {
            return EMPTY_PATH;
        }
        float topRoundness = mAlwaysRoundBothCorners
                ? mOutlineRadius : getCurrentBackgroundRadiusTop();
        float bottomRoundness = mAlwaysRoundBothCorners
                ? mOutlineRadius : getCurrentBackgroundRadiusBottom();
        if (topRoundness + bottomRoundness > height) {
@@ -158,11 +142,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        }
        getRoundedRectPath(left, top, right, bottom, topRoundness,
                bottomRoundness, mTmpPath);
        Path roundedRectPath = mTmpPath;
        if (intersectPath != null) {
            roundedRectPath.op(intersectPath, Path.Op.INTERSECT);
        }
        return roundedRectPath;
        return mTmpPath;
    }

    public static void getRoundedRectPath(int left, int top, int right, int bottom,
@@ -219,7 +199,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        if (childNeedsClipping(child)) {
            Path clipPath = getCustomClipPath(child);
            if (clipPath == null) {
                clipPath = getClipPath();
                clipPath = getClipPath(false /* ignoreTranslation */);
            }
            if (clipPath != null) {
                if (intersectPath != null) {