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

Commit 17e25d0b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Keep rows opaque for keyguard and HUNs." into main

parents 8ec13e28 60686fd3
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -974,6 +974,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        } else if (isAboveShelf() != wasAboveShelf) {
        } else if (isAboveShelf() != wasAboveShelf) {
            mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
            mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
        }
        }
        updateBackgroundOpacity();
    }
    }


    /**
    /**
@@ -3067,6 +3068,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                    mChildrenContainer.setOnKeyguard(onKeyguard);
                    mChildrenContainer.setOnKeyguard(onKeyguard);
                }
                }
            }
            }
            updateBackgroundOpacity();
        }
        }
    }
    }


@@ -4506,4 +4508,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            return getEntry().isExpandAnimationRunning();
            return getEntry().isExpandAnimationRunning();
        }
        }
    }
    }

    private void updateBackgroundOpacity() {
        if (mBackgroundNormal != null) {
            // Row background should be opaque when it's displayed as a heads-up notification or
            // displayed on keyguard.
            mBackgroundNormal.setForceOpaque(mIsHeadsUp || mOnKeyguard);
        }
    }
}
}
+17 −3
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ import java.util.Arrays;
public class NotificationBackgroundView extends View implements Dumpable,
public class NotificationBackgroundView extends View implements Dumpable,
        ExpandableNotificationRow.DismissButtonTargetVisibilityListener {
        ExpandableNotificationRow.DismissButtonTargetVisibilityListener {


    private static final int MAX_ALPHA = 0xFF;
    private final boolean mDontModifyCorners;
    private final boolean mDontModifyCorners;
    private Drawable mBackground;
    private Drawable mBackground;
    private int mClipTopAmount;
    private int mClipTopAmount;
@@ -74,6 +75,7 @@ public class NotificationBackgroundView extends View implements Dumpable,
    private final ColorStateList mDarkColoredStatefulColors;
    private final ColorStateList mDarkColoredStatefulColors;
    private final int mNormalColor;
    private final int mNormalColor;
    private boolean mBgIsColorized = false;
    private boolean mBgIsColorized = false;
    private boolean mForceOpaque = false;
    private final int convexR = 9;
    private final int convexR = 9;
    private final int concaveR = 22;
    private final int concaveR = 22;


@@ -156,6 +158,14 @@ public class NotificationBackgroundView extends View implements Dumpable,
        mBgIsColorized = b;
        mBgIsColorized = b;
    }
    }


    /** Sets if the background should be opaque. */
    public void setForceOpaque(boolean forceOpaque) {
        mForceOpaque = forceOpaque;
        if (notificationRowTransparency()) {
            updateBaseLayerColor();
        }
    }

    private Path calculateDismissButtonCutoutPath(Rect backgroundBounds) {
    private Path calculateDismissButtonCutoutPath(Rect backgroundBounds) {
        // TODO(b/365585705): Adapt to RTL after the UX design is finalized.
        // TODO(b/365585705): Adapt to RTL after the UX design is finalized.


@@ -317,11 +327,15 @@ public class NotificationBackgroundView extends View implements Dumpable,
        // Instead, we set a color filter that essentially replaces every pixel of the drawable.
        // Instead, we set a color filter that essentially replaces every pixel of the drawable.
        // For non-colorized notifications, this function specifies a new color token.
        // For non-colorized notifications, this function specifies a new color token.
        // For colorized notifications, this uses a color that matches the tint color at 90% alpha.
        // For colorized notifications, this uses a color that matches the tint color at 90% alpha.
        int color = isColorized()
                ? ColorUtils.setAlphaComponent(mTintColor, (int) (MAX_ALPHA * 0.9f))
                : SurfaceEffectColors.surfaceEffect1(getContext());
        if (mForceOpaque) {
            color = ColorUtils.setAlphaComponent(color, MAX_ALPHA);
        }
        getBaseBackgroundLayer().setColorFilter(
        getBaseBackgroundLayer().setColorFilter(
                new PorterDuffColorFilter(
                new PorterDuffColorFilter(
                        isColorized()
                        color,
                                ? ColorUtils.setAlphaComponent(mTintColor, (int) (255 * 0.9f))
                                : SurfaceEffectColors.surfaceEffect1(getContext()),
                        PorterDuff.Mode.SRC)); // SRC operator discards the drawable's color+alpha
                        PorterDuff.Mode.SRC)); // SRC operator discards the drawable's color+alpha
    }
    }