Loading core/java/android/app/Notification.java +39 −9 Original line number Diff line number Diff line Loading @@ -6143,6 +6143,20 @@ public class Notification implements Parcelable result.mTitleMarginSet.applyToView(contentView, p.mTextViewId); contentView.setInt(p.mTextViewId, "setNumIndentLines", p.hasTitle() ? 0 : 1); } // The expand button uses paddings rather than margins, so we'll adjust it // separately. adjustExpandButtonPadding(contentView, result.mRightIconVisible); } private void adjustExpandButtonPadding(RemoteViews contentView, boolean rightIconVisible) { if (notificationsRedesignTemplates()) { final Resources res = mContext.getResources(); int normalPadding = res.getDimensionPixelSize(R.dimen.notification_2025_margin); int iconSpacing = res.getDimensionPixelSize( R.dimen.notification_2025_expand_button_right_icon_spacing); contentView.setInt(R.id.expand_button, "setStartPadding", rightIconVisible ? iconSpacing : normalPadding); } } // This code is executed on behalf of other apps' notifications, sometimes even by 3p apps, Loading @@ -6154,12 +6168,21 @@ public class Notification implements Parcelable @NonNull TemplateBindResult result) { final Resources resources = mContext.getResources(); final float density = resources.getDisplayMetrics().density; final float iconMarginDp = resources.getDimension( R.dimen.notification_right_icon_content_margin) / density; int iconMarginId = notificationsRedesignTemplates() ? R.dimen.notification_2025_right_icon_content_margin : R.dimen.notification_right_icon_content_margin; final float iconMarginDp = resources.getDimension(iconMarginId) / density; final float contentMarginDp = resources.getDimension( R.dimen.notification_content_margin_end) / density; final float expanderSizeDp = resources.getDimension( float spaceForExpanderDp; if (notificationsRedesignTemplates()) { spaceForExpanderDp = resources.getDimension( R.dimen.notification_2025_right_icon_expanded_margin_end) / density - contentMarginDp; } else { spaceForExpanderDp = resources.getDimension( R.dimen.notification_header_expand_icon_size) / density - contentMarginDp; } final float viewHeightDp = resources.getDimension( R.dimen.notification_right_icon_size) / density; float viewWidthDp = viewHeightDp; // icons are 1:1 by default Loading @@ -6176,9 +6199,10 @@ public class Notification implements Parcelable } } } // Margin needed for the header to accommodate the icon when shown final float extraMarginEndDpIfVisible = viewWidthDp + iconMarginDp; result.setRightIconState(rightIcon != null /* visible */, viewWidthDp, viewHeightDp, extraMarginEndDpIfVisible, expanderSizeDp); viewHeightDp, extraMarginEndDpIfVisible, spaceForExpanderDp); } /** Loading Loading @@ -14658,13 +14682,19 @@ public class Notification implements Parcelable public final MarginSet mTitleMarginSet = new MarginSet(); public void setRightIconState(boolean visible, float widthDp, float heightDp, float marginEndDpIfVisible, float expanderSizeDp) { float marginEndDpIfVisible, float spaceForExpanderDp) { mRightIconVisible = visible; mRightIconWidthDp = widthDp; mRightIconHeightDp = heightDp; mHeadingExtraMarginSet.setValues(0, marginEndDpIfVisible); mHeadingFullMarginSet.setValues(expanderSizeDp, marginEndDpIfVisible + expanderSizeDp); mTitleMarginSet.setValues(0, marginEndDpIfVisible + expanderSizeDp); mHeadingExtraMarginSet.setValues( /* valueIfGone = */ 0, /* valueIfVisible = */ marginEndDpIfVisible); mHeadingFullMarginSet.setValues( /* valueIfGone = */ spaceForExpanderDp, /* valueIfVisible = */ marginEndDpIfVisible + spaceForExpanderDp); mTitleMarginSet.setValues( /* valueIfGone = */ 0, /* valueIfVisible = */ marginEndDpIfVisible + spaceForExpanderDp); } /** core/java/com/android/internal/widget/NotificationExpandButton.java +10 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,16 @@ public class NotificationExpandButton extends FrameLayout { updateExpandedState(); } /** * Adjust the padding at the start of the view based on the layout direction (RTL/LTR). * This is needed because RemoteViews don't have an equivalent for * {@link this#setPaddingRelative}. */ @RemotableViewMethod public void setStartPadding(int startPadding) { setPaddingRelative(startPadding, getPaddingTop(), getPaddingEnd(), getPaddingBottom()); } private void updateExpandedState() { int drawableId; int contentDescriptionId; Loading core/res/res/layout/notification_2025_expand_button.xml +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ --> <!-- extends FrameLayout --> <!-- Note: The button's padding may be dynamically adjusted in code --> <com.android.internal.widget.NotificationExpandButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/expand_button" Loading core/res/res/layout/notification_2025_right_icon.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?><!-- ~ 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 --> <!-- Large icon to be used in expanded notification layouts. --> <com.android.internal.widget.CachingIconView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/right_icon" android:layout_width="@dimen/notification_right_icon_size" android:layout_height="@dimen/notification_right_icon_size" android:layout_gravity="top|end" android:layout_marginEnd="@dimen/notification_2025_right_icon_expanded_margin_end" android:layout_marginVertical="@dimen/notification_2025_right_icon_vertical_margin" android:background="@drawable/notification_large_icon_outline" android:clipToOutline="true" android:importantForAccessibility="no" android:scaleType="centerCrop" android:maxDrawableWidth="@dimen/notification_right_icon_size" android:maxDrawableHeight="@dimen/notification_right_icon_size" /> core/res/res/layout/notification_2025_template_collapsed_base.xml +2 −3 Original line number Diff line number Diff line Loading @@ -146,9 +146,8 @@ android:layout_width="@dimen/notification_right_icon_size" android:layout_height="@dimen/notification_right_icon_size" android:layout_gravity="center_vertical|end" android:layout_marginTop="@dimen/notification_right_icon_headerless_margin" android:layout_marginBottom="@dimen/notification_right_icon_headerless_margin" android:layout_marginStart="@dimen/notification_right_icon_content_margin" android:layout_marginVertical="@dimen/notification_2025_right_icon_vertical_margin" android:layout_marginStart="@dimen/notification_2025_right_icon_content_margin" android:background="@drawable/notification_large_icon_outline" android:clipToOutline="true" android:importantForAccessibility="no" Loading Loading
core/java/android/app/Notification.java +39 −9 Original line number Diff line number Diff line Loading @@ -6143,6 +6143,20 @@ public class Notification implements Parcelable result.mTitleMarginSet.applyToView(contentView, p.mTextViewId); contentView.setInt(p.mTextViewId, "setNumIndentLines", p.hasTitle() ? 0 : 1); } // The expand button uses paddings rather than margins, so we'll adjust it // separately. adjustExpandButtonPadding(contentView, result.mRightIconVisible); } private void adjustExpandButtonPadding(RemoteViews contentView, boolean rightIconVisible) { if (notificationsRedesignTemplates()) { final Resources res = mContext.getResources(); int normalPadding = res.getDimensionPixelSize(R.dimen.notification_2025_margin); int iconSpacing = res.getDimensionPixelSize( R.dimen.notification_2025_expand_button_right_icon_spacing); contentView.setInt(R.id.expand_button, "setStartPadding", rightIconVisible ? iconSpacing : normalPadding); } } // This code is executed on behalf of other apps' notifications, sometimes even by 3p apps, Loading @@ -6154,12 +6168,21 @@ public class Notification implements Parcelable @NonNull TemplateBindResult result) { final Resources resources = mContext.getResources(); final float density = resources.getDisplayMetrics().density; final float iconMarginDp = resources.getDimension( R.dimen.notification_right_icon_content_margin) / density; int iconMarginId = notificationsRedesignTemplates() ? R.dimen.notification_2025_right_icon_content_margin : R.dimen.notification_right_icon_content_margin; final float iconMarginDp = resources.getDimension(iconMarginId) / density; final float contentMarginDp = resources.getDimension( R.dimen.notification_content_margin_end) / density; final float expanderSizeDp = resources.getDimension( float spaceForExpanderDp; if (notificationsRedesignTemplates()) { spaceForExpanderDp = resources.getDimension( R.dimen.notification_2025_right_icon_expanded_margin_end) / density - contentMarginDp; } else { spaceForExpanderDp = resources.getDimension( R.dimen.notification_header_expand_icon_size) / density - contentMarginDp; } final float viewHeightDp = resources.getDimension( R.dimen.notification_right_icon_size) / density; float viewWidthDp = viewHeightDp; // icons are 1:1 by default Loading @@ -6176,9 +6199,10 @@ public class Notification implements Parcelable } } } // Margin needed for the header to accommodate the icon when shown final float extraMarginEndDpIfVisible = viewWidthDp + iconMarginDp; result.setRightIconState(rightIcon != null /* visible */, viewWidthDp, viewHeightDp, extraMarginEndDpIfVisible, expanderSizeDp); viewHeightDp, extraMarginEndDpIfVisible, spaceForExpanderDp); } /** Loading Loading @@ -14658,13 +14682,19 @@ public class Notification implements Parcelable public final MarginSet mTitleMarginSet = new MarginSet(); public void setRightIconState(boolean visible, float widthDp, float heightDp, float marginEndDpIfVisible, float expanderSizeDp) { float marginEndDpIfVisible, float spaceForExpanderDp) { mRightIconVisible = visible; mRightIconWidthDp = widthDp; mRightIconHeightDp = heightDp; mHeadingExtraMarginSet.setValues(0, marginEndDpIfVisible); mHeadingFullMarginSet.setValues(expanderSizeDp, marginEndDpIfVisible + expanderSizeDp); mTitleMarginSet.setValues(0, marginEndDpIfVisible + expanderSizeDp); mHeadingExtraMarginSet.setValues( /* valueIfGone = */ 0, /* valueIfVisible = */ marginEndDpIfVisible); mHeadingFullMarginSet.setValues( /* valueIfGone = */ spaceForExpanderDp, /* valueIfVisible = */ marginEndDpIfVisible + spaceForExpanderDp); mTitleMarginSet.setValues( /* valueIfGone = */ 0, /* valueIfVisible = */ marginEndDpIfVisible + spaceForExpanderDp); } /**
core/java/com/android/internal/widget/NotificationExpandButton.java +10 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,16 @@ public class NotificationExpandButton extends FrameLayout { updateExpandedState(); } /** * Adjust the padding at the start of the view based on the layout direction (RTL/LTR). * This is needed because RemoteViews don't have an equivalent for * {@link this#setPaddingRelative}. */ @RemotableViewMethod public void setStartPadding(int startPadding) { setPaddingRelative(startPadding, getPaddingTop(), getPaddingEnd(), getPaddingBottom()); } private void updateExpandedState() { int drawableId; int contentDescriptionId; Loading
core/res/res/layout/notification_2025_expand_button.xml +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ --> <!-- extends FrameLayout --> <!-- Note: The button's padding may be dynamically adjusted in code --> <com.android.internal.widget.NotificationExpandButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/expand_button" Loading
core/res/res/layout/notification_2025_right_icon.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?><!-- ~ 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 --> <!-- Large icon to be used in expanded notification layouts. --> <com.android.internal.widget.CachingIconView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/right_icon" android:layout_width="@dimen/notification_right_icon_size" android:layout_height="@dimen/notification_right_icon_size" android:layout_gravity="top|end" android:layout_marginEnd="@dimen/notification_2025_right_icon_expanded_margin_end" android:layout_marginVertical="@dimen/notification_2025_right_icon_vertical_margin" android:background="@drawable/notification_large_icon_outline" android:clipToOutline="true" android:importantForAccessibility="no" android:scaleType="centerCrop" android:maxDrawableWidth="@dimen/notification_right_icon_size" android:maxDrawableHeight="@dimen/notification_right_icon_size" />
core/res/res/layout/notification_2025_template_collapsed_base.xml +2 −3 Original line number Diff line number Diff line Loading @@ -146,9 +146,8 @@ android:layout_width="@dimen/notification_right_icon_size" android:layout_height="@dimen/notification_right_icon_size" android:layout_gravity="center_vertical|end" android:layout_marginTop="@dimen/notification_right_icon_headerless_margin" android:layout_marginBottom="@dimen/notification_right_icon_headerless_margin" android:layout_marginStart="@dimen/notification_right_icon_content_margin" android:layout_marginVertical="@dimen/notification_2025_right_icon_vertical_margin" android:layout_marginStart="@dimen/notification_2025_right_icon_content_margin" android:background="@drawable/notification_large_icon_outline" android:clipToOutline="true" android:importantForAccessibility="no" Loading