From 4d19b03fd5ac18ead6cbed7a0d9ae12580ada35b Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 17 Nov 2020 20:48:42 -0500 Subject: [PATCH 1/3] Fix Gmail undo state. We forced all notifications to have an expanded state, but the Gmail undo notification is totally broken in that case. This check exempts an obviosuly bad expanded state from having to exist, fixing Gmail's undo flow in the process. Fixes: 173774694 Bug: 163626038 Bug: 173550917 Test: manual Change-Id: I8973907ceb06ccf06c0a685fc0f2a2d283794fe5 --- core/java/android/app/Notification.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index e40247ba2d9a6..0ccd07a3a53e2 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5520,7 +5520,7 @@ public class Notification implements Parcelable result = mStyle.makeBigContentView(); hideLine1Text(result); } - if (result == null) { + if (result == null && bigContentViewRequired()) { result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), StandardTemplateParams.VIEW_TYPE_BIG, null /* result */); } @@ -5528,6 +5528,16 @@ public class Notification implements Parcelable return result; } + private boolean bigContentViewRequired() { + // If the big content view has no content, we can exempt the app from having to show it. + // TODO(b/173550917): add an UNDO style then force this requirement on apps targeting S + boolean exempt = mN.contentView != null && mN.bigContentView == null + && mStyle == null && mActions.size() == 0 + && mN.extras.getCharSequence(EXTRA_TITLE) == null + && mN.extras.getCharSequence(EXTRA_TEXT) == null; + return !exempt; + } + /** * Construct a RemoteViews for the final notification header only. This will not be * colorized. From 370a2ce7d78d9c227af03c0477f3ecf2c89f8205 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 18 Nov 2020 10:10:34 -0500 Subject: [PATCH 2/3] Fix snooze/bubble button padding * Reduce the conversation expander width to 48dp. This matches the expander width for normal notifications. * Remove end padding for snooze or bubble buttons. * Use layout to ensure 12dp end padding for actions iff neither of the buttons is present. Bug: 163626038 Test: manual Change-Id: Ic780f98ad74a2e148db2716aca52abe5137fa4a1 --- .../notification_material_action_list.xml | 45 ++++++++++++------- ...ication_template_material_conversation.xml | 4 +- core/res/res/values/dimens.xml | 10 ++--- core/res/res/values/symbols.xml | 2 - .../row/NotificationContentView.java | 8 ---- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/core/res/res/layout/notification_material_action_list.xml b/core/res/res/layout/notification_material_action_list.xml index 552a1bd6aa2ee..9662b8e35bf68 100644 --- a/core/res/res/layout/notification_material_action_list.xml +++ b/core/res/res/layout/notification_material_action_list.xml @@ -28,7 +28,6 @@ android:layout_height="wrap_content" android:gravity="end" android:orientation="horizontal" - android:paddingEnd="@dimen/bubble_gone_padding_end" android:background="@color/notification_action_list_background_color" > @@ -45,22 +44,34 @@ - + + + - + + diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index 520ae282b9421..f9364d565f3b1 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -327,10 +327,10 @@ android:id="@+id/expand_button_touch_container" android:layout_width="wrap_content" android:layout_height="@dimen/conversation_expand_button_size" - android:paddingStart="16dp" + android:paddingStart="@dimen/conversation_expand_button_side_margin" android:orientation="horizontal" android:layout_gravity="end|top" - android:paddingEnd="@dimen/notification_content_margin_end" + android:paddingEnd="@dimen/conversation_expand_button_side_margin" android:clipToPadding="false" android:clipChildren="false" > diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 79eae67e5fba2..38223e6ebdb69 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -340,11 +340,8 @@ 8dp - - 3dp - - - 12dp + + 12dp 6dp @@ -744,6 +741,9 @@ 80dp 18dp + + 13dp 36dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 752bb5b37a30a..6e19290d97603 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3560,8 +3560,6 @@ - - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 328774550f243..74e6c003041e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1369,16 +1369,8 @@ public class NotificationContentView extends FrameLayout { bubbleButton.setOnClickListener(mContainingNotification.getBubbleClickListener()); bubbleButton.setVisibility(VISIBLE); actionContainer.setVisibility(VISIBLE); - - int paddingEnd = getResources().getDimensionPixelSize( - com.android.internal.R.dimen.bubble_visible_padding_end); - actionContainerLayout.setPaddingRelative(0, 0, paddingEnd, 0); } else { bubbleButton.setVisibility(GONE); - - int paddingEnd = getResources().getDimensionPixelSize( - com.android.internal.R.dimen.bubble_gone_padding_end); - actionContainerLayout.setPaddingRelative(0, 0, paddingEnd, 0); } } From fa5c76c245ad37dbaf12ec7f1ef3880ed5ae75c4 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 19 Nov 2020 19:57:20 -0500 Subject: [PATCH 3/3] Collapsed DecoratedCustomView notifications show app name instead of title. Previously, we never showed a title in the decorations, and we still don't in the expanded decorations. Rather than making devleopers deal with the discrepancy, it's easier to just show the app name for these views. It makes them a tad less desirable, but we could potentially give developers a flag to opt into the title in the future. Bug: 163626038 Bug: 173528244 Bug: 173742646 Test: manual Change-Id: I8e5fe162c1ccdddcd39ea36f2b28fcc6aefd1f83 --- core/java/android/app/Notification.java | 61 ++++++++++++------- .../layout/notification_template_header.xml | 10 --- .../notification_template_material_base.xml | 6 ++ .../layout/notification_top_line_views.xml | 14 ++++- .../statusbar/NotificationHeaderUtil.java | 16 ++++- 5 files changed, 71 insertions(+), 36 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 0ccd07a3a53e2..2bf5368b691ba 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4888,12 +4888,6 @@ public class Notification implements Parcelable mN.mUsesStandardHeader = false; } - private RemoteViews applyStandardTemplate(int resId, int viewType, - TemplateBindResult result) { - return applyStandardTemplate(resId, - mParams.reset().viewType(viewType).fillTextsFrom(this), result); - } - private RemoteViews applyStandardTemplate(int resId, StandardTemplateParams p, TemplateBindResult result) { p.headerless(resId == getBaseLayoutResource() @@ -4907,7 +4901,7 @@ public class Notification implements Parcelable bindNotificationHeader(contentView, p); bindLargeIconAndApplyMargin(contentView, p, result); boolean showProgress = handleProgressBar(contentView, ex, p); - if (p.title != null && p.title.length() > 0) { + if (p.title != null && p.title.length() > 0 && !p.mHasCustomContent) { contentView.setViewVisibility(R.id.title, View.VISIBLE); contentView.setTextViewText(R.id.title, processTextSpans(p.title)); setTextViewColorPrimary(contentView, R.id.title, p); @@ -5302,6 +5296,12 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.app_name_text, View.GONE); return false; } + if (p.mHeaderless && !p.mHasCustomContent) { + contentView.setViewVisibility(R.id.app_name_text, View.GONE); + // the headerless template will have the TITLE in this position; return true to + // keep the divider visible between that title and the next text element. + return true; + } contentView.setViewVisibility(R.id.app_name_text, View.VISIBLE); contentView.setTextViewText(R.id.app_name_text, loadHeaderAppName()); if (isColorized(p)) { @@ -5356,12 +5356,6 @@ public class Notification implements Parcelable snoozeEnabled ? 0 : R.dimen.notification_content_margin); } - private RemoteViews applyStandardTemplateWithActions(int layoutId, int viewType, - TemplateBindResult result) { - return applyStandardTemplateWithActions(layoutId, - mParams.reset().viewType(viewType).fillTextsFrom(this), result); - } - private static List filterOutContextualActions( List actions) { List nonContextualActions = new ArrayList<>(); @@ -5499,8 +5493,10 @@ public class Notification implements Parcelable return styleView; } } - return applyStandardTemplate(getBaseLayoutResource(), - StandardTemplateParams.VIEW_TYPE_NORMAL, null /* result */); + StandardTemplateParams p = mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL) + .fillTextsFrom(this); + return applyStandardTemplate(getBaseLayoutResource(), p, null /* result */); } private boolean useExistingRemoteView() { @@ -5521,8 +5517,11 @@ public class Notification implements Parcelable hideLine1Text(result); } if (result == null && bigContentViewRequired()) { - result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), - StandardTemplateParams.VIEW_TYPE_BIG, null /* result */); + StandardTemplateParams p = mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG) + .fillTextsFrom(this); + result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), p, + null /* result */); } makeHeaderExpanded(result); return result; @@ -8703,18 +8702,24 @@ public class Notification implements Parcelable return makeStandardTemplateWithCustomContent(headsUpContentView); } TemplateBindResult result = new TemplateBindResult(); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP) + .hasCustomContent(headsUpContentView != null) + .fillTextsFrom(mBuilder); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getHeadsUpBaseLayoutResource(), - StandardTemplateParams.VIEW_TYPE_HEADS_UP, result); + mBuilder.getHeadsUpBaseLayoutResource(), p, result); buildIntoRemoteViewContent(remoteViews, headsUpContentView, result, true); return remoteViews; } private RemoteViews makeStandardTemplateWithCustomContent(RemoteViews customContent) { TemplateBindResult result = new TemplateBindResult(); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL) + .hasCustomContent(customContent != null) + .fillTextsFrom(mBuilder); RemoteViews remoteViews = mBuilder.applyStandardTemplate( - mBuilder.getBaseLayoutResource(), - StandardTemplateParams.VIEW_TYPE_NORMAL, result); + mBuilder.getBaseLayoutResource(), p, result); buildIntoRemoteViewContent(remoteViews, customContent, result, true); return remoteViews; } @@ -8724,9 +8729,12 @@ public class Notification implements Parcelable ? mBuilder.mN.contentView : mBuilder.mN.bigContentView; TemplateBindResult result = new TemplateBindResult(); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG) + .hasCustomContent(bigContentView != null) + .fillTextsFrom(mBuilder); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource(), - StandardTemplateParams.VIEW_TYPE_BIG, result); + mBuilder.getBigBaseLayoutResource(), p, result); buildIntoRemoteViewContent(remoteViews, bigContentView, result, false); return remoteViews; } @@ -11039,6 +11047,7 @@ public class Notification implements Parcelable int mViewType = VIEW_TYPE_UNSPECIFIED; boolean mHeaderless; + boolean mHasCustomContent; boolean hasProgress = true; CharSequence title; CharSequence text; @@ -11052,6 +11061,7 @@ public class Notification implements Parcelable final StandardTemplateParams reset() { mViewType = VIEW_TYPE_UNSPECIFIED; mHeaderless = false; + mHasCustomContent = false; hasProgress = true; title = null; text = null; @@ -11078,6 +11088,11 @@ public class Notification implements Parcelable return this; } + final StandardTemplateParams hasCustomContent(boolean hasCustomContent) { + this.mHasCustomContent = hasCustomContent; + return this; + } + final StandardTemplateParams title(CharSequence title) { this.title = title; return this; diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml index a26473ad60102..4b67509db457e 100644 --- a/core/res/res/layout/notification_template_header.xml +++ b/core/res/res/layout/notification_template_header.xml @@ -50,16 +50,6 @@ android:theme="@style/Theme.DeviceDefault.Notification" > - - diff --git a/core/res/res/layout/notification_template_material_base.xml b/core/res/res/layout/notification_template_material_base.xml index ded16b7edf87b..9d581729df722 100644 --- a/core/res/res/layout/notification_template_material_base.xml +++ b/core/res/res/layout/notification_template_material_base.xml @@ -68,6 +68,12 @@ android:theme="@style/Theme.DeviceDefault.Notification" > + + + +