diff options
| author | 2025-02-18 19:14:52 +0100 | |
|---|---|---|
| committer | 2025-02-18 20:28:06 +0100 | |
| commit | 7498fce7002a8de9d193ae06347a97728993261c (patch) | |
| tree | ea040b225e91a1dfa6a7dd8b33296ef8204d360e | |
| parent | 9cdd2d3b5a686184b499c3e7d7ce99cca85b0e22 (diff) | |
[Notif redesign] Update call layouts
Make the structure more consistent with the other templates, including
showing the top line with the app name above the text in the expanded
form. This also means that although previously we'd use the expanded
layout for HUNs, now we just use the collapsed layout (that also has the
smart replies/actions containers), similar to what we do for messaging
style.
Note that the new notification_2025_template_collapsed_call.xml and
notification_2025_template_expanded_call.xml are a combination of
notification_2025_template_collapsed_conversation.xml/
notification_2025_template_collapsed_base.xml and
notification_2025_template_expanded_conversation.xml/
notification_2025_template_expanded_base.xml respectively.
Bug: 378660052
Test: tested manually + screenshot tests
Flag: android.app.notifications_redesign_templates
Change-Id: I88276e0a2a3480d63ca728369aac724278e17827
4 files changed, 213 insertions, 122 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 06047a42e70d..719e4389d92d 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5966,7 +5966,9 @@ public class Notification implements Parcelable || resId == getMessagingCompactHeadsUpLayoutResource() || resId == getCollapsedMessagingLayoutResource() || resId == getCollapsedMediaLayoutResource() - || resId == getCollapsedConversationLayoutResource()); + || resId == getCollapsedConversationLayoutResource() + || (notificationsRedesignTemplates() + && resId == getCollapsedCallLayoutResource())); RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -11035,6 +11037,7 @@ public class Notification implements Parcelable private RemoteViews makeCallLayout(int viewType) { final boolean isCollapsed = viewType == StandardTemplateParams.VIEW_TYPE_NORMAL; + final boolean isHeadsUp = viewType == StandardTemplateParams.VIEW_TYPE_HEADS_UP; Bundle extras = mBuilder.mN.extras; CharSequence title = mPerson != null ? mPerson.getName() : null; CharSequence text = mBuilder.processLegacyText(extras.getCharSequence(EXTRA_TEXT)); @@ -11050,22 +11053,31 @@ public class Notification implements Parcelable .hideLeftIcon(true) .hideRightIcon(true) .hideAppName(isCollapsed) - .titleViewId(R.id.conversation_text) .title(title) - .text(text) - .summaryText(mBuilder.processLegacyText(mVerificationText)); + .text(text); + if (!notificationsRedesignTemplates()) { + // We're using the normal title in the redesign, not a special text. + p.titleViewId(R.id.conversation_text) + // The verification text is now part of the top line views, so this is no + // longer necessary. + .summaryText(mBuilder.processLegacyText(mVerificationText)); + } mBuilder.mActions = getActionsListWithSystemActions(); final RemoteViews contentView; if (isCollapsed) { contentView = mBuilder.applyStandardTemplate( mBuilder.getCollapsedCallLayoutResource(), p, null /* result */); + } else if (notificationsRedesignTemplates() && isHeadsUp) { + contentView = mBuilder.applyStandardTemplateWithActions( + mBuilder.getCollapsedCallLayoutResource(), p, null /* result */); } else { contentView = mBuilder.applyStandardTemplateWithActions( mBuilder.getExpandedCallLayoutResource(), p, null /* result */); } // Bind some extra conversation-specific header fields. - if (!p.mHideAppName) { + if (!notificationsRedesignTemplates() && !p.mHideAppName) { + // Redesign note: This special divider is no longer needed. mBuilder.setTextViewColorSecondary(contentView, R.id.app_name_divider, p); contentView.setViewVisibility(R.id.app_name_divider, View.VISIBLE); } 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 f1729b3c2f76..ee691e4d6894 100644 --- a/core/res/res/layout/notification_2025_template_collapsed_call.xml +++ b/core/res/res/layout/notification_2025_template_collapsed_call.xml @@ -1,5 +1,5 @@ <?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. @@ -25,55 +25,177 @@ android:theme="@style/Theme.DeviceDefault.Notification" > - <!-- CallLayout shares visual appearance with ConversationLayout, so shares layouts --> - <include layout="@layout/notification_2025_conversation_icon_container" /> - <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="@dimen/notification_2025_min_height" - android:orientation="horizontal" + android:clipChildren="false" + android:orientation="vertical" > - <LinearLayout - android:id="@+id/notification_main_column" + <com.android.internal.widget.NotificationMaxHeightFrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_marginStart="@dimen/notification_2025_content_margin_start" - android:orientation="vertical" - android:paddingBottom="@dimen/notification_2025_margin" + android:minHeight="@dimen/notification_2025_min_height" + android:clipChildren="false" > - <include - layout="@layout/notification_template_conversation_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + <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_template_text" - android:layout_height="wrap_content" - android:minHeight="@dimen/notification_text_height" + <!-- CallLayout shares visual appearance with ConversationLayout, so shares layouts --> + <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" /> - </LinearLayout> + <LinearLayout + android:id="@+id/notification_headerless_view_row" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginStart="@dimen/notification_2025_content_margin_start" + android:orientation="horizontal" + android:clipChildren="false" + > - <FrameLayout - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:minWidth="@dimen/notification_content_margin_end" - > + <LinearLayout + android:id="@+id/notification_headerless_view_column" + 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:clipChildren="false" + android:orientation="vertical" + > - <include - layout="@layout/notification_2025_expand_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="top|end" - /> + <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> - </FrameLayout> + <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.NotificationVanishingFrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="@dimen/notification_headerless_line_height" + > + <!-- This is the simplest way to keep this text vertically centered without + gravity="center_vertical" which causes jumpiness in expansion animations. --> + <include + layout="@layout/notification_2025_text" + android:layout_width="match_parent" + android:layout_height="@dimen/notification_text_height" + android:layout_gravity="center_vertical" + android:layout_marginTop="0dp" + /> + </com.android.internal.widget.NotificationVanishingFrameLayout> + </LinearLayout> + </LinearLayout> + + <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.CallLayout> 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 2114831f4c15..bbc29664d594 100644 --- a/core/res/res/layout/notification_2025_template_expanded_call.xml +++ b/core/res/res/layout/notification_2025_template_expanded_call.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. @@ -27,83 +27,47 @@ > <!-- CallLayout shares visual appearance with ConversationLayout, so shares layouts --> - <include layout="@layout/notification_2025_conversation_icon_container" /> + <include layout="@layout/notification_2025_conversation_header"/> - <LinearLayout + <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_marginBottom="@dimen/notification_content_margin" - android:orientation="vertical" - > - - <LinearLayout + 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:orientation="horizontal" + android:layout_marginStart="@dimen/notification_2025_content_margin_start" + android:layout_marginEnd="@dimen/notification_content_margin_end" + android:orientation="vertical" + android:clipChildren="false" > - <LinearLayout - android:id="@+id/notification_main_column" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/notification_2025_content_margin_start" - android:layout_weight="1" - android:orientation="vertical" - android:minHeight="68dp" - > - - <include - layout="@layout/notification_template_conversation_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - /> - - <include layout="@layout/notification_template_text_multiline" /> - - <include - android:layout_width="match_parent" - android:layout_height="@dimen/notification_progress_bar_height" - android:layout_marginTop="@dimen/notification_progress_margin_top" - layout="@layout/notification_template_progress" - /> - </LinearLayout> - - <FrameLayout - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:minWidth="@dimen/notification_content_margin_end" - > - - <include - layout="@layout/notification_expand_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - /> + <include layout="@layout/notification_template_part_line1"/> - </FrameLayout> + <include layout="@layout/notification_template_text_multiline" /> - </LinearLayout> + </com.android.internal.widget.RemeasuringLinearLayout> - <ViewStub - android:layout="@layout/notification_material_reply_text" - android:id="@+id/notification_material_reply_container" + <include layout="@layout/notification_template_smart_reply_container" android:layout_width="match_parent" android:layout_height="wrap_content" - /> - - <include - layout="@layout/notification_template_smart_reply_container" - android:layout_width="match_parent" - 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_marginStart="@dimen/notification_2025_content_margin_start" + android:layout_marginEnd="@dimen/notification_content_margin_end" /> <include layout="@layout/notification_material_action_list" /> - </LinearLayout> + </com.android.internal.widget.RemeasuringLinearLayout> + + <include layout="@layout/notification_template_right_icon" /> </com.android.internal.widget.CallLayout> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCallTemplateViewWrapper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCallTemplateViewWrapper.kt index 2d946945597e..e887e25b74a2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCallTemplateViewWrapper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCallTemplateViewWrapper.kt @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.notification.row.wrapper +import android.app.Flags.notificationsRedesignTemplates import android.content.Context import android.view.View import com.android.internal.widget.CachingIconView @@ -25,17 +26,13 @@ import com.android.systemui.statusbar.notification.NotificationFadeAware import com.android.systemui.statusbar.notification.NotificationUtils import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow -/** - * Wraps a notification containing a call template - */ -class NotificationCallTemplateViewWrapper constructor( - ctx: Context, - view: View, - row: ExpandableNotificationRow -) : NotificationTemplateViewWrapper(ctx, view, row) { +/** Wraps a notification containing a call template */ +class NotificationCallTemplateViewWrapper +constructor(ctx: Context, view: View, row: ExpandableNotificationRow) : + NotificationTemplateViewWrapper(ctx, view, row) { private val minHeightWithActions: Int = - NotificationUtils.getFontScaledHeight(ctx, R.dimen.notification_max_height) + NotificationUtils.getFontScaledHeight(ctx, R.dimen.notification_max_height) private val callLayout: CallLayout = view as CallLayout private lateinit var conversationIconContainer: View @@ -48,13 +45,17 @@ class NotificationCallTemplateViewWrapper constructor( private fun resolveViews() { with(callLayout) { conversationIconContainer = - requireViewById(com.android.internal.R.id.conversation_icon_container) + requireViewById(com.android.internal.R.id.conversation_icon_container) conversationIconView = requireViewById(com.android.internal.R.id.conversation_icon) conversationBadgeBg = - requireViewById(com.android.internal.R.id.conversation_icon_badge_bg) + requireViewById(com.android.internal.R.id.conversation_icon_badge_bg) expandBtn = requireViewById(com.android.internal.R.id.expand_button) 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 + ) } } @@ -68,20 +69,12 @@ class NotificationCallTemplateViewWrapper constructor( override fun updateTransformedTypes() { // This also clears the existing types super.updateTransformedTypes() - addTransformedViews( - appName, - conversationTitleView - ) - addViewsTransformingToSimilar( - conversationIconView, - conversationBadgeBg, - expandBtn - ) + addTransformedViews(appName, conversationTitleView) + addViewsTransformingToSimilar(conversationIconView, conversationBadgeBg, expandBtn) } override fun disallowSingleClick(x: Float, y: Float): Boolean { - val isOnExpandButton = expandBtn.visibility == View.VISIBLE && - isOnView(expandBtn, x, y) + val isOnExpandButton = expandBtn.visibility == View.VISIBLE && isOnView(expandBtn, x, y) return isOnExpandButton || super.disallowSingleClick(x, y) } |