Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7498fce7 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[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
parent 9cdd2d3b
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -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)
                    .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);
            }
+155 −33
Original line number Diff line number Diff line
<?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,48 +25,145 @@
    android:theme="@style/Theme.DeviceDefault.Notification"
    >

    <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"
                />

            <!-- 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
        xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/notification_headerless_view_row"
                android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="@dimen/notification_2025_min_height"
                android:layout_height="match_parent"
                android:layout_marginStart="@dimen/notification_2025_content_margin_start"
                android:orientation="horizontal"
                android:clipChildren="false"
                >

                <LinearLayout
            android:id="@+id/notification_main_column"
            android:layout_width="match_parent"
                    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_marginStart="@dimen/notification_2025_content_margin_start"
                    android:layout_marginBottom="@dimen/notification_2025_margin"
                    android:layout_marginTop="@dimen/notification_2025_margin"
                    android:clipChildren="false"
                    android:orientation="vertical"
            android:paddingBottom="@dimen/notification_2025_margin"
                    >

            <include
                layout="@layout/notification_template_conversation_header"
                    <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_template_text"
                        <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:minHeight="@dimen/notification_text_height"
                        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"
                    <include layout="@layout/notification_2025_expand_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="top|end"
@@ -76,4 +173,29 @@

            </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>
+25 −61
Original line number Diff line number Diff line
<?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_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal"
            >
        android:layout_gravity="top"
        android:clipChildren="false"
        android:orientation="vertical">

            <LinearLayout
        <!-- 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_marginStart="@dimen/notification_2025_content_margin_start"
            android:layout_gravity="top"
            android:layout_weight="1"
            android:layout_marginStart="@dimen/notification_2025_content_margin_start"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:orientation="vertical"
                android:minHeight="68dp"
            android:clipChildren="false"
            >

                <include
                    layout="@layout/notification_template_conversation_header"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    />
            <include layout="@layout/notification_template_part_line1"/>

            <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>
        </com.android.internal.widget.RemeasuringLinearLayout>

            <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"
                    />

            </FrameLayout>

        </LinearLayout>

        <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>
+16 −23
Original line number Diff line number Diff line
@@ -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,14 +26,10 @@ 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)
@@ -54,7 +51,11 @@ class NotificationCallTemplateViewWrapper constructor(
                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)
    }