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

Commit a2e1b6f1 authored by d34d's avatar d34d
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 b04193af
Loading
Loading
Loading
Loading
+11 −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() {
@@ -202,7 +211,8 @@ public class StackScrollAlgorithm {

            // In the unlocked shade we have to clip a little bit higher because of the rounded
            // corners of the notifications.
            float clippingCorrection = state.dimmed ? 0 : mRoundedRectCornerRadius * state.scale;
            float clippingCorrection = state.dimmed ? (mPerformClipping ? 0 : newHeight)
                    : mRoundedRectCornerRadius * state.scale;

            // When the previous notification is swiped, we don't clip the content to the
            // bottom of it.