Loading core/java/com/android/internal/widget/NotificationCloseButton.java +12 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.RemotableViewMethod; import android.view.View; Loading @@ -40,6 +42,8 @@ public class NotificationCloseButton extends ImageView { @ColorInt private int mBackgroundColor; @ColorInt private int mForegroundColor; private Drawable mPillDrawable; public NotificationCloseButton(Context context) { this(context, null, 0, 0); } Loading @@ -62,6 +66,10 @@ public class NotificationCloseButton extends ImageView { protected void onFinishInflate() { super.onFinishInflate(); setContentDescription(mContext.getText(R.string.close_button_text)); final LayerDrawable layeredPill = (LayerDrawable) this.getBackground(); mPillDrawable = layeredPill.findDrawableByLayerId(R.id.close_button_pill_colorized_layer); boolean notificationCloseButtonSupported = Resources.getSystem().getBoolean( com.android.internal.R.bool.config_notificationCloseButtonSupported); this.setVisibility(notificationCloseButtonSupported ? View.VISIBLE : View.GONE); Loading @@ -76,8 +84,11 @@ public class NotificationCloseButton extends ImageView { private void updateColors() { if (mBackgroundColor != 0) { this.setBackgroundTintList(ColorStateList.valueOf(mBackgroundColor)); // TODO(http://b/365585705): Ensure this close button compatible with the ongoing effort // that makes notification rows partially-transparent. this.mPillDrawable.setTintList(ColorStateList.valueOf(mBackgroundColor)); } if (mForegroundColor != 0) { this.setImageTintList(ColorStateList.valueOf(mForegroundColor)); } Loading core/res/res/color/notification_close_button_state_tint.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2025 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, softwarere ~ 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"> <item android:color="@color/notification_expand_button_state_tint" /> </selector> No newline at end of file core/res/res/drawable/close_button_bg.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2025 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. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/close_button_pill_colorized_layer"> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="@dimen/notification_close_button_size" /> <solid android:color="@android:color/white" /> </shape> </item> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="@dimen/notification_close_button_size" /> <solid android:color="@color/notification_close_button_state_tint" /> </shape> </item> </layer-list> No newline at end of file core/res/res/layout/notification_close_button.xml +2 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ <com.android.internal.widget.NotificationCloseButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/close_button" android:background="@drawable/close_button_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|end" android:contentDescription="@string/close_button_text" android:visibility="gone" android:src="@drawable/notification_close_button_icon" android:padding="2dp" android:padding="@dimen/notification_close_button_padding" android:scaleType="fitCenter" android:importantForAccessibility="no" > Loading core/res/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -450,6 +450,8 @@ <!-- the size of the notification close button --> <dimen name="notification_close_button_size">16dp</dimen> <dimen name="notification_close_button_padding">2dp</dimen> <!-- Margin for all notification content --> <dimen name="notification_2025_margin">16dp</dimen> Loading Loading
core/java/com/android/internal/widget/NotificationCloseButton.java +12 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.annotation.Nullable; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.RemotableViewMethod; import android.view.View; Loading @@ -40,6 +42,8 @@ public class NotificationCloseButton extends ImageView { @ColorInt private int mBackgroundColor; @ColorInt private int mForegroundColor; private Drawable mPillDrawable; public NotificationCloseButton(Context context) { this(context, null, 0, 0); } Loading @@ -62,6 +66,10 @@ public class NotificationCloseButton extends ImageView { protected void onFinishInflate() { super.onFinishInflate(); setContentDescription(mContext.getText(R.string.close_button_text)); final LayerDrawable layeredPill = (LayerDrawable) this.getBackground(); mPillDrawable = layeredPill.findDrawableByLayerId(R.id.close_button_pill_colorized_layer); boolean notificationCloseButtonSupported = Resources.getSystem().getBoolean( com.android.internal.R.bool.config_notificationCloseButtonSupported); this.setVisibility(notificationCloseButtonSupported ? View.VISIBLE : View.GONE); Loading @@ -76,8 +84,11 @@ public class NotificationCloseButton extends ImageView { private void updateColors() { if (mBackgroundColor != 0) { this.setBackgroundTintList(ColorStateList.valueOf(mBackgroundColor)); // TODO(http://b/365585705): Ensure this close button compatible with the ongoing effort // that makes notification rows partially-transparent. this.mPillDrawable.setTintList(ColorStateList.valueOf(mBackgroundColor)); } if (mForegroundColor != 0) { this.setImageTintList(ColorStateList.valueOf(mForegroundColor)); } Loading
core/res/res/color/notification_close_button_state_tint.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2025 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, softwarere ~ 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"> <item android:color="@color/notification_expand_button_state_tint" /> </selector> No newline at end of file
core/res/res/drawable/close_button_bg.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2025 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. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/close_button_pill_colorized_layer"> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="@dimen/notification_close_button_size" /> <solid android:color="@android:color/white" /> </shape> </item> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="@dimen/notification_close_button_size" /> <solid android:color="@color/notification_close_button_state_tint" /> </shape> </item> </layer-list> No newline at end of file
core/res/res/layout/notification_close_button.xml +2 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ <com.android.internal.widget.NotificationCloseButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/close_button" android:background="@drawable/close_button_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|end" android:contentDescription="@string/close_button_text" android:visibility="gone" android:src="@drawable/notification_close_button_icon" android:padding="2dp" android:padding="@dimen/notification_close_button_padding" android:scaleType="fitCenter" android:importantForAccessibility="no" > Loading
core/res/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -450,6 +450,8 @@ <!-- the size of the notification close button --> <dimen name="notification_close_button_size">16dp</dimen> <dimen name="notification_close_button_padding">2dp</dimen> <!-- Margin for all notification content --> <dimen name="notification_2025_margin">16dp</dimen> Loading