Loading packages/SystemUI/res/color/notification_state_color_dark.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <!-- Pressed state's alpha is set to 0.00 temporarily until this bug is resolved permanently b/313920497 Design intended alpha is 0.15--> <item android:state_pressed="true" android:color="#ffffff" android:alpha="0.00" /> <item android:state_hovered="true" android:color="#ffffff" android:alpha="0.11" /> <item android:color="@color/transparent" /> </selector> No newline at end of file packages/SystemUI/res/color/notification_overlay_color.xml→packages/SystemUI/res/color/notification_state_color_default.xml +0 −0 File moved. View file packages/SystemUI/res/color/notification_state_color_light.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <!-- Pressed state's alpha is set to 0.00 temporarily until this bug is resolved permanently b/313920497 Design intended alpha is 0.15--> <item android:state_pressed="true" android:color="#000000" android:alpha="0.00" /> <item android:state_hovered="true" android:color="#000000" android:alpha="0.11" /> <item android:color="@color/transparent" /> </selector> No newline at end of file packages/SystemUI/res/drawable/notification_material_bg.xml +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ </item> <item> <shape> <solid android:color="@color/notification_overlay_color" /> <solid android:color="@color/notification_state_color_default" /> </shape> </item> </layer-list> No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +36 −15 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.util.ContrastColorUtil; import com.android.settingslib.Utils; import com.android.systemui.Dumpable; import com.android.systemui.res.R; Loading @@ -58,11 +60,19 @@ public class NotificationBackgroundView extends View implements Dumpable { private int mExpandAnimationWidth = -1; private int mExpandAnimationHeight = -1; private int mDrawableAlpha = 255; private final ColorStateList mLightColoredStatefulColors; private final ColorStateList mDarkColoredStatefulColors; private final int mNormalColor; public NotificationBackgroundView(Context context, AttributeSet attrs) { super(context, attrs); mDontModifyCorners = getResources().getBoolean( R.bool.config_clipNotificationsToOutline); mDontModifyCorners = getResources().getBoolean(R.bool.config_clipNotificationsToOutline); mLightColoredStatefulColors = getResources().getColorStateList( R.color.notification_state_color_light); mDarkColoredStatefulColors = getResources().getColorStateList( R.color.notification_state_color_dark); mNormalColor = Utils.getColorAttrDefaultColor(mContext, com.android.internal.R.attr.materialColorSurfaceContainerHigh); } @Override Loading Loading @@ -121,6 +131,18 @@ public class NotificationBackgroundView extends View implements Dumpable { } } /** * Stateful colors are colors that will overlay on the notification original color when one of * hover states, pressed states or other similar states is activated. */ private void setStatefulColors() { if (mTintColor != mNormalColor) { ColorStateList newColor = ContrastColorUtil.isColorDark(mTintColor) ? mDarkColoredStatefulColors : mLightColoredStatefulColors; ((GradientDrawable) getStatefulBackgroundLayer().mutate()).setColor(newColor); } } /** * Sets a background drawable. As we need to change our bounds independently of layout, we need * the notion of a background independently of the regular View background.. Loading Loading @@ -149,21 +171,20 @@ public class NotificationBackgroundView extends View implements Dumpable { setCustomBackground(d); } public void setTint(int tintColor) { 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, 0, tintColor} ); mBackground.setTintMode(PorterDuff.Mode.SRC_ATOP); mBackground.setTintList(stateList); } else { mBackground.setTintList(null); private Drawable getBaseBackgroundLayer() { return ((LayerDrawable) mBackground).getDrawable(0); } private Drawable getStatefulBackgroundLayer() { return ((LayerDrawable) mBackground).getDrawable(1); } public void setTint(int tintColor) { Drawable baseLayer = getBaseBackgroundLayer(); baseLayer.mutate().setTintMode(PorterDuff.Mode.SRC_ATOP); baseLayer.setTint(tintColor); mTintColor = tintColor; setStatefulColors(); invalidate(); } Loading Loading
packages/SystemUI/res/color/notification_state_color_dark.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <!-- Pressed state's alpha is set to 0.00 temporarily until this bug is resolved permanently b/313920497 Design intended alpha is 0.15--> <item android:state_pressed="true" android:color="#ffffff" android:alpha="0.00" /> <item android:state_hovered="true" android:color="#ffffff" android:alpha="0.11" /> <item android:color="@color/transparent" /> </selector> No newline at end of file
packages/SystemUI/res/color/notification_overlay_color.xml→packages/SystemUI/res/color/notification_state_color_default.xml +0 −0 File moved. View file
packages/SystemUI/res/color/notification_state_color_light.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <!-- Pressed state's alpha is set to 0.00 temporarily until this bug is resolved permanently b/313920497 Design intended alpha is 0.15--> <item android:state_pressed="true" android:color="#000000" android:alpha="0.00" /> <item android:state_hovered="true" android:color="#000000" android:alpha="0.11" /> <item android:color="@color/transparent" /> </selector> No newline at end of file
packages/SystemUI/res/drawable/notification_material_bg.xml +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ </item> <item> <shape> <solid android:color="@color/notification_overlay_color" /> <solid android:color="@color/notification_state_color_default" /> </shape> </item> </layer-list> No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java +36 −15 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.util.ContrastColorUtil; import com.android.settingslib.Utils; import com.android.systemui.Dumpable; import com.android.systemui.res.R; Loading @@ -58,11 +60,19 @@ public class NotificationBackgroundView extends View implements Dumpable { private int mExpandAnimationWidth = -1; private int mExpandAnimationHeight = -1; private int mDrawableAlpha = 255; private final ColorStateList mLightColoredStatefulColors; private final ColorStateList mDarkColoredStatefulColors; private final int mNormalColor; public NotificationBackgroundView(Context context, AttributeSet attrs) { super(context, attrs); mDontModifyCorners = getResources().getBoolean( R.bool.config_clipNotificationsToOutline); mDontModifyCorners = getResources().getBoolean(R.bool.config_clipNotificationsToOutline); mLightColoredStatefulColors = getResources().getColorStateList( R.color.notification_state_color_light); mDarkColoredStatefulColors = getResources().getColorStateList( R.color.notification_state_color_dark); mNormalColor = Utils.getColorAttrDefaultColor(mContext, com.android.internal.R.attr.materialColorSurfaceContainerHigh); } @Override Loading Loading @@ -121,6 +131,18 @@ public class NotificationBackgroundView extends View implements Dumpable { } } /** * Stateful colors are colors that will overlay on the notification original color when one of * hover states, pressed states or other similar states is activated. */ private void setStatefulColors() { if (mTintColor != mNormalColor) { ColorStateList newColor = ContrastColorUtil.isColorDark(mTintColor) ? mDarkColoredStatefulColors : mLightColoredStatefulColors; ((GradientDrawable) getStatefulBackgroundLayer().mutate()).setColor(newColor); } } /** * Sets a background drawable. As we need to change our bounds independently of layout, we need * the notion of a background independently of the regular View background.. Loading Loading @@ -149,21 +171,20 @@ public class NotificationBackgroundView extends View implements Dumpable { setCustomBackground(d); } public void setTint(int tintColor) { 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, 0, tintColor} ); mBackground.setTintMode(PorterDuff.Mode.SRC_ATOP); mBackground.setTintList(stateList); } else { mBackground.setTintList(null); private Drawable getBaseBackgroundLayer() { return ((LayerDrawable) mBackground).getDrawable(0); } private Drawable getStatefulBackgroundLayer() { return ((LayerDrawable) mBackground).getDrawable(1); } public void setTint(int tintColor) { Drawable baseLayer = getBaseBackgroundLayer(); baseLayer.mutate().setTintMode(PorterDuff.Mode.SRC_ATOP); baseLayer.setTint(tintColor); mTintColor = tintColor; setStatefulColors(); invalidate(); } Loading