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

Commit 12fa627b authored by Jeff DeCew's avatar Jeff DeCew
Browse files

CallStyle now supports contextual actions (e.g. smart replies)

* This required that call style also has a collapsed state which has no actions.  Removing actions from the collapsed state resolves a bunch of bugs that were being introduced.  There's just too much of SystemUI that assumes collapsed notifications don't have actions to fix this right now.
* To make the collapsed state match stylistically, I also had to remove the progress bar from that state for vertical space reasons.

Bug: 179178086
Test: atest NotificationTemplateTests
Test: visual inspection ; expand/collapse
Change-Id: I6bc865d5fca8459ffaa6031d220d8bfa08545d89
parent 1f8c257d
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -6583,10 +6583,6 @@ public class Notification implements Parcelable
            return R.layout.notification_template_material_conversation;
        }

        private int getCallLayoutResource() {
            return R.layout.notification_template_material_call;
        }

        private int getActionLayoutResource() {
            return R.layout.notification_material_action;
        }
@@ -9329,7 +9325,7 @@ public class Notification implements Parcelable
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
            return makeCallLayout();
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_NORMAL);
        }

        /**
@@ -9337,14 +9333,14 @@ public class Notification implements Parcelable
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
            return makeCallLayout();
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_HEADS_UP);
        }

        /**
         * @hide
         */
        public RemoteViews makeBigContentView() {
            return makeCallLayout();
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_BIG);
        }

        @NonNull
@@ -9443,7 +9439,7 @@ public class Notification implements Parcelable
            return resultActions;
        }

        private RemoteViews makeCallLayout() {
        private RemoteViews makeCallLayout(int viewType) {
            Bundle extras = mBuilder.mN.extras;
            CharSequence text = mBuilder.processLegacyText(extras.getCharSequence(EXTRA_TEXT));
            if (text == null) {
@@ -9452,15 +9448,21 @@ public class Notification implements Parcelable

            // Bind standard template
            StandardTemplateParams p = mBuilder.mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_BIG)
                    .viewType(viewType)
                    .callStyleActions(true)
                    .allowTextWithProgress(true)
                    .hideLargeIcon(true)
                    .text(text)
                    .summaryText(mBuilder.processLegacyText(mVerificationText));
            mBuilder.mActions = getActionsListWithSystemActions();
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                    mBuilder.getCallLayoutResource(), p, null /* result */);
            final RemoteViews contentView;
            if (p.mViewType != StandardTemplateParams.VIEW_TYPE_NORMAL) {
                contentView = mBuilder.applyStandardTemplateWithActions(
                        R.layout.notification_template_material_big_call, p, null /* result */);
            } else {
                contentView = mBuilder.applyStandardTemplate(
                        R.layout.notification_template_material_call, p, null /* result */);
            }

            // Bind some extra conversation-specific header fields.
            mBuilder.setTextViewColorPrimary(contentView, R.id.conversation_text, p);
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
        android:id="@+id/notification_action_list_margin_target"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/notification_action_list_height"
        android:layout_marginBottom="@dimen/notification_content_margin"
        android:orientation="vertical"
        >

+107 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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
  -->
<com.android.internal.widget.CallLayout
    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="call"
    android:theme="@style/Theme.DeviceDefault.Notification"
    >

    <!-- CallLayout shares visual appearance with ConversationLayout, so shares layouts -->
    <include layout="@layout/notification_template_conversation_icon_container" />

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

            <LinearLayout
                android:id="@+id/notification_main_column"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginStart="@dimen/conversation_content_start"
                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"
                    />

            </FrameLayout>

        </LinearLayout>

        <ViewStub
            android:layout="@layout/notification_material_reply_text"
            android:id="@+id/notification_material_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_content_margin_start"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:layout_marginTop="@dimen/notification_content_margin"
            />

        <include layout="@layout/notification_material_action_list" />

    </LinearLayout>

</com.android.internal.widget.CallLayout>
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginTop="@dimen/notification_content_margin_top"
        android:layout_marginBottom="@dimen/notification_action_list_height"
        android:layout_marginBottom="@dimen/notification_content_margin"
        android:clipToPadding="false"
        android:orientation="vertical"
        >
+25 −44
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2021 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +18,6 @@
    android:id="@+id/status_bar_latest_event_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:clipChildren="false"
    android:tag="call"
    android:theme="@style/Theme.DeviceDefault.Notification"
@@ -29,18 +27,9 @@
    <include layout="@layout/notification_template_conversation_icon_container" />

    <LinearLayout
        android:id="@+id/notification_action_list_margin_target"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/notification_action_list_height"
        android:orientation="vertical"
        >

        <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="top"
        android:layout_height="80dp"
        android:orientation="horizontal"
        >

@@ -62,12 +51,6 @@

            <include layout="@layout/notification_template_text" />

                <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
@@ -76,17 +59,15 @@
            android:minWidth="@dimen/notification_content_margin_end"
            >

                <include layout="@layout/notification_expand_button"
            <include
                layout="@layout/notification_expand_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                />

        </FrameLayout>

    </LinearLayout>

        <include layout="@layout/notification_material_action_list" />

    </LinearLayout>

</com.android.internal.widget.CallLayout>
Loading