diff options
3 files changed, 58 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index b4092cd785bf..b0773276a3e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.row; import static com.android.systemui.Flags.notificationBackgroundTintOptimization; +import static com.android.systemui.Flags.notificationRowTransparency; import static com.android.systemui.statusbar.notification.row.ExpandableView.ClipSide.BOTTOM; import static com.android.systemui.statusbar.notification.row.ExpandableView.ClipSide.TOP; @@ -38,6 +39,7 @@ import com.android.app.animation.Interpolators; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.jank.InteractionJankMonitor.Configuration; import com.android.systemui.Gefingerpoken; +import com.android.systemui.common.shared.colors.SurfaceEffectColors; import com.android.systemui.res.R; import com.android.systemui.shade.TouchLogger; import com.android.systemui.statusbar.NotificationShelf; @@ -122,8 +124,12 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView } private void updateColors() { - mNormalColor = mContext.getColor( - com.android.internal.R.color.materialColorSurfaceContainerHigh); + if (notificationRowTransparency()) { + mNormalColor = SurfaceEffectColors.surfaceEffect1(getResources()); + } else { + mNormalColor = mContext.getColor( + com.android.internal.R.color.materialColorSurfaceContainerHigh); + } mTintedRippleColor = mContext.getColor( R.color.notification_ripple_tinted_color); mNormalRippleColor = mContext.getColor( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 66a0fb4ee4ab..64cd6174a585 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -21,6 +21,7 @@ import static android.app.Notification.Action.SEMANTIC_ACTION_MARK_CONVERSATION_ import static android.service.notification.NotificationListenerService.REASON_CANCEL; import static com.android.systemui.Flags.notificationsPinnedHunInShade; +import static com.android.systemui.Flags.notificationRowTransparency; import static com.android.systemui.flags.Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE; import static com.android.systemui.statusbar.notification.NotificationUtils.logKey; import static com.android.systemui.statusbar.notification.collection.NotificationEntry.DismissState.PARENT_DISMISSED; @@ -1636,6 +1637,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (view != null) { view.setBackgroundTintColor(color); } + if (notificationRowTransparency() + && (mBackgroundNormal != null) + && (mEntry != null)) { + mBackgroundNormal.setBgIsColorized( + mEntry.getSbn().getNotification().isColorized()); + } } public void closeRemoteInput() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java index dd3a9c9dcf21..33c36d8c4c76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.notification.row; +import static com.android.systemui.Flags.notificationRowTransparency; import static com.android.systemui.util.ColorUtilKt.hexColorString; import android.content.Context; @@ -23,6 +24,7 @@ import android.content.res.ColorStateList; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -34,8 +36,10 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.internal.graphics.ColorUtils; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.Dumpable; +import com.android.systemui.common.shared.colors.SurfaceEffectColors; import com.android.systemui.res.R; import com.android.systemui.statusbar.notification.shared.NotificationAddXOnHoverToDismiss; import com.android.systemui.util.DrawableDumpKt; @@ -69,6 +73,7 @@ public class NotificationBackgroundView extends View implements Dumpable, private final ColorStateList mLightColoredStatefulColors; private final ColorStateList mDarkColoredStatefulColors; private final int mNormalColor; + private boolean mBgIsColorized = false; private final int convexR = 9; private final int concaveR = 22; @@ -82,8 +87,12 @@ public class NotificationBackgroundView extends View implements Dumpable, R.color.notification_state_color_light); mDarkColoredStatefulColors = getResources().getColorStateList( R.color.notification_state_color_dark); - mNormalColor = mContext.getColor( - com.android.internal.R.color.materialColorSurfaceContainerHigh); + if (notificationRowTransparency()) { + mNormalColor = SurfaceEffectColors.surfaceEffect1(getResources()); + } else { + mNormalColor = mContext.getColor( + com.android.internal.R.color.materialColorSurfaceContainerHigh); + } mFocusOverlayStroke = getResources().getDimension(R.dimen.notification_focus_stroke_width); } @@ -132,6 +141,21 @@ public class NotificationBackgroundView extends View implements Dumpable, } } + /** + * A way to tell whether the background has been colorized. + */ + public boolean isColorized() { + return mBgIsColorized; + } + + /** + * A way to inform this class whether the background has been colorized. + * We need to know this, in order to *not* override that color. + */ + public void setBgIsColorized(boolean b) { + mBgIsColorized = b; + } + private Path calculateDismissButtonCutoutPath(Rect backgroundBounds) { // TODO(b/365585705): Adapt to RTL after the UX design is finalized. @@ -280,7 +304,7 @@ public class NotificationBackgroundView extends View implements Dumpable, setCustomBackground(d); } - private Drawable getBaseBackgroundLayer() { + public Drawable getBaseBackgroundLayer() { return ((LayerDrawable) mBackground).getDrawable(0); } @@ -288,11 +312,27 @@ public class NotificationBackgroundView extends View implements Dumpable, return ((LayerDrawable) mBackground).getDrawable(1); } + private void updateBaseLayerColor() { + // BG base layer being a drawable, there isn't a method like setColor() to color it. + // 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 colorized notifications, this uses a color that matches the tint color at 90% alpha. + getBaseBackgroundLayer().setColorFilter( + new PorterDuffColorFilter( + isColorized() + ? ColorUtils.setAlphaComponent(mTintColor, (int) (255 * 0.9f)) + : SurfaceEffectColors.surfaceEffect1(getResources()), + PorterDuff.Mode.SRC)); // SRC operator discards the drawable's color+alpha + } + public void setTint(int tintColor) { Drawable baseLayer = getBaseBackgroundLayer(); baseLayer.mutate().setTintMode(PorterDuff.Mode.SRC_ATOP); baseLayer.setTint(tintColor); mTintColor = tintColor; + if (notificationRowTransparency()) { + updateBaseLayerColor(); + } setStatefulColors(); invalidate(); } |