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

Commit 2871beff authored by Selim Cinek's avatar Selim Cinek
Browse files

Implemented rounded clipping for groups

Groups would not properly clip to the bottom before.

Test: add notification group, observe clipping
Bug: 69168591
Change-Id: Ia59e2d979faf2e84d96e16ac2d4f31c03ac6e910
parent d7768f4f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -695,6 +695,11 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
                mBackgroundNormal.getVisibility() == View.VISIBLE ? 1.0f : 0.0f);
    }

    protected void updateBackgroundClipping() {
        mBackgroundNormal.setBottomAmountClips(!isChildInGroup());
        mBackgroundDimmed.setBottomAmountClips(!isChildInGroup());
    }

    protected boolean shouldHideBackground() {
        return mDark;
    }
+23 −2
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
        onChildrenCountChanged();
        row.setIsChildInGroup(false, null);
        row.setBottomRoundness(0.0f, false /* animate */);
    }

    @Override
@@ -566,6 +567,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mNotificationParent.updateBackgroundForGroupState();
        }
        updateIconVisibilities();
        updateBackgroundClipping();
    }

    @Override
@@ -1761,6 +1763,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mPrivateLayout.updateExpandButtons(isExpandable());
        updateChildrenHeaderAppearance();
        updateChildrenVisibility();
        applyChildrenRoundness();
    }

    public void updateChildrenHeaderAppearance() {
@@ -2351,7 +2354,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                return true;
            }
        } else if (child == mChildrenContainer) {
            if (isClippingNeeded()) {
            if (isClippingNeeded() || ((isGroupExpanded() || isGroupExpansionChanging())
                    && getClipBottomAmount() != 0.0f && getCurrentBottomRoundness() != 0.0f)) {
                return true;
            }
        } else if (child instanceof NotificationGuts) {
@@ -2360,10 +2364,27 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return super.childNeedsClipping(child);
    }

    @Override
    protected void applyRoundness() {
        super.applyRoundness();
        applyChildrenRoundness();
    }

    private void applyChildrenRoundness() {
        if (mIsSummaryWithChildren) {
            mChildrenContainer.setCurrentBottomRoundness(getCurrentBottomRoundness());
        }
    }

    @Override
    public Path getCustomClipPath(View child) {
        if (child instanceof NotificationGuts) {
            return getClipPath(true /* ignoreTranslation */);
            return getClipPath(true, /* ignoreTranslation */
                    false /* clipRoundedToBottom */);
        }
        if (child instanceof NotificationChildrenContainer) {
            return getClipPath(false, /* ignoreTranslation */
                    true /* clipRoundedToBottom */);
        }
        return super.getCustomClipPath(child);
    }
+13 −8
Original line number Diff line number Diff line
@@ -90,10 +90,11 @@ public abstract class ExpandableOutlineView extends ExpandableView {
    };

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

    protected Path getClipPath(boolean ignoreTranslation) {
    protected Path getClipPath(boolean ignoreTranslation, boolean clipRoundedToBottom) {
        int left;
        int top;
        int right;
@@ -109,11 +110,15 @@ public abstract class ExpandableOutlineView extends ExpandableView {
            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;
                }
            }
        } else {
            left = mOutlineRect.left;
            top = mOutlineRect.top;
@@ -248,7 +253,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        return mCurrentTopRoundness;
    }

    protected float getCurrentBottomRoundness() {
    public float getCurrentBottomRoundness() {
        return mCurrentBottomRoundness;
    }

@@ -256,7 +261,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        return mCurrentBottomRoundness * mOutlineRadius;
    }

    public void setBottomRoundNess(float bottomRoundness, boolean animate) {
    public void setBottomRoundness(float bottomRoundness, boolean animate) {
        if (mBottomRoundness != bottomRoundness) {
            mBottomRoundness = bottomRoundness;
            PropertyAnimator.setProperty(this, BOTTOM_ROUNDNESS, bottomRoundness,
+8 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class NotificationBackgroundView extends View {
    private int mCurrentSidePaddings;
    private boolean mBottomIsRounded;
    private int mBackgroundTop;
    private boolean mBottomAmountClips = true;

    public NotificationBackgroundView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -64,7 +65,7 @@ public class NotificationBackgroundView extends View {
    private void draw(Canvas canvas, Drawable drawable) {
        if (drawable != null) {
            int bottom = mActualHeight;
            if (mBottomIsRounded) {
            if (mBottomIsRounded && mBottomAmountClips) {
                bottom -= mClipBottomAmount;
            }
            drawable.setBounds(mCurrentSidePaddings, mBackgroundTop,
@@ -187,6 +188,12 @@ public class NotificationBackgroundView extends View {
        updateBackgroundRadii();
    }

    public void setBottomAmountClips(boolean clips) {
        if (clips != mBottomAmountClips) {
            mBottomAmountClips = clips;
            invalidate();
        }
    }

    private void updateBackgroundRadii() {
        if (mDontModifyCorners) {
+1 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.android.systemui.statusbar.phone.NotificationIconContainer.OVE
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Path;
import android.graphics.Rect;
import android.os.SystemProperties;
import android.util.AttributeSet;
@@ -109,7 +108,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
        mViewInvertHelper = new ViewInvertHelper(mShelfIcons,
                NotificationPanelView.DOZE_ANIMATION_DURATION);
        mShelfState = new ShelfState();
        setBottomRoundNess(1.0f, false /* animate */);
        setBottomRoundness(1.0f, false /* animate */);
        initDimens();
    }

Loading