diff options
21 files changed, 282 insertions, 108 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 127a08b04e87..feaa98f644a0 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -6453,45 +6453,47 @@ public class Notification implements Parcelable return mN.showsTime() || mN.showsChronometer(); } - private void resetStandardTemplateWithActions(RemoteViews big) { + private void resetStandardTemplateWithActions(RemoteViews contentView) { // actions_container is only reset when there are no actions to avoid focus issues with // remote inputs. - big.setViewVisibility(R.id.actions, View.GONE); - big.removeAllViews(R.id.actions); - - big.setViewVisibility(R.id.notification_material_reply_container, View.GONE); - big.setTextViewText(R.id.notification_material_reply_text_1, null); - big.setViewVisibility(R.id.notification_material_reply_text_1_container, View.GONE); - big.setViewVisibility(R.id.notification_material_reply_progress, View.GONE); - - big.setViewVisibility(R.id.notification_material_reply_text_2, View.GONE); - big.setTextViewText(R.id.notification_material_reply_text_2, null); - big.setViewVisibility(R.id.notification_material_reply_text_3, View.GONE); - big.setTextViewText(R.id.notification_material_reply_text_3, null); - - // This may get erased by bindSnoozeAction - big.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, + contentView.setViewVisibility(R.id.actions, View.GONE); + contentView.removeAllViews(R.id.actions); + + contentView.setViewVisibility(R.id.notification_material_reply_container, View.GONE); + contentView.setTextViewText(R.id.notification_material_reply_text_1, null); + contentView.setViewVisibility(R.id.notification_material_reply_text_1_container, + View.GONE); + contentView.setViewVisibility(R.id.notification_material_reply_progress, View.GONE); + + contentView.setViewVisibility(R.id.notification_material_reply_text_2, View.GONE); + contentView.setTextViewText(R.id.notification_material_reply_text_2, null); + contentView.setViewVisibility(R.id.notification_material_reply_text_3, View.GONE); + contentView.setTextViewText(R.id.notification_material_reply_text_3, null); + + // This may get erased by bindSnoozeAction, or if we're showing the bubble icon + contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, RemoteViews.MARGIN_BOTTOM, R.dimen.notification_content_margin); } - private void bindSnoozeAction(RemoteViews big, StandardTemplateParams p) { + private boolean bindSnoozeAction(RemoteViews contentView, StandardTemplateParams p) { boolean hideSnoozeButton = mN.isFgsOrUij() || mN.fullScreenIntent != null || isBackgroundColorized(p) || p.mViewType != StandardTemplateParams.VIEW_TYPE_EXPANDED; - big.setBoolean(R.id.snooze_button, "setEnabled", !hideSnoozeButton); + contentView.setBoolean(R.id.snooze_button, "setEnabled", !hideSnoozeButton); if (hideSnoozeButton) { // Only hide; NotificationContentView will show it when it adds the click listener - big.setViewVisibility(R.id.snooze_button, View.GONE); + contentView.setViewVisibility(R.id.snooze_button, View.GONE); } final boolean snoozeEnabled = !hideSnoozeButton && mContext.getContentResolver() != null && isSnoozeSettingEnabled(); if (snoozeEnabled) { - big.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, + contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, RemoteViews.MARGIN_BOTTOM, 0); } + return snoozeEnabled; } private boolean isSnoozeSettingEnabled() { @@ -6526,16 +6528,14 @@ public class Notification implements Parcelable private RemoteViews applyStandardTemplateWithActions(int layoutId, StandardTemplateParams p, TemplateBindResult result) { - RemoteViews big = applyStandardTemplate(layoutId, p, result); + RemoteViews contentView = applyStandardTemplate(layoutId, p, result); - resetStandardTemplateWithActions(big); - bindSnoozeAction(big, p); + resetStandardTemplateWithActions(contentView); + boolean snoozeEnabled = bindSnoozeAction(contentView, p); // color the snooze and bubble actions with the theme color ColorStateList actionColor = ColorStateList.valueOf(getStandardActionColor(p)); - big.setColorStateList(R.id.snooze_button, "setImageTintList", actionColor); - big.setColorStateList(R.id.bubble_button, "setImageTintList", actionColor); - - boolean validRemoteInput = false; + contentView.setColorStateList(R.id.snooze_button, "setImageTintList", actionColor); + contentView.setColorStateList(R.id.bubble_button, "setImageTintList", actionColor); // In the UI, contextual actions appear separately from the standard actions, so we // filter them out here. @@ -6549,47 +6549,64 @@ public class Notification implements Parcelable if (p.mCallStyleActions) { // Clear view padding to allow buttons to start on the left edge. // This must be done before 'setEmphasizedMode' which sets top/bottom margins. - big.setViewPadding(R.id.actions, 0, 0, 0, 0); + contentView.setViewPadding(R.id.actions, 0, 0, 0, 0); if (!Flags.notificationsRedesignTemplates()) { // Add an optional indent that will make buttons start at the correct column // when there is enough space to do so (and fall back to the left edge if not). // This is handled directly in NotificationActionListLayout in the new design. - big.setInt(R.id.actions, "setCollapsibleIndentDimen", + contentView.setInt(R.id.actions, "setCollapsibleIndentDimen", R.dimen.call_notification_collapsible_indent); } if (evenlyDividedCallStyleActionLayout()) { if (CallStyle.DEBUG_NEW_ACTION_LAYOUT) { Log.d(TAG, "setting evenly divided mode on action list"); } - big.setBoolean(R.id.actions, "setEvenlyDividedMode", true); + contentView.setBoolean(R.id.actions, "setEvenlyDividedMode", true); } } - big.setBoolean(R.id.actions, "setEmphasizedMode", emphasizedMode); + if (!notificationsRedesignTemplates()) { + contentView.setBoolean(R.id.actions, "setEmphasizedMode", emphasizedMode); + } + + boolean validRemoteInput = false; if (numActions > 0 && !p.mHideActions) { - big.setViewVisibility(R.id.actions_container, View.VISIBLE); - big.setViewVisibility(R.id.actions, View.VISIBLE); - big.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, + contentView.setViewVisibility(R.id.actions_container, View.VISIBLE); + contentView.setViewVisibility(R.id.actions, View.VISIBLE); + contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target, RemoteViews.MARGIN_BOTTOM, 0); - for (int i = 0; i < numActions; i++) { - Action action = nonContextualActions.get(i); - - boolean actionHasValidInput = hasValidRemoteInput(action); - validRemoteInput |= actionHasValidInput; - - final RemoteViews button = generateActionButton(action, emphasizedMode, p); - if (actionHasValidInput && !emphasizedMode) { - // Clear the drawable - button.setInt(R.id.action0, "setBackgroundResource", 0); - } - if (emphasizedMode && i > 0) { - // Clear start margin from non-first buttons to reduce the gap between them. - // (8dp remaining gap is from all buttons' standard 4dp inset). - button.setViewLayoutMarginDimen(R.id.action0, RemoteViews.MARGIN_START, 0); + if (notificationsRedesignTemplates()) { + // No need for additional space under smart replies/smart actions. + contentView.setViewLayoutMarginDimen(R.id.smart_reply_container, + RemoteViews.MARGIN_BOTTOM, 0); + if (emphasizedMode) { + // Emphasized actions look similar to smart replies, so let's use the same + // margins. + contentView.setViewLayoutMarginDimen(R.id.actions_container, + RemoteViews.MARGIN_TOP, + R.dimen.notification_2025_smart_reply_container_margin); + contentView.setViewLayoutMarginDimen(R.id.actions_container, + RemoteViews.MARGIN_BOTTOM, + R.dimen.notification_2025_smart_reply_container_margin); + } else { + contentView.setViewLayoutMarginDimen(R.id.actions_container, + RemoteViews.MARGIN_TOP, 0); + contentView.setViewLayoutMarginDimen(R.id.actions_container, + RemoteViews.MARGIN_BOTTOM, + R.dimen.notification_2025_action_list_margin_bottom); } - big.addView(R.id.actions, button); } + validRemoteInput = populateActionsContainer(contentView, p, nonContextualActions, + numActions, emphasizedMode); } else { - big.setViewVisibility(R.id.actions_container, View.GONE); + contentView.setViewVisibility(R.id.actions_container, View.GONE); + if (notificationsRedesignTemplates() && !snoozeEnabled) { + // Make sure smart replies & smart actions have enough space at the bottom + // (if present) when there are no actions. This should be set to 0 if we're + // showing the snooze or bubble buttons. + contentView.setViewLayoutMarginDimen(R.id.smart_reply_container, + RemoteViews.MARGIN_BOTTOM, + R.dimen.notification_2025_smart_reply_container_margin); + } } RemoteInputHistoryItem[] replyText = getParcelableArrayFromBundle( @@ -6598,37 +6615,65 @@ public class Notification implements Parcelable && !TextUtils.isEmpty(replyText[0].getText()) && p.maxRemoteInputHistory > 0) { boolean showSpinner = mN.extras.getBoolean(EXTRA_SHOW_REMOTE_INPUT_SPINNER); - big.setViewVisibility(R.id.notification_material_reply_container, View.VISIBLE); - big.setViewVisibility(R.id.notification_material_reply_text_1_container, + contentView.setViewVisibility(R.id.notification_material_reply_container, + View.VISIBLE); + contentView.setViewVisibility(R.id.notification_material_reply_text_1_container, View.VISIBLE); - big.setTextViewText(R.id.notification_material_reply_text_1, + contentView.setTextViewText(R.id.notification_material_reply_text_1, ensureColorSpanContrastOrStripStyling(replyText[0].getText(), p)); - setTextViewColorSecondary(big, R.id.notification_material_reply_text_1, p); - big.setViewVisibility(R.id.notification_material_reply_progress, + setTextViewColorSecondary(contentView, R.id.notification_material_reply_text_1, p); + contentView.setViewVisibility(R.id.notification_material_reply_progress, showSpinner ? View.VISIBLE : View.GONE); - big.setProgressIndeterminateTintList( + contentView.setProgressIndeterminateTintList( R.id.notification_material_reply_progress, ColorStateList.valueOf(getPrimaryAccentColor(p))); if (replyText.length > 1 && !TextUtils.isEmpty(replyText[1].getText()) && p.maxRemoteInputHistory > 1) { - big.setViewVisibility(R.id.notification_material_reply_text_2, View.VISIBLE); - big.setTextViewText(R.id.notification_material_reply_text_2, + contentView.setViewVisibility(R.id.notification_material_reply_text_2, + View.VISIBLE); + contentView.setTextViewText(R.id.notification_material_reply_text_2, ensureColorSpanContrastOrStripStyling(replyText[1].getText(), p)); - setTextViewColorSecondary(big, R.id.notification_material_reply_text_2, p); + setTextViewColorSecondary(contentView, R.id.notification_material_reply_text_2, + p); if (replyText.length > 2 && !TextUtils.isEmpty(replyText[2].getText()) && p.maxRemoteInputHistory > 2) { - big.setViewVisibility( + contentView.setViewVisibility( R.id.notification_material_reply_text_3, View.VISIBLE); - big.setTextViewText(R.id.notification_material_reply_text_3, + contentView.setTextViewText(R.id.notification_material_reply_text_3, ensureColorSpanContrastOrStripStyling(replyText[2].getText(), p)); - setTextViewColorSecondary(big, R.id.notification_material_reply_text_3, p); + setTextViewColorSecondary(contentView, + R.id.notification_material_reply_text_3, p); } } } - return big; + return contentView; + } + + private boolean populateActionsContainer(RemoteViews contentView, StandardTemplateParams p, + List<Action> nonContextualActions, int numActions, boolean emphasizedMode) { + boolean validRemoteInput = false; + for (int i = 0; i < numActions; i++) { + Action action = nonContextualActions.get(i); + + boolean actionHasValidInput = hasValidRemoteInput(action); + validRemoteInput |= actionHasValidInput; + + final RemoteViews button = generateActionButton(action, emphasizedMode, p); + if (actionHasValidInput && !emphasizedMode) { + // Clear the drawable + button.setInt(R.id.action0, "setBackgroundResource", 0); + } + if (emphasizedMode && i > 0) { + // Clear start margin from non-first buttons to reduce the gap between them. + // (8dp remaining gap is from all buttons' standard 4dp inset). + button.setViewLayoutMarginDimen(R.id.action0, RemoteViews.MARGIN_START, 0); + } + contentView.addView(R.id.actions, button); + } + return validRemoteInput; } /** diff --git a/core/java/com/android/internal/widget/NotificationActionListLayout.java b/core/java/com/android/internal/widget/NotificationActionListLayout.java index cac2024f548d..cf9f1c8b380a 100644 --- a/core/java/com/android/internal/widget/NotificationActionListLayout.java +++ b/core/java/com/android/internal/widget/NotificationActionListLayout.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import static android.app.Flags.notificationsRedesignTemplates; import static android.app.Notification.CallStyle.DEBUG_NEW_ACTION_LAYOUT; import static android.app.Flags.evenlyDividedCallStyleActionLayout; @@ -368,12 +369,17 @@ public class NotificationActionListLayout extends LinearLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mDefaultPaddingBottom = getPaddingBottom(); - mDefaultPaddingTop = getPaddingTop(); - updateHeights(); + if (!notificationsRedesignTemplates()) { + mDefaultPaddingBottom = getPaddingBottom(); + mDefaultPaddingTop = getPaddingTop(); + updateHeights(); + } } private void updateHeights() { + if (notificationsRedesignTemplates()) { + return; + } int inset = getResources().getDimensionPixelSize( com.android.internal.R.dimen.button_inset_vertical_material); mEmphasizedPaddingTop = getResources().getDimensionPixelSize( @@ -440,6 +446,9 @@ public class NotificationActionListLayout extends LinearLayout { */ @RemotableViewMethod public void setEmphasizedMode(boolean emphasizedMode) { + if (notificationsRedesignTemplates()) { + return; + } mEmphasizedMode = emphasizedMode; int height; if (emphasizedMode) { @@ -462,7 +471,9 @@ public class NotificationActionListLayout extends LinearLayout { } public int getExtraMeasureHeight() { - if (mEmphasizedMode) { + // Note: the emphasized height is no longer different from the regular height when the + // notificationsRedesignTemplates flag is on. + if (!notificationsRedesignTemplates() && mEmphasizedMode) { return mEmphasizedHeight - mRegularHeight; } return 0; diff --git a/core/res/res/layout/notification_2025_action_list.xml b/core/res/res/layout/notification_2025_action_list.xml new file mode 100644 index 000000000000..053aca068027 --- /dev/null +++ b/core/res/res/layout/notification_2025_action_list.xml @@ -0,0 +1,84 @@ +<?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 + --> + +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/actions_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_marginBottom="@dimen/notification_2025_action_list_margin_bottom" + > + + <LinearLayout + android:id="@+id/actions_container_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="end" + android:layout_gravity="bottom" + android:orientation="horizontal" + android:background="@color/notification_action_list_background_color" + > + + <com.android.internal.widget.NotificationActionListLayout + android:id="@+id/actions" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:minHeight="@dimen/notification_2025_action_list_height" + android:orientation="horizontal" + android:gravity="center_vertical" + android:visibility="gone" + > + <!-- actions will be added here --> + </com.android.internal.widget.NotificationActionListLayout> + + <!-- + This nested linear layout exists to ensure that if the neither of the contained + actions is visible we have some minimum padding at the end of the actions is present, + then there will be 12dp of padding at the end of the actions list. + + The end padding exists to match the bottom margin of the actions, for symmetry when the icon + is shown in the corner of the notification. + --> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal" + android:paddingEnd="@dimen/notification_2025_action_list_margin_bottom" + android:minWidth="@dimen/snooze_and_bubble_gone_padding_end" + > + <ImageView + android:id="@+id/snooze_button" + android:layout_width="@dimen/notification_2025_actions_icon_size" + android:layout_height="@dimen/notification_2025_actions_icon_size" + android:layout_gravity="center_vertical|end" + android:visibility="gone" + android:scaleType="centerInside" + /> + + <ImageView + android:id="@+id/bubble_button" + android:layout_width="@dimen/notification_2025_actions_icon_size" + android:layout_height="@dimen/notification_2025_actions_icon_size" + android:layout_gravity="center_vertical|end" + android:visibility="gone" + android:scaleType="centerInside" + /> + </LinearLayout> + </LinearLayout> +</FrameLayout> diff --git a/core/res/res/layout/notification_2025_template_collapsed_call.xml b/core/res/res/layout/notification_2025_template_collapsed_call.xml index fbea10d42b2b..4e0cf753722f 100644 --- a/core/res/res/layout/notification_2025_template_collapsed_call.xml +++ b/core/res/res/layout/notification_2025_template_collapsed_call.xml @@ -182,10 +182,10 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </LinearLayout> diff --git a/core/res/res/layout/notification_2025_template_collapsed_conversation.xml b/core/res/res/layout/notification_2025_template_collapsed_conversation.xml index a6fdcd95399e..5783201981a8 100644 --- a/core/res/res/layout/notification_2025_template_collapsed_conversation.xml +++ b/core/res/res/layout/notification_2025_template_collapsed_conversation.xml @@ -206,10 +206,10 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </LinearLayout> </com.android.internal.widget.ConversationLayout> diff --git a/core/res/res/layout/notification_2025_template_collapsed_messaging.xml b/core/res/res/layout/notification_2025_template_collapsed_messaging.xml index 3716fa6825b3..6391b1ebf744 100644 --- a/core/res/res/layout/notification_2025_template_collapsed_messaging.xml +++ b/core/res/res/layout/notification_2025_template_collapsed_messaging.xml @@ -216,10 +216,10 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </LinearLayout> </com.android.internal.widget.MessagingLayout> diff --git a/core/res/res/layout/notification_2025_template_compact_heads_up_messaging.xml b/core/res/res/layout/notification_2025_template_compact_heads_up_messaging.xml index cf9ff6bef6f8..be6404609f25 100644 --- a/core/res/res/layout/notification_2025_template_compact_heads_up_messaging.xml +++ b/core/res/res/layout/notification_2025_template_compact_heads_up_messaging.xml @@ -96,7 +96,7 @@ <FrameLayout android:id="@+id/reply_action_container" android:layout_width="wrap_content" - android:layout_height="@dimen/notification_action_list_height" + android:layout_height="@dimen/notification_2025_action_list_height" android:gravity="center_vertical" android:orientation="horizontal" /> <FrameLayout diff --git a/core/res/res/layout/notification_2025_template_expanded_base.xml b/core/res/res/layout/notification_2025_template_expanded_base.xml index 8d99e47c5386..76a85813b980 100644 --- a/core/res/res/layout/notification_2025_template_expanded_base.xml +++ b/core/res/res/layout/notification_2025_template_expanded_base.xml @@ -79,9 +79,9 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </FrameLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_big_picture.xml b/core/res/res/layout/notification_2025_template_expanded_big_picture.xml index e8e460d1b4ae..999afa66c65b 100644 --- a/core/res/res/layout/notification_2025_template_expanded_big_picture.xml +++ b/core/res/res/layout/notification_2025_template_expanded_big_picture.xml @@ -86,9 +86,9 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </FrameLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_big_text.xml b/core/res/res/layout/notification_2025_template_expanded_big_text.xml index b68db7f0a638..c9206eddbcde 100644 --- a/core/res/res/layout/notification_2025_template_expanded_big_text.xml +++ b/core/res/res/layout/notification_2025_template_expanded_big_text.xml @@ -85,10 +85,10 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </com.android.internal.widget.RemeasuringLinearLayout> <include layout="@layout/notification_2025_right_icon" /> diff --git a/core/res/res/layout/notification_2025_template_expanded_call.xml b/core/res/res/layout/notification_2025_template_expanded_call.xml index 7b45b55ba15b..ec214554a30b 100644 --- a/core/res/res/layout/notification_2025_template_expanded_call.xml +++ b/core/res/res/layout/notification_2025_template_expanded_call.xml @@ -60,11 +60,11 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </com.android.internal.widget.RemeasuringLinearLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_conversation.xml b/core/res/res/layout/notification_2025_template_expanded_conversation.xml index 592785d53018..6ee82fa116ff 100644 --- a/core/res/res/layout/notification_2025_template_expanded_conversation.xml +++ b/core/res/res/layout/notification_2025_template_expanded_conversation.xml @@ -62,11 +62,11 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </com.android.internal.widget.RemeasuringLinearLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_inbox.xml b/core/res/res/layout/notification_2025_template_expanded_inbox.xml index 6459e1eab862..1eaef228aaca 100644 --- a/core/res/res/layout/notification_2025_template_expanded_inbox.xml +++ b/core/res/res/layout/notification_2025_template_expanded_inbox.xml @@ -127,8 +127,8 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" /> - <include layout="@layout/notification_material_action_list" /> + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> <include layout="@layout/notification_2025_right_icon" /> </FrameLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_messaging.xml b/core/res/res/layout/notification_2025_template_expanded_messaging.xml index 82c71527a291..62059af7f056 100644 --- a/core/res/res/layout/notification_2025_template_expanded_messaging.xml +++ b/core/res/res/layout/notification_2025_template_expanded_messaging.xml @@ -62,11 +62,11 @@ <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </com.android.internal.widget.RemeasuringLinearLayout> diff --git a/core/res/res/layout/notification_2025_template_expanded_progress.xml b/core/res/res/layout/notification_2025_template_expanded_progress.xml index 2ff252747fd2..cf39d8b08c4f 100644 --- a/core/res/res/layout/notification_2025_template_expanded_progress.xml +++ b/core/res/res/layout/notification_2025_template_expanded_progress.xml @@ -115,9 +115,9 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/core/res/res/layout/notification_2025_template_heads_up_base.xml b/core/res/res/layout/notification_2025_template_heads_up_base.xml index 084ec7daa683..4d3b2453637d 100644 --- a/core/res/res/layout/notification_2025_template_heads_up_base.xml +++ b/core/res/res/layout/notification_2025_template_heads_up_base.xml @@ -57,10 +57,10 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_2025_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" - android:layout_marginTop="@dimen/notification_content_margin" + android:layout_marginTop="@dimen/notification_2025_smart_reply_container_margin" /> - <include layout="@layout/notification_material_action_list" /> + <include layout="@layout/notification_2025_action_list" /> </LinearLayout> </LinearLayout> </FrameLayout> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 465e318511c6..d0a8796418f1 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -277,12 +277,24 @@ <!-- The margin on the end of the top-line content views (accommodates the expander) --> <dimen name="notification_heading_margin_end">56dp</dimen> + <!-- The vertical spacing for the smart reply/smart action container. + Note that the button background itself also has an inset of 6dp (making the height of the + tappable area 48dp total, 32dp for the visible button plus 6dp top and bottom), so the visible + space between the button and the other content is going to be 16dp. --> + <dimen name="notification_2025_smart_reply_container_margin">10dp</dimen> + <!-- The total height of the notification action list --> <dimen name="notification_action_list_height">60dp</dimen> + <!-- The total height of the notification action list (2025 redesign version) --> + <dimen name="notification_2025_action_list_height">48dp</dimen> + <!-- The margin of the notification action list at the top --> <dimen name="notification_action_list_margin_top">0dp</dimen> + <!-- The margin of the notification action list at the bottom in the 2025 redesign --> + <dimen name="notification_2025_action_list_margin_bottom">6dp</dimen> + <!-- The overall height of the emphasized notification action --> <dimen name="notification_action_emphasized_height">48dp</dimen> @@ -304,6 +316,9 @@ <!-- The size of icons for visual actions in the notification_material_action_list --> <dimen name="notification_actions_icon_size">56dp</dimen> + <!-- The size of icon actions in notification_material_action_list (2025 redesign version) --> + <dimen name="notification_2025_actions_icon_size">48dp</dimen> + <!-- The size of icons for visual actions in the notification_material_action_list --> <dimen name="notification_actions_icon_drawable_size">20dp</dimen> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 46d18e3d3302..a9c540275569 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3271,6 +3271,8 @@ <java-symbol type="dimen" name="notification_2025_expand_button_reduced_end_padding" /> <java-symbol type="dimen" name="notification_2025_expand_button_right_icon_spacing" /> <java-symbol type="dimen" name="notification_2025_right_icon_expanded_margin_end" /> + <java-symbol type="dimen" name="notification_2025_action_list_margin_bottom" /> + <java-symbol type="dimen" name="notification_2025_smart_reply_container_margin" /> <java-symbol type="dimen" name="notification_progress_margin_horizontal" /> <java-symbol type="dimen" name="notification_header_background_height" /> <java-symbol type="dimen" name="notification_header_touchable_height" /> @@ -3497,6 +3499,7 @@ <java-symbol type="dimen" name="input_extract_action_button_height" /> <java-symbol type="dimen" name="notification_action_list_height" /> + <java-symbol type="dimen" name="notification_2025_action_list_height" /> <java-symbol type="dimen" name="notification_action_emphasized_height" /> <!-- TV Remote Service package --> diff --git a/packages/SystemUI/res/drawable/notification_2025_smart_reply_button_background.xml b/packages/SystemUI/res/drawable/notification_2025_smart_reply_button_background.xml index d398f60ddc3c..84e228e436cb 100644 --- a/packages/SystemUI/res/drawable/notification_2025_smart_reply_button_background.xml +++ b/packages/SystemUI/res/drawable/notification_2025_smart_reply_button_background.xml @@ -21,9 +21,9 @@ <item> <inset android:insetLeft="0dp" - android:insetTop="8dp" + android:insetTop="6dp" android:insetRight="0dp" - android:insetBottom="8dp"> + android:insetBottom="6dp"> <shape android:shape="rectangle"> <corners android:radius="@dimen/notification_2025_smart_reply_button_corner_radius" /> <stroke android:width="@dimen/smart_reply_button_stroke_width" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 676c96ebc9d9..cd6e4979ce88 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.row; +import static android.app.Flags.notificationsRedesignTemplates; + import android.annotation.NonNull; import android.annotation.Nullable; import android.app.Flags; @@ -719,9 +721,12 @@ public class NotificationContentView extends FrameLayout implements Notification * height, the notification is clipped instead of being further shrunk. */ private int getMinContentHeightHint() { + int actionListHeight = mContext.getResources().getDimensionPixelSize( + notificationsRedesignTemplates() + ? com.android.internal.R.dimen.notification_2025_action_list_height + : com.android.internal.R.dimen.notification_action_list_height); if (mIsChildInGroup && isVisibleOrTransitioning(VISIBLE_TYPE_SINGLELINE)) { - return mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.notification_action_list_height); + return actionListHeight; } // Transition between heads-up & expanded, or pinned. @@ -756,9 +761,7 @@ public class NotificationContentView extends FrameLayout implements Notification } else if (mExpandedChild != null) { hint = getViewHeight(VISIBLE_TYPE_EXPANDED); } else if (mContractedChild != null) { - hint = getViewHeight(VISIBLE_TYPE_CONTRACTED) - + mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.notification_action_list_height); + hint = getViewHeight(VISIBLE_TYPE_CONTRACTED) + actionListHeight; } else { hint = getMinHeight(); } @@ -1613,12 +1616,14 @@ public class NotificationContentView extends FrameLayout implements Notification actionContainer.setVisibility(VISIBLE); // Set notification_action_list_margin_target's bottom margin to 0 when showing bubble if (actionListMarginTarget != null) { - ViewGroup.LayoutParams lp = actionListMarginTarget.getLayoutParams(); - if (lp instanceof ViewGroup.MarginLayoutParams) { - final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; - if (mlp.bottomMargin > 0) { - mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, 0); - } + removeBottomMargin(actionListMarginTarget); + } + if (notificationsRedesignTemplates()) { + // Similar treatment for smart reply margin + LinearLayout smartReplyContainer = layout.findViewById( + com.android.internal.R.id.smart_reply_container); + if (smartReplyContainer != null) { + removeBottomMargin(smartReplyContainer); } } } else { @@ -1626,6 +1631,16 @@ public class NotificationContentView extends FrameLayout implements Notification } } + private static void removeBottomMargin(ViewGroup actionListMarginTarget) { + ViewGroup.LayoutParams lp = actionListMarginTarget.getLayoutParams(); + if (lp instanceof MarginLayoutParams) { + final MarginLayoutParams mlp = (MarginLayoutParams) lp; + if (mlp.bottomMargin > 0) { + mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, 0); + } + } + } + @MainThread public void setBubblesEnabledForUser(boolean enabled) { mBubblesEnabledForUser = enabled; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java index 8176d2a1be44..99db1dba7e65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java @@ -53,8 +53,8 @@ import com.android.systemui.statusbar.notification.ImageTransformState; import com.android.systemui.statusbar.notification.TransformState; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.HybridNotificationView; -import com.android.systemui.util.DimensionKt; import com.android.systemui.statusbar.notification.shared.NotificationBundleUi; +import com.android.systemui.util.DimensionKt; import java.util.function.Consumer; @@ -411,7 +411,8 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp @Override public int getExtraMeasureHeight() { int extra = 0; - if (mActions != null) { + if (!notificationsRedesignTemplates() && mActions != null) { + // With the redesign, this should always be 0. extra = mActions.getExtraMeasureHeight(); } if (mRemoteInputHistory != null && mRemoteInputHistory.getVisibility() != View.GONE) { |