diff options
| author | 2023-11-27 19:25:25 +0000 | |
|---|---|---|
| committer | 2023-11-27 19:26:56 +0000 | |
| commit | 63eefdc6cf672f628f86d6fd25476457fa2482c6 (patch) | |
| tree | dd5a5032c14325024920e93cbee0d1bc3c86d04f | |
| parent | a47ea5ec42337124cfa1e72ee1d2ce12f486abdc (diff) | |
Revert "Restore the notification background's hovered/pressed tints"
This reverts commit a47ea5ec42337124cfa1e72ee1d2ce12f486abdc.
Reason for revert: b/312841260
Fixes: 312841260
Change-Id: I28c06042d0e478bb76fb719c19deb9c8008050ea
Test: manual, post colorized notif before and after revert
Flag: NA
| -rw-r--r-- | packages/SystemUI/res/drawable/notification_material_bg.xml | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java | 51 |
2 files changed, 14 insertions, 39 deletions
diff --git a/packages/SystemUI/res/drawable/notification_material_bg.xml b/packages/SystemUI/res/drawable/notification_material_bg.xml index 9c08f5ef4cfe..355e75d0716b 100644 --- a/packages/SystemUI/res/drawable/notification_material_bg.xml +++ b/packages/SystemUI/res/drawable/notification_material_bg.xml @@ -18,7 +18,7 @@ <layer-list xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:color="?android:attr/colorControlHighlight"> - <item android:id="@+id/notification_background_color_layer"> + <item> <shape> <solid android:color="?androidprv:attr/materialColorSurfaceContainerHigh" /> </shape> 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 64f61d9ac2da..8eda96f62257 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 @@ -27,7 +27,6 @@ import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; -import android.util.Log; import android.view.View; import androidx.annotation.NonNull; @@ -43,11 +42,9 @@ import java.util.Arrays; * A view that can be used for both the dimmed and normal background of an notification. */ public class NotificationBackgroundView extends View implements Dumpable { - private static final String TAG = "NotificationBackgroundView"; private final boolean mDontModifyCorners; private Drawable mBackground; - private Drawable mBackgroundDrawableToTint; private int mClipTopAmount; private int mClipBottomAmount; private int mTintColor; @@ -134,7 +131,6 @@ public class NotificationBackgroundView extends View implements Dumpable { unscheduleDrawable(mBackground); } mBackground = background; - mBackgroundDrawableToTint = findBackgroundDrawableToTint(mBackground); mRippleColor = null; mBackground.mutate(); if (mBackground != null) { @@ -148,46 +144,25 @@ public class NotificationBackgroundView extends View implements Dumpable { invalidate(); } - // setCustomBackground should be called from ActivatableNotificationView.initBackground - // with R.drawable.notification_material_bg, which is a layer-list with a lower layer - // for the background color (annotated with an ID so we can find it) and an upper layer - // to blend in the stateful @color/notification_overlay_color. - // - // If the notification is tinted, we want to set a tint list on *just that lower layer* that - // will replace the default materialColorSurfaceContainerHigh *without* wiping out the stateful - // tints in the upper layer that make the hovered and pressed states visible. - // - // This function fishes that lower layer out, or makes a fuss in logcat if it can't find it. - private @Nullable Drawable findBackgroundDrawableToTint(@Nullable Drawable background) { - if (background == null) { - return null; - } - - if (!(background instanceof LayerDrawable)) { - Log.wtf(TAG, "background is not a LayerDrawable: " + background); - return background; - } - - final Drawable backgroundColorLayer = ((LayerDrawable) background).findDrawableByLayerId( - R.id.notification_background_color_layer); - - if (backgroundColorLayer == null) { - Log.wtf(TAG, "background is missing background color layer: " + background); - return background; - } - - return backgroundColorLayer; - } - public void setCustomBackground(int drawableResId) { final Drawable d = mContext.getDrawable(drawableResId); setCustomBackground(d); } public void setTint(int tintColor) { - mBackgroundDrawableToTint.setTint(tintColor); - mBackgroundDrawableToTint.setTintMode(PorterDuff.Mode.SRC_ATOP); - + if (tintColor != 0) { + ColorStateList stateList = new ColorStateList(new int[][]{ + new int[]{com.android.internal.R.attr.state_pressed}, + new int[]{com.android.internal.R.attr.state_hovered}, + new int[]{}}, + + new int[]{tintColor, tintColor, tintColor} + ); + mBackground.setTintMode(PorterDuff.Mode.SRC_ATOP); + mBackground.setTintList(stateList); + } else { + mBackground.setTintList(null); + } mTintColor = tintColor; invalidate(); } |