diff options
| author | 2025-02-20 02:14:55 -0800 | |
|---|---|---|
| committer | 2025-02-20 02:14:55 -0800 | |
| commit | 5c93bf876f8c8dd45f4ef15da470d388b40cb345 (patch) | |
| tree | 2001aa7e49559d41d3ff7729fc235bf71c75e151 | |
| parent | db00286845519f1121ef7be70d1e781bf59a5bc0 (diff) | |
| parent | 2f6cdb0d22ff00cffa7b2010b58927e78c3c16dc (diff) | |
Merge changes from topics "notif_redesign_conversations", "notif_redesign_legacy_msg_title" into main
* changes:
[Notif redesign] Show title in legacy messaging notifs
[Notif redesign] Update conversation layout
16 files changed, 519 insertions, 365 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 5dca1c70a2e6..06047a42e70d 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -18,6 +18,7 @@ package android.app; import static android.annotation.Dimension.DP; import static android.app.Flags.evenlyDividedCallStyleActionLayout; +import static android.app.Flags.notificationsRedesignTemplates; import static android.app.admin.DevicePolicyResources.Drawables.Source.NOTIFICATION; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_COLORED; import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICON; @@ -818,7 +819,8 @@ public class Notification implements Parcelable R.layout.notification_2025_template_expanded_base, R.layout.notification_2025_template_heads_up_base, R.layout.notification_2025_template_header, - R.layout.notification_2025_template_conversation, + R.layout.notification_2025_template_collapsed_conversation, + R.layout.notification_2025_template_expanded_conversation, R.layout.notification_2025_template_collapsed_call, R.layout.notification_2025_template_expanded_call, R.layout.notification_2025_template_collapsed_messaging, @@ -5963,7 +5965,8 @@ public class Notification implements Parcelable || resId == getCompactHeadsUpBaseLayoutResource() || resId == getMessagingCompactHeadsUpLayoutResource() || resId == getCollapsedMessagingLayoutResource() - || resId == getCollapsedMediaLayoutResource()); + || resId == getCollapsedMediaLayoutResource() + || resId == getCollapsedConversationLayoutResource()); RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -6001,8 +6004,7 @@ public class Notification implements Parcelable // Update margins to leave space for the top line (but not for headerless views like // HUNS, which use a different layout that already accounts for that). Templates that // have content that will be displayed under the small icon also use a different margin. - if (Flags.notificationsRedesignTemplates() - && !p.mHeaderless && !p.mSkipTopLineAlignment) { + if (Flags.notificationsRedesignTemplates() && !p.mHeaderless) { int margin = getContentMarginTop(mContext, R.dimen.notification_2025_content_margin_top); contentView.setViewLayoutMargin(R.id.notification_main_column, @@ -7673,12 +7675,18 @@ public class Notification implements Parcelable } } + // Note: In the 2025 redesign, we use two separate layouts for the collapsed and expanded + // version of conversations. See below. private int getConversationLayoutResource() { - if (Flags.notificationsRedesignTemplates()) { - return R.layout.notification_2025_template_conversation; - } else { - return R.layout.notification_template_material_conversation; - } + return R.layout.notification_template_material_conversation; + } + + private int getCollapsedConversationLayoutResource() { + return R.layout.notification_2025_template_collapsed_conversation; + } + + private int getExpandedConversationLayoutResource() { + return R.layout.notification_2025_template_expanded_conversation; } private int getCollapsedCallLayoutResource() { @@ -9462,7 +9470,7 @@ public class Notification implements Parcelable boolean hideRightIcons = viewType != StandardTemplateParams.VIEW_TYPE_NORMAL; boolean isConversationLayout = mConversationType != CONVERSATION_TYPE_LEGACY; boolean isImportantConversation = mConversationType == CONVERSATION_TYPE_IMPORTANT; - boolean isHeaderless = !isConversationLayout && isCollapsed; + boolean isLegacyHeaderless = !isConversationLayout && isCollapsed; //TODO (b/217799515): ensure mConversationTitle always returns the correct // conversationTitle, probably set mConversationTitle = conversationTitle after this @@ -9483,7 +9491,8 @@ public class Notification implements Parcelable } else { isOneToOne = !isGroupConversation(); } - if (isHeaderless && isOneToOne && TextUtils.isEmpty(conversationTitle)) { + if ((isLegacyHeaderless || notificationsRedesignTemplates()) + && isOneToOne && TextUtils.isEmpty(conversationTitle)) { conversationTitle = getOtherPersonName(); } @@ -9493,22 +9502,24 @@ public class Notification implements Parcelable .viewType(viewType) .highlightExpander(isConversationLayout) .hideProgress(true) - .title(isHeaderless ? conversationTitle : null) .text(null) .hideLeftIcon(isOneToOne) - .hideRightIcon(hideRightIcons || isOneToOne) - .headerTextSecondary(isHeaderless ? null : conversationTitle) - .skipTopLineAlignment(true); + .hideRightIcon(hideRightIcons || isOneToOne); + if (notificationsRedesignTemplates()) { + p.title(conversationTitle) + .hideAppName(isCollapsed); + } else { + p.title(isLegacyHeaderless ? conversationTitle : null) + .headerTextSecondary(isLegacyHeaderless ? null : conversationTitle); + } RemoteViews contentView = mBuilder.applyStandardTemplateWithActions( - isConversationLayout - ? mBuilder.getConversationLayoutResource() - : isCollapsed - ? mBuilder.getCollapsedMessagingLayoutResource() - : mBuilder.getExpandedMessagingLayoutResource(), + getMessagingLayoutResource(isConversationLayout, isCollapsed), p, bindResult); - if (isConversationLayout) { + if (isConversationLayout && !notificationsRedesignTemplates()) { + // Redesign note: This view is replaced by the `title`, which is handled normally. mBuilder.setTextViewColorPrimary(contentView, R.id.conversation_text, p); + // Redesign note: This special divider is no longer needed. mBuilder.setTextViewColorSecondary(contentView, R.id.app_name_divider, p); } @@ -9538,7 +9549,18 @@ public class Notification implements Parcelable contentView.setBoolean(R.id.status_bar_latest_event_content, "setIsImportantConversation", isImportantConversation); } - if (isHeaderless) { + if (notificationsRedesignTemplates() && !isCollapsed) { + // Align the title to the app/small icon in the expanded form. In other layouts, + // this margin is added directly to the notification_main_column parent, but for + // messages we don't want the margin to be applied to the actual messaging + // content since it can contain icons that are displayed below the app icon. + Resources res = mBuilder.mContext.getResources(); + int marginStart = res.getDimensionPixelSize( + R.dimen.notification_2025_content_margin_start); + contentView.setViewLayoutMargin(R.id.title, + RemoteViews.MARGIN_START, marginStart, TypedValue.COMPLEX_UNIT_PX); + } + if (isLegacyHeaderless) { // Collapsed legacy messaging style has a 1-line limit. contentView.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1); } @@ -9549,6 +9571,33 @@ public class Notification implements Parcelable return contentView; } + private int getMessagingLayoutResource(boolean isConversationLayout, boolean isCollapsed) { + if (notificationsRedesignTemplates()) { + // Note: We eventually would like to use the same layouts for both conversations and + // regular messaging notifications. + if (isConversationLayout) { + if (isCollapsed) { + return mBuilder.getCollapsedConversationLayoutResource(); + } else { + return mBuilder.getExpandedConversationLayoutResource(); + } + } else { + if (isCollapsed) { + return mBuilder.getCollapsedMessagingLayoutResource(); + } else { + return mBuilder.getExpandedMessagingLayoutResource(); + } + } + + } else { + return isConversationLayout + ? mBuilder.getConversationLayoutResource() + : isCollapsed + ? mBuilder.getCollapsedMessagingLayoutResource() + : mBuilder.getExpandedMessagingLayoutResource(); + } + } + private CharSequence getKey(Person person) { return person == null ? null : person.getKey() == null ? person.getName() : person.getKey(); @@ -14676,7 +14725,6 @@ public class Notification implements Parcelable Icon mPromotedPicture; boolean mCallStyleActions; boolean mAllowTextWithProgress; - boolean mSkipTopLineAlignment; int mTitleViewId; int mTextViewId; @Nullable CharSequence mTitle; @@ -14702,7 +14750,6 @@ public class Notification implements Parcelable mPromotedPicture = null; mCallStyleActions = false; mAllowTextWithProgress = false; - mSkipTopLineAlignment = false; mTitleViewId = R.id.title; mTextViewId = R.id.text; mTitle = null; @@ -14769,11 +14816,6 @@ public class Notification implements Parcelable return this; } - public StandardTemplateParams skipTopLineAlignment(boolean skipTopLineAlignment) { - mSkipTopLineAlignment = skipTopLineAlignment; - return this; - } - final StandardTemplateParams hideSnoozeButton(boolean hideSnoozeButton) { this.mHideSnoozeButton = hideSnoozeButton; return this; diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index 641ecc9b675a..ce46da12aa76 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -250,7 +250,8 @@ public class ConversationLayout extends FrameLayout mPeopleHelper.animateViewForceHidden(mImportanceRingView, forceHidden); mPeopleHelper.animateViewForceHidden(mIcon, forceHidden); }); - mConversationText = findViewById(R.id.conversation_text); + mConversationText = findViewById(notificationsRedesignTemplates() + ? R.id.title : R.id.conversation_text); mExpandButtonContainer = findViewById(R.id.expand_button_container); mExpandButtonContainerA11yContainer = findViewById(R.id.expand_button_a11y_container); @@ -716,17 +717,10 @@ public class ConversationLayout extends FrameLayout } private void updateImageMessages() { - View newMessage = null; - if (mIsCollapsed && !mGroups.isEmpty()) { - - // When collapsed, we're displaying the image message in a dedicated container - // on the right of the layout instead of inline. Let's add the isolated image there - MessagingGroup messagingGroup = mGroups.getLast(); - MessagingImageMessage isolatedMessage = messagingGroup.getIsolatedMessage(); - if (isolatedMessage != null) { - newMessage = isolatedMessage.getView(); - } + if (mImageMessageContainer == null) { + return; } + View newMessage = getNewImageMessage(); // Remove all messages that don't belong into the image layout View previousMessage = mImageMessageContainer.getChildAt(0); if (previousMessage != newMessage) { @@ -738,6 +732,20 @@ public class ConversationLayout extends FrameLayout mImageMessageContainer.setVisibility(newMessage != null ? VISIBLE : GONE); } + @Nullable + private View getNewImageMessage() { + if (mIsCollapsed && !mGroups.isEmpty()) { + // When collapsed, we're displaying the image message in a dedicated container + // on the right of the layout instead of inline. Let's add the isolated image there + MessagingGroup messagingGroup = mGroups.getLast(); + MessagingImageMessage isolatedMessage = messagingGroup.getIsolatedMessage(); + if (isolatedMessage != null) { + return isolatedMessage.getView(); + } + } + return null; + } + public void bindFacePile(ImageView bottomBackground, ImageView bottomView, ImageView topView) { applyNotificationBackgroundColor(bottomBackground); // Let's find the two last conversations: @@ -841,6 +849,10 @@ public class ConversationLayout extends FrameLayout } private void updateAppName() { + if (notificationsRedesignTemplates()) { + return; + } + mAppName.setVisibility(mIsCollapsed ? GONE : VISIBLE); } @@ -1533,6 +1545,10 @@ public class ConversationLayout extends FrameLayout } private void updateExpandButton() { + if (notificationsRedesignTemplates()) { + return; + } + int buttonGravity; ViewGroup newContainer; if (mIsCollapsed) { @@ -1565,6 +1581,10 @@ public class ConversationLayout extends FrameLayout } private void updateContentEndPaddings() { + if (notificationsRedesignTemplates()) { + return; + } + // Let's make sure the conversation header can't run into the expand button when we're // collapsed and update the paddings of the content int headerPaddingEnd; @@ -1593,6 +1613,10 @@ public class ConversationLayout extends FrameLayout } private void onAppNameVisibilityChanged() { + if (notificationsRedesignTemplates()) { + return; + } + boolean appNameGone = mAppName.getVisibility() == GONE; if (appNameGone != mAppNameGone) { mAppNameGone = appNameGone; @@ -1601,10 +1625,18 @@ public class ConversationLayout extends FrameLayout } private void updateAppNameDividerVisibility() { + if (notificationsRedesignTemplates()) { + return; + } + mAppNameDivider.setVisibility(mAppNameGone ? GONE : VISIBLE); } public void updateExpandability(boolean expandable, @Nullable OnClickListener onClickListener) { + if (notificationsRedesignTemplates()) { + return; + } + mExpandable = expandable; if (expandable) { mExpandButtonContainer.setVisibility(VISIBLE); diff --git a/core/java/com/android/internal/widget/MessagingGroup.java b/core/java/com/android/internal/widget/MessagingGroup.java index 31d9770f6ac4..b9a603cc5696 100644 --- a/core/java/com/android/internal/widget/MessagingGroup.java +++ b/core/java/com/android/internal/widget/MessagingGroup.java @@ -449,12 +449,8 @@ public class MessagingGroup extends NotificationOptimizedLinearLayout implements } private void updateIconVisibility() { - if (Flags.notificationsRedesignTemplates() && !mIsInConversation) { - // We don't show any icon (other than the app icon) in the collapsed form. For - // conversations, keeping this container helps with aligning the message to the icon - // when collapsed, but the old messaging style already has this alignment built into - // the template like all other layouts. Conversations are special because we use the - // same base layout for both the collapsed and expanded views. + if (Flags.notificationsRedesignTemplates()) { + // We don't show any icon (other than the app or person icon) in the collapsed form. mMessagingIconContainer.setVisibility(mSingleLine ? GONE : VISIBLE); } } diff --git a/core/java/com/android/internal/widget/MessagingLayout.java b/core/java/com/android/internal/widget/MessagingLayout.java index 64b44df8c982..eb22e7c8cdc0 100644 --- a/core/java/com/android/internal/widget/MessagingLayout.java +++ b/core/java/com/android/internal/widget/MessagingLayout.java @@ -337,19 +337,10 @@ public class MessagingLayout extends FrameLayout } private void updateImageMessages() { - View newMessage = null; if (mImageMessageContainer == null) { return; } - if (mIsCollapsed && !mGroups.isEmpty()) { - // When collapsed, we're displaying the image message in a dedicated container - // on the right of the layout instead of inline. Let's add the isolated image there - MessagingGroup messagingGroup = mGroups.getLast(); - MessagingImageMessage isolatedMessage = messagingGroup.getIsolatedMessage(); - if (isolatedMessage != null) { - newMessage = isolatedMessage.getView(); - } - } + View newMessage = getNewImageMessage(); // Remove all messages that don't belong into the image layout View previousMessage = mImageMessageContainer.getChildAt(0); if (previousMessage != newMessage) { @@ -368,6 +359,20 @@ public class MessagingLayout extends FrameLayout } } + @Nullable + private View getNewImageMessage() { + if (mIsCollapsed && !mGroups.isEmpty()) { + // When collapsed, we're displaying the image message in a dedicated container + // on the right of the layout instead of inline. Let's add the isolated image there + MessagingGroup messagingGroup = mGroups.getLast(); + MessagingImageMessage isolatedMessage = messagingGroup.getIsolatedMessage(); + if (isolatedMessage != null) { + return isolatedMessage.getView(); + } + } + return null; + } + private void removeGroups(ArrayList<MessagingGroup> oldGroups) { int size = oldGroups.size(); for (int i = 0; i < size; i++) { diff --git a/core/res/res/layout/notification_2025_conversation_header.xml b/core/res/res/layout/notification_2025_conversation_header.xml index 1bde17358825..68096f8cc50e 100644 --- a/core/res/res/layout/notification_2025_conversation_header.xml +++ b/core/res/res/layout/notification_2025_conversation_header.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Copyright (C) 2024 The Android Open Source Project + ~ 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. @@ -15,157 +15,74 @@ ~ limitations under the License --> -<com.android.internal.widget.ConversationHeaderLinearLayout +<!-- extends RelativeLayout --> +<NotificationHeaderView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/conversation_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:id="@+id/notification_header" + android:layout_width="match_parent" + android:layout_height="@dimen/notification_2025_header_height" + android:clipChildren="false" + android:gravity="center_vertical" android:orientation="horizontal" - android:paddingTop="@dimen/notification_2025_margin" + android:theme="@style/Theme.DeviceDefault.Notification" + android:importantForAccessibility="no" > - <TextView - android:id="@+id/conversation_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title" - android:textSize="16sp" - android:singleLine="true" - android:layout_weight="1" - /> - - <TextView - android:id="@+id/app_name_divider" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Info" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:text="@string/notification_header_divider_symbol" - android:singleLine="true" + <ImageView + android:id="@+id/left_icon" + android:layout_width="@dimen/notification_2025_left_icon_size" + android:layout_height="@dimen/notification_2025_left_icon_size" + android:layout_alignParentStart="true" + android:layout_margin="@dimen/notification_2025_margin" + android:background="@drawable/notification_large_icon_outline" + android:clipToOutline="true" + android:importantForAccessibility="no" + android:scaleType="centerCrop" android:visibility="gone" /> - <!-- App Name --> - <com.android.internal.widget.ObservableTextView - android:id="@+id/app_name_text" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Info" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:singleLine="true" - android:visibility="gone" - /> + <include layout="@layout/notification_2025_conversation_icon_container" /> - <TextView - android:id="@+id/time_divider" + <!-- extends ViewGroup --> + <NotificationTopLineView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/notification_top_line" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Info" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:text="@string/notification_header_divider_symbol" - android:singleLine="true" - android:visibility="gone" - /> + android:layout_alignParentStart="true" + android:layout_toStartOf="@id/expand_button" + android:layout_alignWithParentIfMissing="true" + android:layout_marginVertical="@dimen/notification_2025_margin" + android:clipChildren="false" + android:gravity="center_vertical" + android:paddingStart="@dimen/notification_2025_content_margin_start" + android:theme="@style/Theme.DeviceDefault.Notification" + > - <DateTimeView - android:id="@+id/time" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Time" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:showRelative="true" - android:singleLine="true" - android:visibility="gone" - /> + <include layout="@layout/notification_2025_top_line_views" /> - <ViewStub - android:id="@+id/chronometer" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:layout="@layout/notification_template_part_chronometer" - android:visibility="gone" - /> + </NotificationTopLineView> - <TextView - android:id="@+id/verification_divider" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Info" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:text="@string/notification_header_divider_symbol" - android:singleLine="true" - android:visibility="gone" - /> - - <ImageView - android:id="@+id/verification_icon" - android:layout_width="@dimen/notification_verification_icon_size" - android:layout_height="@dimen/notification_verification_icon_size" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:baseline="10dp" - android:scaleType="fitCenter" - android:src="@drawable/ic_notifications_alerted" - android:visibility="gone" + <FrameLayout + android:id="@+id/alternate_expand_target" + android:layout_width="@dimen/notification_2025_content_margin_start" + android:layout_height="match_parent" + android:layout_alignParentStart="true" + android:importantForAccessibility="no" + android:focusable="false" /> - <TextView - android:id="@+id/verification_text" - android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Info" + <include layout="@layout/notification_2025_expand_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/notification_conversation_header_separating_margin" - android:layout_weight="100" - android:showRelative="true" - android:singleLine="true" - android:visibility="gone" - /> + android:layout_gravity="top|end" + android:layout_alignParentEnd="true" /> - <ImageButton - android:id="@+id/feedback" - android:layout_width="@dimen/notification_feedback_size" - android:layout_height="@dimen/notification_feedback_size" - android:layout_marginStart="@dimen/notification_header_separating_margin" - android:background="?android:selectableItemBackgroundBorderless" - android:contentDescription="@string/notification_feedback_indicator" - android:baseline="13dp" - android:scaleType="fitCenter" - android:src="@drawable/ic_feedback_indicator" - android:visibility="gone" - /> + <include layout="@layout/notification_close_button" + android:id="@+id/close_button" + android:layout_width="@dimen/notification_close_button_size" + android:layout_height="@dimen/notification_close_button_size" + android:layout_alignParentTop="true" + android:layout_alignParentEnd="true" /> - <ImageView - android:id="@+id/phishing_alert" - android:layout_width="@dimen/notification_2025_badge_size" - android:layout_height="@dimen/notification_2025_badge_size" - android:layout_marginStart="@dimen/notification_2025_badge_margin" - android:baseline="@dimen/notification_2025_badge_baseline" - android:scaleType="fitCenter" - android:src="@drawable/ic_dialog_alert_material" - android:visibility="gone" - android:contentDescription="@string/notification_phishing_alert_content_description" - /> - - <ImageView - android:id="@+id/profile_badge" - android:layout_width="@dimen/notification_2025_badge_size" - android:layout_height="@dimen/notification_2025_badge_size" - android:layout_marginStart="@dimen/notification_2025_badge_margin" - android:baseline="@dimen/notification_2025_badge_baseline" - android:scaleType="fitCenter" - android:visibility="gone" - android:contentDescription="@string/notification_work_profile_content_description" - /> - - <ImageView - android:id="@+id/alerted_icon" - android:layout_width="@dimen/notification_2025_badge_size" - android:layout_height="@dimen/notification_2025_badge_size" - android:layout_marginStart="@dimen/notification_2025_badge_margin" - android:baseline="@dimen/notification_2025_badge_baseline" - android:contentDescription="@string/notification_alerted_content_description" - android:scaleType="fitCenter" - android:src="@drawable/ic_notifications_alerted" - android:visibility="gone" - /> -</com.android.internal.widget.ConversationHeaderLinearLayout> +</NotificationHeaderView> 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 6f3c15adb082..f1729b3c2f76 100644 --- a/core/res/res/layout/notification_2025_template_collapsed_call.xml +++ b/core/res/res/layout/notification_2025_template_collapsed_call.xml @@ -47,7 +47,7 @@ > <include - layout="@layout/notification_2025_conversation_header" + layout="@layout/notification_template_conversation_header" android:layout_width="wrap_content" android:layout_height="wrap_content" /> diff --git a/core/res/res/layout/notification_2025_template_collapsed_conversation.xml b/core/res/res/layout/notification_2025_template_collapsed_conversation.xml new file mode 100644 index 000000000000..f80411103501 --- /dev/null +++ b/core/res/res/layout/notification_2025_template_collapsed_conversation.xml @@ -0,0 +1,216 @@ +<?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 + --> + +<!-- extends FrameLayout --> +<com.android.internal.widget.ConversationLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/status_bar_latest_event_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:tag="conversation" + > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:orientation="vertical" + > + + + <com.android.internal.widget.NotificationMaxHeightFrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="@dimen/notification_2025_min_height" + android:clipChildren="false" + > + + <ImageView + android:id="@+id/left_icon" + android:layout_width="@dimen/notification_2025_left_icon_size" + android:layout_height="@dimen/notification_2025_left_icon_size" + android:layout_alignParentStart="true" + android:layout_margin="@dimen/notification_2025_margin" + android:background="@drawable/notification_large_icon_outline" + android:clipToOutline="true" + android:importantForAccessibility="no" + android:scaleType="centerCrop" + android:visibility="gone" + /> + + <include layout="@layout/notification_2025_conversation_icon_container" /> + + <FrameLayout + android:id="@+id/alternate_expand_target" + android:layout_width="@dimen/notification_2025_content_margin_start" + android:layout_height="match_parent" + android:layout_gravity="start" + android:importantForAccessibility="no" + android:focusable="false" + /> + + <!-- + NOTE: to make the expansion animation of id/notification_messaging happen vertically, + its X positioning must be the left edge of the notification, so instead of putting the + layout_marginStart on the id/notification_headerless_view_row, we put it on + id/notification_top_line, making the layout here just a bit different from the base. + --> + <LinearLayout + android:id="@+id/notification_headerless_view_row" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:clipChildren="false" + > + + <!-- + NOTE: because messaging will always have 2 lines, this LinearLayout should NOT + have the id/notification_headerless_view_column, as that is used for modifying + vertical margins to accommodate the single-line state that base supports + --> + <LinearLayout + android:layout_width="0px" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:layout_marginBottom="@dimen/notification_2025_margin" + android:layout_marginTop="@dimen/notification_2025_margin" + android:layout_marginStart="@dimen/notification_2025_content_margin_start" + android:clipChildren="false" + android:orientation="vertical" + > + + <NotificationTopLineView + android:id="@+id/notification_top_line" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:minHeight="@dimen/notification_headerless_line_height" + android:clipChildren="false" + android:theme="@style/Theme.DeviceDefault.Notification" + > + + <!-- + NOTE: The notification_2025_top_line_views layout contains the app_name_text. + In order to include the title view at the beginning, the Notification.Builder + has logic to hide that view whenever this title view is to be visible. + --> + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/notification_header_separating_margin" + android:ellipsize="end" + android:fadingEdge="horizontal" + android:singleLine="true" + android:textAlignment="viewStart" + android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title" + /> + + <include layout="@layout/notification_2025_top_line_views" /> + + </NotificationTopLineView> + + <LinearLayout + android:id="@+id/notification_main_column" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:clipChildren="false" + > + <com.android.internal.widget.MessagingLinearLayout + android:id="@+id/notification_messaging" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:spacing="@dimen/notification_messaging_spacing" /> + </LinearLayout> + + </LinearLayout> + + <!-- Images --> + <com.android.internal.widget.MessagingLinearLayout + android:id="@+id/conversation_image_message_container" + 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:forceHasOverlappingRendering="false" + android:spacing="0dp" + android:clipChildren="false" + android:visibility="gone" + /> + + <ImageView + android:id="@+id/right_icon" + 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:background="@drawable/notification_large_icon_outline" + android:clipToOutline="true" + android:importantForAccessibility="no" + android:scaleType="centerCrop" + /> + + <FrameLayout + android:id="@+id/expand_button_touch_container" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:minWidth="@dimen/notification_content_margin_end" + > + + <include layout="@layout/notification_2025_expand_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="top|end" + /> + + </FrameLayout> + + </LinearLayout> + + <include layout="@layout/notification_close_button" + android:id="@+id/close_button" + android:layout_width="@dimen/notification_close_button_size" + android:layout_height="@dimen/notification_close_button_size" + android:layout_gravity="top|end" /> + + </com.android.internal.widget.NotificationMaxHeightFrameLayout> + + <LinearLayout + android:id="@+id/notification_action_list_margin_target" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="-20dp" + android:clipChildren="false" + android:orientation="vertical"> + <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_marginStart="@dimen/notification_2025_content_margin_start" + android:layout_marginEnd="@dimen/notification_content_margin_end" /> + <include layout="@layout/notification_material_action_list" /> + </LinearLayout> +</LinearLayout> +</com.android.internal.widget.ConversationLayout> diff --git a/core/res/res/layout/notification_2025_template_conversation.xml b/core/res/res/layout/notification_2025_template_conversation.xml deleted file mode 100644 index 24b6ad09d3f7..000000000000 --- a/core/res/res/layout/notification_2025_template_conversation.xml +++ /dev/null @@ -1,159 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2024 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 - --> - -<!-- extends FrameLayout --> -<com.android.internal.widget.ConversationLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/status_bar_latest_event_content" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:clipChildren="false" - android:tag="conversation" - android:theme="@style/Theme.DeviceDefault.Notification" - > - - <include layout="@layout/notification_2025_conversation_icon_container" /> - - <!-- Wraps entire "expandable" notification --> - <com.android.internal.widget.RemeasuringLinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="top" - android:clipToPadding="false" - android:clipChildren="false" - android:orientation="vertical" - > - <!-- LinearLayout for Expand Button--> - <com.android.internal.widget.RemeasuringLinearLayout - android:id="@+id/expand_button_and_content_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="start|top" - android:orientation="horizontal" - android:clipChildren="false" - android:clipToPadding="false"> - <!--TODO: move this into a separate layout and share logic with the header to bring back app opps etc--> - <com.android.internal.widget.RemeasuringLinearLayout - android:id="@+id/notification_action_list_margin_target" - android:layout_width="0dp" - android:orientation="vertical" - android:layout_height="wrap_content" - android:layout_weight="1"> - - <!-- Header --> - - <!-- Use layout_marginStart instead of paddingStart to work around strange - measurement behavior on lower display densities. --> - <include - layout="@layout/notification_2025_conversation_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="2dp" - android:layout_marginStart="@dimen/notification_2025_content_margin_start" - /> - - <!-- Messages --> - <com.android.internal.widget.MessagingLinearLayout - android:id="@+id/notification_messaging" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="@dimen/notification_text_size" - android:spacing="@dimen/notification_messaging_spacing" - android:clipToPadding="false" - android:clipChildren="false" - /> - </com.android.internal.widget.RemeasuringLinearLayout> - - <!-- This is where the expand button container will be placed when collapsed--> - </com.android.internal.widget.RemeasuringLinearLayout> - - <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_marginStart="@dimen/notification_2025_content_margin_start" - android:layout_marginEnd="@dimen/notification_content_margin_end" /> - <include layout="@layout/notification_material_action_list" /> - </com.android.internal.widget.RemeasuringLinearLayout> - - <!--expand_button_a11y_container ensures talkback focus order is correct when view is expanded. - The -1px of marginTop and 1px of paddingTop make sure expand_button_a11y_container is prior to - its sibling view in accessibility focus order. - {see android.view.ViewGroup.addChildrenForAccessibility()} - expand_button_container will be moved under expand_button_and_content_container when collapsed, - this dynamic movement ensures message can flow under expand button when expanded--> - <FrameLayout - android:id="@+id/expand_button_a11y_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_gravity="end|top" - android:clipChildren="false" - android:clipToPadding="false" - android:layout_marginTop="-1px" - android:paddingTop="1px" - > - <!--expand_button_container is dynamically placed between here and at the end of the - layout. It starts here since only FrameLayout layout params have gravity--> - <LinearLayout - android:id="@+id/expand_button_container" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="end|top" - android:clipChildren="false" - android:clipToPadding="false" - android:orientation="vertical"> - <include layout="@layout/notification_close_button" - android:layout_width="@dimen/notification_close_button_size" - android:layout_height="@dimen/notification_close_button_size" - android:layout_gravity="end" - android:layout_marginEnd="20dp" - /> - <!--expand_button_touch_container makes sure that we can nicely center the expand - content in the collapsed layout while the parent makes sure that we're never laid out - bigger than the messaging content.--> - <LinearLayout - android:id="@+id/expand_button_touch_container" - android:layout_width="wrap_content" - android:layout_height="@dimen/conversation_expand_button_height" - android:orientation="horizontal" - android:layout_gravity="end|top" - android:paddingEnd="0dp" - android:clipToPadding="false" - android:clipChildren="false" - > - <!-- Images --> - <com.android.internal.widget.MessagingLinearLayout - android:id="@+id/conversation_image_message_container" - android:forceHasOverlappingRendering="false" - android:layout_width="40dp" - android:layout_height="40dp" - android:layout_marginStart="@dimen/conversation_image_start_margin" - android:spacing="0dp" - android:layout_gravity="center" - android:clipToPadding="false" - android:clipChildren="false" - /> - <include layout="@layout/notification_2025_expand_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="top|end" - /> - </LinearLayout> - </LinearLayout> - </FrameLayout> -</com.android.internal.widget.ConversationLayout> 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 0be61253c917..2114831f4c15 100644 --- a/core/res/res/layout/notification_2025_template_expanded_call.xml +++ b/core/res/res/layout/notification_2025_template_expanded_call.xml @@ -55,7 +55,7 @@ > <include - layout="@layout/notification_2025_conversation_header" + layout="@layout/notification_template_conversation_header" android:layout_width="wrap_content" android:layout_height="wrap_content" /> diff --git a/core/res/res/layout/notification_2025_template_expanded_conversation.xml b/core/res/res/layout/notification_2025_template_expanded_conversation.xml new file mode 100644 index 000000000000..d7e8bb3b6da2 --- /dev/null +++ b/core/res/res/layout/notification_2025_template_expanded_conversation.xml @@ -0,0 +1,75 @@ +<?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 + --> + +<!-- extends FrameLayout --> +<com.android.internal.widget.ConversationLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/status_bar_latest_event_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipToPadding="false" + android:clipChildren="false" + android:tag="conversation" + > + + <include layout="@layout/notification_2025_conversation_header"/> + + <com.android.internal.widget.RemeasuringLinearLayout + android:id="@+id/notification_action_list_margin_target" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="top" + android:clipChildren="false" + android:orientation="vertical"> + + <!-- Note: the top margin is being set in code based on the estimated space needed for + the header text. --> + <com.android.internal.widget.RemeasuringLinearLayout + android:id="@+id/notification_main_column" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="top" + android:layout_weight="1" + android:layout_marginEnd="@dimen/notification_content_margin_end" + android:orientation="vertical" + android:clipChildren="false" + > + + <include layout="@layout/notification_template_part_line1"/> + + <com.android.internal.widget.MessagingLinearLayout + android:id="@+id/notification_messaging" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:spacing="@dimen/notification_messaging_spacing" /> + </com.android.internal.widget.RemeasuringLinearLayout> + + <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_marginStart="@dimen/notification_2025_content_margin_start" + android:layout_marginEnd="@dimen/notification_content_margin_end" /> + + <include layout="@layout/notification_material_action_list" /> + + </com.android.internal.widget.RemeasuringLinearLayout> + + <include layout="@layout/notification_template_right_icon" /> + +</com.android.internal.widget.ConversationLayout> 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 177706c6d58d..20abfee6a4b6 100644 --- a/core/res/res/layout/notification_2025_template_expanded_messaging.xml +++ b/core/res/res/layout/notification_2025_template_expanded_messaging.xml @@ -36,17 +36,21 @@ android:clipChildren="false" android:orientation="vertical"> + <!-- Note: the top margin is being set in code based on the estimated space needed for + the header text. --> <com.android.internal.widget.RemeasuringLinearLayout android:id="@+id/notification_main_column" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_weight="1" - android:layout_marginTop="@dimen/notification_2025_header_height" android:layout_marginEnd="@dimen/notification_content_margin_end" android:orientation="vertical" android:clipChildren="false" > + + <include layout="@layout/notification_template_part_line1"/> + <com.android.internal.widget.MessagingLinearLayout android:id="@+id/notification_messaging" android:layout_width="match_parent" diff --git a/core/res/res/layout/notification_2025_top_line_views.xml b/core/res/res/layout/notification_2025_top_line_views.xml index 74873463391e..a9bde9d48dcf 100644 --- a/core/res/res/layout/notification_2025_top_line_views.xml +++ b/core/res/res/layout/notification_2025_top_line_views.xml @@ -20,7 +20,7 @@ <merge xmlns:android="http://schemas.android.com/apk/res/android"> - <TextView + <com.android.internal.widget.ObservableTextView android:id="@+id/app_name_text" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 26f0ab3f28e1..b013ffd41ecb 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3264,6 +3264,7 @@ <java-symbol type="dimen" name="notification_content_margin" /> <java-symbol type="dimen" name="notification_2025_margin" /> <java-symbol type="dimen" name="notification_2025_content_margin_top" /> + <java-symbol type="dimen" name="notification_2025_content_margin_start" /> <java-symbol type="dimen" name="notification_2025_expand_button_horizontal_icon_padding" /> <java-symbol type="dimen" name="notification_2025_expand_button_reduced_end_padding" /> <java-symbol type="dimen" name="notification_progress_margin_horizontal" /> @@ -4705,7 +4706,8 @@ <java-symbol type="dimen" name="conversation_icon_container_top_padding" /> <java-symbol type="dimen" name="conversation_icon_container_top_padding_small_avatar" /> <java-symbol type="layout" name="notification_template_material_conversation" /> - <java-symbol type="layout" name="notification_2025_template_conversation" /> + <java-symbol type="layout" name="notification_2025_template_collapsed_conversation" /> + <java-symbol type="layout" name="notification_2025_template_expanded_conversation" /> <java-symbol type="dimen" name="button_padding_horizontal_material" /> <java-symbol type="dimen" name="button_inset_horizontal_material" /> <java-symbol type="layout" name="conversation_face_pile_layout" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java index c1b8d9d123b9..6ebe02469f5c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; +import static android.app.Flags.notificationsRedesignTemplates; + import android.app.Flags; import android.app.Notification; import android.graphics.drawable.Drawable; @@ -427,7 +429,8 @@ public class NotificationGroupingUtil { @Override public void apply(View parent, View view, boolean apply, boolean reset) { - if (reset && parent instanceof ConversationLayout) { + if (!notificationsRedesignTemplates() + && reset && parent instanceof ConversationLayout) { ConversationLayout layout = (ConversationLayout) parent; apply = layout.shouldHideAppName(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt index 9aa5a2e32ada..7959e99f3189 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.promoted import android.app.Flags +import android.app.Flags.notificationsRedesignTemplates import android.app.Notification import android.graphics.PorterDuff import android.view.LayoutInflater @@ -166,7 +167,10 @@ private class AODPromotedNotificationViewUpdater(root: View) { private val closeButton: View? = root.findViewById(R.id.close_button) private val conversationIconBadge: View? = root.findViewById(R.id.conversation_icon_badge) private val conversationIcon: CachingIconView? = root.findViewById(R.id.conversation_icon) - private val conversationText: TextView? = root.findViewById(R.id.conversation_text) + private val conversationText: TextView? = + root.findViewById( + if (notificationsRedesignTemplates()) R.id.title else R.id.conversation_text + ) private val expandButton: NotificationExpandButton? = root.findViewById(R.id.expand_button) private val headerText: TextView? = root.findViewById(R.id.header_text) private val headerTextDivider: View? = root.findViewById(R.id.header_text_divider) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt index 9d13ab53ec71..6a96fba8f28d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt @@ -17,10 +17,12 @@ package com.android.systemui.statusbar.notification.row.wrapper import android.app.Flags +import android.app.Flags.notificationsRedesignTemplates import android.content.Context import android.graphics.drawable.AnimatedImageDrawable import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import com.android.internal.widget.CachingIconView import com.android.internal.widget.ConversationLayout import com.android.internal.widget.MessagingGroup @@ -53,8 +55,8 @@ class NotificationConversationTemplateViewWrapper( private lateinit var badgeIconView: NotificationRowIconView private lateinit var conversationBadgeBg: View private lateinit var expandBtn: View - private lateinit var expandBtnContainer: View - private lateinit var imageMessageContainer: ViewGroup + private var expandBtnContainer: View? = null + private var imageMessageContainer: ViewGroup? = null private lateinit var messageContainers: ArrayList<MessagingGroup> private lateinit var messagingLinearLayout: MessagingLinearLayout private lateinit var conversationTitleView: View @@ -78,10 +80,14 @@ class NotificationConversationTemplateViewWrapper( conversationBadgeBg = requireViewById(com.android.internal.R.id.conversation_icon_badge_bg) expandBtn = requireViewById(com.android.internal.R.id.expand_button) - expandBtnContainer = requireViewById(com.android.internal.R.id.expand_button_container) + expandBtnContainer = findViewById(com.android.internal.R.id.expand_button_container) importanceRing = requireViewById(com.android.internal.R.id.conversation_icon_badge_ring) appName = requireViewById(com.android.internal.R.id.app_name_text) - conversationTitleView = requireViewById(com.android.internal.R.id.conversation_text) + conversationTitleView = + requireViewById( + if (notificationsRedesignTemplates()) com.android.internal.R.id.title + else com.android.internal.R.id.conversation_text + ) facePileTop = findViewById(com.android.internal.R.id.conversation_face_pile_top) facePileBottom = findViewById(com.android.internal.R.id.conversation_face_pile_bottom) facePileBottomBg = @@ -133,11 +139,21 @@ class NotificationConversationTemplateViewWrapper( expandable: Boolean, onClickListener: View.OnClickListener, requestLayout: Boolean, - ) = conversationLayout.updateExpandability(expandable, onClickListener) + ) { + if (notificationsRedesignTemplates()) { + super.updateExpandability(expandable, onClickListener, requestLayout) + } else { + conversationLayout.updateExpandability(expandable, onClickListener) + } + } override fun disallowSingleClick(x: Float, y: Float): Boolean { val isOnExpandButton = - expandBtnContainer.visibility == View.VISIBLE && isOnView(expandBtnContainer, x, y) + if (notificationsRedesignTemplates()) { + expandBtn.isVisible && isOnView(expandBtn, x, y) + } else { + expandBtnContainer?.visibility == View.VISIBLE && isOnView(expandBtnContainer, x, y) + } return isOnExpandButton || super.disallowSingleClick(x, y) } @@ -158,7 +174,8 @@ class NotificationConversationTemplateViewWrapper( // and the top level image message container. val containers = messageContainers.asSequence().map { it.messageContainer } + - sequenceOf(imageMessageContainer) + if (notificationsRedesignTemplates()) emptySequence() + else sequenceOf(imageMessageContainer!!) val drawables = containers .flatMap { it.children } |