From 12fa627bfb9b128a51ca7789f352805b5b61c069 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 8 Mar 2021 16:22:52 -0500 Subject: [PATCH] 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 --- core/java/android/app/Notification.java | 24 ++-- ...otification_template_material_big_base.xml | 2 +- ...otification_template_material_big_call.xml | 107 ++++++++++++++++++ ...otification_template_material_big_text.xml | 2 +- .../notification_template_material_call.xml | 73 +++++------- core/res/res/values/symbols.xml | 1 + 6 files changed, 150 insertions(+), 59 deletions(-) create mode 100644 core/res/res/layout/notification_template_material_big_call.xml diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 2b45723dae557..c66f3f746b659 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -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); diff --git a/core/res/res/layout/notification_template_material_big_base.xml b/core/res/res/layout/notification_template_material_big_base.xml index 2d1c3422ca368..b9a3625f9e452 100644 --- a/core/res/res/layout/notification_template_material_big_base.xml +++ b/core/res/res/layout/notification_template_material_big_base.xml @@ -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" > diff --git a/core/res/res/layout/notification_template_material_big_call.xml b/core/res/res/layout/notification_template_material_big_call.xml new file mode 100644 index 0000000000000..1d5046777e77e --- /dev/null +++ b/core/res/res/layout/notification_template_material_big_call.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/notification_template_material_big_text.xml b/core/res/res/layout/notification_template_material_big_text.xml index 2954ba2a09033..86e7dec29e7df 100644 --- a/core/res/res/layout/notification_template_material_big_text.xml +++ b/core/res/res/layout/notification_template_material_big_text.xml @@ -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" > diff --git a/core/res/res/layout/notification_template_material_call.xml b/core/res/res/layout/notification_template_material_call.xml index c2ffd1f0d8b35..5d9e761842d84 100644 --- a/core/res/res/layout/notification_template_material_call.xml +++ b/core/res/res/layout/notification_template_material_call.xml @@ -1,5 +1,4 @@ - - +