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

Commit 2233f8a6 authored by d34d's avatar d34d Committed by Steve Kondik
Browse files

Themes: Don't clip notification when a theme defines a larger radius

The normal behavior is to clip notifications as they go behind
other notifications.  The clipping is much more obvious when a
larger radius is being used so we should forgoe clipping in this
situation.

Change-Id: Iacffc8bdb146d47dd61686314297ddb851416a65
parent 8e5f8551
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class StackScrollAlgorithm {
    private static final int MAX_ITEMS_IN_BOTTOM_STACK = 3;
    private static final int MAX_ITEMS_IN_TOP_STACK = 3;

    private static final int DEFAULT_CORNER_RADIUS = 2;

    public static final float DIMMED_SCALE = 0.95f;

    private int mPaddingBetweenElements;
@@ -73,6 +75,7 @@ public class StackScrollAlgorithm {
    private boolean mIsSmallScreen;
    private int mMaxNotificationHeight;
    private boolean mScaleDimmed;
    private boolean mPerformClipping;

    public StackScrollAlgorithm(Context context) {
        initConstants(context);
@@ -127,6 +130,12 @@ public class StackScrollAlgorithm {
                R.dimen.notification_collapse_second_card_padding);
        mScaleDimmed = context.getResources().getDisplayMetrics().densityDpi
                >= DisplayMetrics.DENSITY_XXHIGH;

        // We don't want to clip the notification if a theme overrides the corner radius with
        // a value larger than the default.
        mPerformClipping = context.getResources()
                .getDimension(R.dimen.notification_material_rounded_rect_radius) <=
                DEFAULT_CORNER_RADIUS * context.getResources().getDisplayMetrics().density;
    }

    public boolean shouldScaleDimmed() {
@@ -214,7 +223,7 @@ public class StackScrollAlgorithm {
                    // corners of the notifications, but only if we are not fully overlapped by
                    // the top card.
                    float clippingCorrection = state.dimmed
                            ? 0
                            ? (mPerformClipping ? 0 : newHeight)
                            : mRoundedRectCornerRadius * state.scale;
                    clipHeight += clippingCorrection;
                }