From e84b4b825d47f0ff8daf4b22668711c42331c19f Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 13 Nov 2020 11:14:47 -0500 Subject: [PATCH 01/14] Remove night-mode override of notification_divider_height Test: manual Change-Id: I983b6ea87d59717795253df99d7589203b23d373 --- packages/SystemUI/res/values-night/dimens.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/SystemUI/res/values-night/dimens.xml b/packages/SystemUI/res/values-night/dimens.xml index 23e3231128450..d2d4198b77286 100644 --- a/packages/SystemUI/res/values-night/dimens.xml +++ b/packages/SystemUI/res/values-night/dimens.xml @@ -16,8 +16,6 @@ --> - - 1dp 375dp From 18422628138f37af9f101ef4ea141690bb014a54 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 21 Oct 2020 21:51:23 -0400 Subject: [PATCH 02/14] Notification template redesign; part 1. Known issues: * Sub-par dyson animation * Sub-par animation of text in the title * Notification height limits not yet adjusted * Decorated custom view height limits not yet updated * HUNs may need to get their own headerless template * Messaging style notifications are not yet headerless * Possible [de]colorization bug for grouped icons * Some notifications still not always expandable Bug: 163626038 Test: Manual, visual testing Change-Id: I9e7e2fd689938a13e042c8f6319bd7d0d2252781 --- config/hiddenapi-max-target-o.txt | 2 - core/java/android/app/Notification.java | 270 ++++++++++++------ .../android/view/NotificationHeaderView.java | 143 ++-------- .../android/view/NotificationTopLineView.java | 25 +- .../widget/MediaNotificationView.java | 8 +- .../res/drawable/notification_icon_circle.xml | 19 ++ .../notification_large_icon_outline.xml | 21 ++ .../notification_material_action_list.xml | 83 +++--- .../layout/notification_template_header.xml | 75 +++-- .../notification_template_material_base.xml | 116 ++++++-- ...otification_template_material_big_base.xml | 53 +++- ...tification_template_material_big_media.xml | 44 ++- ...fication_template_material_big_picture.xml | 94 +++--- ...otification_template_material_big_text.xml | 70 +++-- ...ication_template_material_conversation.xml | 4 +- .../notification_template_material_inbox.xml | 1 + ...tification_template_material_messaging.xml | 3 +- .../notification_template_reply_icon.xml | 27 ++ .../notification_template_right_icon.xml | 41 +-- .../res/layout/notification_template_text.xml | 6 +- ...ne.xml => notification_top_line_views.xml} | 62 ++-- core/res/res/values/dimens.xml | 58 +++- core/res/res/values/symbols.xml | 10 +- .../statusbar/NotificationHeaderUtil.java | 11 +- .../row/NotificationContentView.java | 31 +- .../NotificationHeaderViewWrapper.java | 41 ++- packages/SystemUI/tools/lint/baseline.xml | 11 - 27 files changed, 797 insertions(+), 532 deletions(-) create mode 100644 core/res/res/drawable/notification_icon_circle.xml create mode 100644 core/res/res/drawable/notification_large_icon_outline.xml create mode 100644 core/res/res/layout/notification_template_reply_icon.xml rename core/res/res/layout/{notification_template_top_line.xml => notification_top_line_views.xml} (82%) diff --git a/config/hiddenapi-max-target-o.txt b/config/hiddenapi-max-target-o.txt index 023bf38762285..eefe493efbc49 100644 --- a/config/hiddenapi-max-target-o.txt +++ b/config/hiddenapi-max-target-o.txt @@ -91659,8 +91659,6 @@ Lcom/android/internal/R$dimen;->notification_expand_button_padding_top:I Lcom/android/internal/R$dimen;->notification_header_app_name_margin_start:I Lcom/android/internal/R$dimen;->notification_header_background_height:I Lcom/android/internal/R$dimen;->notification_header_expand_icon_size:I -Lcom/android/internal/R$dimen;->notification_header_height:I -Lcom/android/internal/R$dimen;->notification_header_icon_margin_end:I Lcom/android/internal/R$dimen;->notification_header_icon_size:I Lcom/android/internal/R$dimen;->notification_header_separating_margin:I Lcom/android/internal/R$dimen;->notification_header_shrink_min_width:I diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 4c08e759f3cf7..113ec4df3c9f4 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4868,13 +4868,15 @@ public class Notification implements Parcelable mN.mUsesStandardHeader = false; } - private RemoteViews applyStandardTemplate(int resId, TemplateBindResult result) { - return applyStandardTemplate(resId, mParams.reset().fillTextsFrom(this), - result); + 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()); RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -4884,7 +4886,7 @@ public class Notification implements Parcelable bindNotificationHeader(contentView, p); bindLargeIconAndReply(contentView, p, result); boolean showProgress = handleProgressBar(contentView, ex, p); - if (p.title != null) { + if (p.title != null && p.title.length() > 0) { contentView.setViewVisibility(R.id.title, View.VISIBLE); contentView.setTextViewText(R.id.title, processTextSpans(p.title)); setTextViewColorPrimary(contentView, R.id.title, p); @@ -5099,53 +5101,56 @@ public class Notification implements Parcelable } } - private void bindLargeIconAndReply(RemoteViews contentView, StandardTemplateParams p, - TemplateBindResult result) { + private void bindLargeIconAndReply(RemoteViews contentView, + @NonNull StandardTemplateParams p, + @Nullable TemplateBindResult result) { + if (result == null) { + result = new TemplateBindResult(); + } boolean largeIconShown = bindLargeIcon(contentView, p); boolean replyIconShown = bindReplyIcon(contentView, p); - boolean iconContainerVisible = largeIconShown || replyIconShown; - contentView.setViewVisibility(R.id.right_icon_container, - iconContainerVisible ? View.VISIBLE : View.GONE); - int marginEnd = calculateMarginEnd(largeIconShown, replyIconShown); - contentView.setViewLayoutMarginEnd(R.id.line1, marginEnd); - contentView.setViewLayoutMarginEnd(R.id.text, marginEnd); - contentView.setViewLayoutMarginEnd(R.id.progress, marginEnd); - if (result != null) { - result.setIconMarginEnd(marginEnd); - result.setRightIconContainerVisible(iconContainerVisible); + calculateLargeIconMarginEnd(largeIconShown, result); + calculateReplyIconMarginEnd(replyIconShown, result); + if (p.mHeaderless) { + // views in the headerless (collapsed) state + contentView.setViewLayoutMarginEnd(R.id.notification_standard_view_column, + result.getHeadingExtraMarginEnd()); + } else { + // views in states with a header (big states) + contentView.setInt(R.id.notification_header, "setTopLineExtraMarginEnd", + result.getHeadingExtraMarginEnd()); + contentView.setViewLayoutMarginEnd(R.id.line1, result.getTitleMarginEnd()); } } - private int calculateMarginEnd(boolean largeIconShown, boolean replyIconShown) { - int marginEnd = 0; + private void calculateLargeIconMarginEnd(boolean largeIconShown, + @NonNull TemplateBindResult result) { int contentMargin = mContext.getResources().getDimensionPixelSize( R.dimen.notification_content_margin_end); - int iconSize = mContext.getResources().getDimensionPixelSize( - R.dimen.notification_right_icon_size); - if (replyIconShown) { - // The size of the reply icon - marginEnd += iconSize; + int expanderSize = mContext.getResources().getDimensionPixelSize( + R.dimen.notification_header_expand_icon_size) - contentMargin; + int extraMarginEnd = 0; + if (largeIconShown) { + int iconSize = mContext.getResources().getDimensionPixelSize( + R.dimen.notification_right_icon_size); + extraMarginEnd = iconSize + contentMargin; + } + result.setRightIconState(largeIconShown, extraMarginEnd, expanderSize); + } + private void calculateReplyIconMarginEnd(boolean replyIconShown, + @NonNull TemplateBindResult result) { + int marginEnd = 0; + if (replyIconShown) { + int iconSize = mContext.getResources().getDimensionPixelSize( + R.dimen.notification_reply_icon_size); + int contentMargin = mContext.getResources().getDimensionPixelSize( + R.dimen.notification_content_margin_end); int replyInset = mContext.getResources().getDimensionPixelSize( R.dimen.notification_reply_inset); - // We're subtracting the inset of the reply icon to make sure it's - // aligned nicely on the right, and remove it from the following padding - marginEnd -= replyInset * 2; + marginEnd = iconSize + contentMargin - replyInset * 2; } - if (largeIconShown) { - // adding size of the right icon - marginEnd += iconSize; - - if (replyIconShown) { - // We also add some padding to the reply icon if it's around - marginEnd += contentMargin; - } - } - if (replyIconShown || largeIconShown) { - // The padding to the content - marginEnd += contentMargin; - } - return marginEnd; + result.setReplyIconState(replyIconShown, marginEnd); } /** @@ -5156,7 +5161,10 @@ public class Notification implements Parcelable if (mN.mLargeIcon == null && mN.largeIcon != null) { mN.mLargeIcon = Icon.createWithBitmap(mN.largeIcon); } - boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon; + // Hide the large icon in Heads Up view, because the icon is partly within header, + // which for HUNs will be hidden and cropped. + boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon + && p.mViewType != StandardTemplateParams.VIEW_TYPE_HEADS_UP; if (showLargeIcon) { contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); contentView.setImageViewIcon(R.id.right_icon, mN.mLargeIcon); @@ -5170,7 +5178,7 @@ public class Notification implements Parcelable * @return if the reply icon is visible */ private boolean bindReplyIcon(RemoteViews contentView, StandardTemplateParams p) { - boolean actionVisible = !p.hideReplyIcon; + boolean actionVisible = !p.hideReplyIcon && !p.mHeaderless; Action action = null; if (actionVisible) { action = findReplyAction(); @@ -5375,10 +5383,10 @@ public class Notification implements Parcelable R.dimen.notification_content_margin); } - private RemoteViews applyStandardTemplateWithActions(int layoutId, + private RemoteViews applyStandardTemplateWithActions(int layoutId, int viewType, TemplateBindResult result) { - return applyStandardTemplateWithActions(layoutId, mParams.reset().fillTextsFrom(this), - result); + return applyStandardTemplateWithActions(layoutId, + mParams.reset().viewType(viewType).fillTextsFrom(this), result); } private static List filterOutContextualActions( @@ -5518,7 +5526,8 @@ public class Notification implements Parcelable return styleView; } } - return applyStandardTemplate(getBaseLayoutResource(), null /* result */); + return applyStandardTemplate(getBaseLayoutResource(), + StandardTemplateParams.VIEW_TYPE_NORMAL, null /* result */); } private boolean useExistingRemoteView() { @@ -5533,12 +5542,14 @@ public class Notification implements Parcelable RemoteViews result = null; if (mN.bigContentView != null && useExistingRemoteView()) { return mN.bigContentView; - } else if (mStyle != null) { + } + if (mStyle != null) { result = mStyle.makeBigContentView(); hideLine1Text(result); - } else if (mActions.size() != 0) { + } + if (result == null) { result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), - null /* result */); + StandardTemplateParams.VIEW_TYPE_BIG, null /* result */); } makeHeaderExpanded(result); return result; @@ -5551,7 +5562,9 @@ public class Notification implements Parcelable * @hide */ public RemoteViews makeNotificationHeader() { - return makeNotificationHeader(mParams.reset().fillTextsFrom(this)); + return makeNotificationHeader(mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED) + .fillTextsFrom(this)); } /** @@ -5624,7 +5637,9 @@ public class Notification implements Parcelable // We only want at most a single remote input history to be shown here, otherwise // the content would become squished. - StandardTemplateParams p = mParams.reset().fillTextsFrom(this) + StandardTemplateParams p = mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP) + .fillTextsFrom(this) .setMaxRemoteInputHistory(1); return applyStandardTemplateWithActions(getBigBaseLayoutResource(), p, @@ -5672,7 +5687,9 @@ public class Notification implements Parcelable } mN.extras = publicExtras; RemoteViews view; - StandardTemplateParams params = mParams.reset().fillTextsFrom(this); + StandardTemplateParams params = mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_PUBLIC) + .fillTextsFrom(this); if (isLowPriority) { params.forceDefaultColor(); } @@ -5696,6 +5713,7 @@ public class Notification implements Parcelable */ public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext) { StandardTemplateParams p = mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED) .forceDefaultColor() .fillTextsFrom(this); if (!useRegularSubtext || TextUtils.isEmpty(mParams.summaryText)) { @@ -6563,7 +6581,10 @@ public class Notification implements Parcelable } protected RemoteViews getStandardView(int layoutId) { - StandardTemplateParams p = mBuilder.mParams.reset().fillTextsFrom(mBuilder); + // TODO(jeffdq): set the view type based on the layout resource? + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_UNSPECIFIED) + .fillTextsFrom(mBuilder); return getStandardView(layoutId, p, null); } @@ -6892,7 +6913,8 @@ public class Notification implements Parcelable mBuilder.mN.largeIcon = null; } - StandardTemplateParams p = mBuilder.mParams.reset().fillTextsFrom(mBuilder); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG).fillTextsFrom(mBuilder); RemoteViews contentView = getStandardView(mBuilder.getBigPictureLayoutResource(), p, null /* result */); if (mSummaryTextSet) { @@ -7106,11 +7128,13 @@ public class Notification implements Parcelable * @hide */ public RemoteViews makeBigContentView() { - StandardTemplateParams p = mBuilder.mParams.reset().fillTextsFrom(mBuilder).text(null); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG) + .fillTextsFrom(mBuilder).text(null); TemplateBindResult result = new TemplateBindResult(); RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource(), p, result); - contentView.setInt(R.id.big_text, "setImageEndMargin", result.getIconMarginEnd()); + contentView.setInt(R.id.big_text, "setImageEndMargin", result.getTextMarginEnd()); CharSequence bigTextText = mBuilder.processLegacyText(mBigText); if (TextUtils.isEmpty(bigTextText)) { @@ -7124,7 +7148,7 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.big_text, TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE); contentView.setBoolean(R.id.big_text, "setHasImage", - result.isRightIconContainerVisible()); + result.isReplyIconVisible()); return contentView; } @@ -7708,6 +7732,8 @@ public class Notification implements Parcelable Icon largeIcon = mBuilder.mN.mLargeIcon; TemplateBindResult bindResult = new TemplateBindResult(); StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(isCollapsed ? StandardTemplateParams.VIEW_TYPE_NORMAL + : StandardTemplateParams.VIEW_TYPE_BIG) .hasProgress(false) .title(conversationTitle) .text(null) @@ -7725,7 +7751,7 @@ public class Notification implements Parcelable if (!isConversationLayout) { // also update the end margin if there is an image contentView.setViewLayoutMarginEnd(R.id.notification_messaging, - bindResult.getIconMarginEnd()); + bindResult.getHeadingExtraMarginEnd()); } contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor", mBuilder.isColorized(p) @@ -8213,7 +8239,9 @@ public class Notification implements Parcelable * @hide */ public RemoteViews makeBigContentView() { - StandardTemplateParams p = mBuilder.mParams.reset().fillTextsFrom(mBuilder).text(null); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG) + .fillTextsFrom(mBuilder).text(null); TemplateBindResult result = new TemplateBindResult(); RemoteViews contentView = getStandardView(mBuilder.getInboxLayoutResource(), p, result); @@ -8266,7 +8294,7 @@ public class Notification implements Parcelable mBuilder.setTextViewColorSecondary(contentView, rowIds[i], p); contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0); handleInboxImageMargin(contentView, rowIds[i], first, - result.getIconMarginEnd()); + result.getHeadingFullMarginEnd()); if (first) { onlyViewId = rowIds[i]; } else { @@ -8533,8 +8561,9 @@ public class Notification implements Parcelable } private RemoteViews makeMediaContentView() { - StandardTemplateParams p = mBuilder.mParams.reset().hasProgress(false).fillTextsFrom( - mBuilder); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL) + .hasProgress(false).fillTextsFrom(mBuilder); RemoteViews view = mBuilder.applyStandardTemplate( R.layout.notification_template_material_media, p, null /* result */); @@ -8580,8 +8609,9 @@ public class Notification implements Parcelable if (!mBuilder.mN.hasLargeIcon() && actionCount <= actionsInCompact) { return null; } - StandardTemplateParams p = mBuilder.mParams.reset().hasProgress(false).fillTextsFrom( - mBuilder); + StandardTemplateParams p = mBuilder.mParams.reset() + .viewType(StandardTemplateParams.VIEW_TYPE_BIG) + .hasProgress(false).fillTextsFrom(mBuilder); RemoteViews big = mBuilder.applyStandardTemplate( R.layout.notification_template_material_big_media, p , null /* result */); @@ -8680,16 +8710,18 @@ public class Notification implements Parcelable } TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource(), result); - buildIntoRemoteViewContent(remoteViews, headsUpContentView, result); + mBuilder.getBigBaseLayoutResource(), + StandardTemplateParams.VIEW_TYPE_HEADS_UP, result); + buildIntoRemoteViewContent(remoteViews, headsUpContentView, result, false); return remoteViews; } private RemoteViews makeStandardTemplateWithCustomContent(RemoteViews customContent) { TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplate( - mBuilder.getBaseLayoutResource(), result); - buildIntoRemoteViewContent(remoteViews, customContent, result); + mBuilder.getBaseLayoutResource(), + StandardTemplateParams.VIEW_TYPE_NORMAL, result); + buildIntoRemoteViewContent(remoteViews, customContent, result, true); return remoteViews; } @@ -8697,18 +8729,16 @@ public class Notification implements Parcelable RemoteViews bigContentView = mBuilder.mN.bigContentView == null ? mBuilder.mN.contentView : mBuilder.mN.bigContentView; - if (mBuilder.mActions.size() == 0) { - return makeStandardTemplateWithCustomContent(bigContentView); - } TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource(), result); - buildIntoRemoteViewContent(remoteViews, bigContentView, result); + mBuilder.getBigBaseLayoutResource(), + StandardTemplateParams.VIEW_TYPE_BIG, result); + buildIntoRemoteViewContent(remoteViews, bigContentView, result, false); return remoteViews; } private void buildIntoRemoteViewContent(RemoteViews remoteViews, - RemoteViews customContent, TemplateBindResult result) { + RemoteViews customContent, TemplateBindResult result, boolean headerless) { int childIndex = -1; if (customContent != null) { // Need to clone customContent before adding, because otherwise it can no longer be @@ -8722,11 +8752,14 @@ public class Notification implements Parcelable remoteViews.setIntTag(R.id.notification_main_column, com.android.internal.R.id.notification_custom_view_index_tag, childIndex); - // also update the end margin if there is an image - Resources resources = mBuilder.mContext.getResources(); - int endMargin = resources.getDimensionPixelSize( - R.dimen.notification_content_margin_end) + result.getIconMarginEnd(); - remoteViews.setViewLayoutMarginEnd(R.id.notification_main_column, endMargin); + if (!headerless) { + // also update the end margin to account for the large icon or expander + Resources resources = mBuilder.mContext.getResources(); + int endMargin = resources.getDimensionPixelSize( + R.dimen.notification_content_margin_end) + result.getTitleMarginEnd(); + remoteViews.setViewLayoutMarginEnd(R.id.notification_main_column, + endMargin); + } } /** @@ -10962,35 +10995,78 @@ public class Notification implements Parcelable * A result object where information about the template that was created is saved. */ private static class TemplateBindResult { - int mIconMarginEnd; - boolean mRightIconContainerVisible; + boolean mRightIconVisible; + int mRightIconMarginEnd; + int mExpanderSize; + boolean mReplyIconVisible; + int mReplyIconMarginEnd; /** - * Get the margin end that needs to be added to any fields that may overlap - * with the right actions. + * @return the margin end that needs to be added to the heading so that it won't overlap + * with the large icon. This value includes the space required to accommodate the large + * icon, but should be added to the space needed to accommodate the expander. This does + * not include the 16dp content margin that all notification views must have. */ - public int getIconMarginEnd() { - return mIconMarginEnd; + public int getHeadingExtraMarginEnd() { + return mRightIconMarginEnd; + } + + /** + * @return the margin end that needs to be added to the heading so that it won't overlap + * with the large icon. This value includes the space required to accommodate the large + * icon as well as the expander. This does not include the 16dp content margin that all + * notification views must have. + */ + public int getHeadingFullMarginEnd() { + return mRightIconMarginEnd + mExpanderSize; + } + + /** + * @return the margin end that needs to be added to the title text of the big state + * so that it won't overlap with either the large icon or the reply action. + */ + public int getTitleMarginEnd() { + return mRightIconVisible ? getHeadingFullMarginEnd() : mReplyIconMarginEnd; + } + + /** + * @return the margin end that needs to be added to the topmost content of the big state + * so that it won't overlap with the reply action. + */ + public int getTextMarginEnd() { + return mReplyIconMarginEnd; } /** * Is the icon container visible on the right size because of the reply button or the * right icon. */ - public boolean isRightIconContainerVisible() { - return mRightIconContainerVisible; + public boolean isReplyIconVisible() { + return mReplyIconVisible; } - public void setIconMarginEnd(int iconMarginEnd) { - this.mIconMarginEnd = iconMarginEnd; + public void setReplyIconState(boolean visible, int marginEnd) { + mReplyIconVisible = visible; + mReplyIconMarginEnd = marginEnd; } - public void setRightIconContainerVisible(boolean iconContainerVisible) { - mRightIconContainerVisible = iconContainerVisible; + public void setRightIconState(boolean visible, int marginEnd, int expanderSize) { + mRightIconVisible = visible; + mRightIconMarginEnd = marginEnd; + mExpanderSize = expanderSize; } } private static class StandardTemplateParams { + public static int VIEW_TYPE_UNSPECIFIED = 0; + public static int VIEW_TYPE_NORMAL = 1; + public static int VIEW_TYPE_BIG = 2; + public static int VIEW_TYPE_HEADS_UP = 3; + public static int VIEW_TYPE_MINIMIZED = 4; + public static int VIEW_TYPE_PUBLIC = 5; + + int mViewType = VIEW_TYPE_UNSPECIFIED; + boolean mHeaderless; boolean hasProgress = true; CharSequence title; CharSequence text; @@ -11003,6 +11079,8 @@ public class Notification implements Parcelable boolean forceDefaultColor = false; final StandardTemplateParams reset() { + mViewType = VIEW_TYPE_UNSPECIFIED; + mHeaderless = false; hasProgress = true; title = null; text = null; @@ -11014,6 +11092,16 @@ public class Notification implements Parcelable return this; } + final StandardTemplateParams viewType(int viewType) { + mViewType = viewType; + return this; + } + + public StandardTemplateParams headerless(boolean headerless) { + mHeaderless = headerless; + return this; + } + final StandardTemplateParams hasProgress(boolean hasProgress) { this.hasProgress = hasProgress; return this; diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 2bd3d46d389a6..f7fbb1ce0ab98 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -27,6 +27,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; +import android.widget.FrameLayout; import android.widget.RemoteViews; import com.android.internal.R; @@ -41,15 +42,14 @@ import java.util.ArrayList; * @hide */ @RemoteViews.RemoteView -public class NotificationHeaderView extends ViewGroup { - private final int mChildMinWidth; +public class NotificationHeaderView extends FrameLayout { private final int mContentEndMargin; + private final int mHeadingEndMargin; private OnClickListener mExpandClickListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private NotificationTopLineView mTopLineView; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; - private int mHeaderTextMarginEnd; private Drawable mBackground; private boolean mEntireHeaderClickable; private boolean mExpandOnlyOnButton; @@ -82,8 +82,8 @@ public class NotificationHeaderView extends ViewGroup { int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); Resources res = getResources(); - mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width); mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end); + mHeadingEndMargin = res.getDimensionPixelSize(R.dimen.notification_heading_margin_end); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); } @@ -96,108 +96,6 @@ public class NotificationHeaderView extends ViewGroup { setClipToPadding(false); } - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int givenWidth = MeasureSpec.getSize(widthMeasureSpec); - final int givenHeight = MeasureSpec.getSize(heightMeasureSpec); - int wrapContentWidthSpec = MeasureSpec.makeMeasureSpec(givenWidth, - MeasureSpec.AT_MOST); - int wrapContentHeightSpec = MeasureSpec.makeMeasureSpec(givenHeight, - MeasureSpec.AT_MOST); - int totalWidth = getPaddingStart(); - int iconWidth = getPaddingEnd(); - for (int i = 0; i < getChildCount(); i++) { - final View child = getChildAt(i); - if (child.getVisibility() == GONE) { - // We'll give it the rest of the space in the end - continue; - } - final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams(); - int childWidthSpec = getChildMeasureSpec(wrapContentWidthSpec, - lp.leftMargin + lp.rightMargin, lp.width); - int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec, - lp.topMargin + lp.bottomMargin, lp.height); - child.measure(childWidthSpec, childHeightSpec); - // Icons that should go at the end - if (child == mExpandButton) { - iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); - } else { - totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); - } - } - - // Ensure that there is at least enough space for the icons - int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth); - if (totalWidth > givenWidth - endMargin) { - int overFlow = totalWidth - givenWidth + endMargin; - // We are overflowing; shrink the top line - shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mTopLineView, - mChildMinWidth); - } - setMeasuredDimension(givenWidth, givenHeight); - } - - private int shrinkViewForOverflow(int heightSpec, int overFlow, View targetView, - int minimumWidth) { - final int oldWidth = targetView.getMeasuredWidth(); - if (overFlow > 0 && targetView.getVisibility() != GONE && oldWidth > minimumWidth) { - // we're still too big - int newSize = Math.max(minimumWidth, oldWidth - overFlow); - int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST); - targetView.measure(childWidthSpec, heightSpec); - overFlow -= oldWidth - newSize; - } - return overFlow; - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - int left = getPaddingStart(); - int end = getMeasuredWidth(); - int childCount = getChildCount(); - int ownHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); - for (int i = 0; i < childCount; i++) { - View child = getChildAt(i); - if (child.getVisibility() == GONE) { - continue; - } - int childHeight = child.getMeasuredHeight(); - MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams(); - int layoutLeft; - int layoutRight; - int top = (int) (getPaddingTop() + (ownHeight - childHeight) / 2.0f); - int bottom = top + childHeight; - // Icons that should go at the end - if (child == mExpandButton) { - if (end == getMeasuredWidth()) { - layoutRight = end - mContentEndMargin; - } else { - layoutRight = end - params.getMarginEnd(); - } - layoutLeft = layoutRight - child.getMeasuredWidth(); - end = layoutLeft - params.getMarginStart(); - } else { - left += params.getMarginStart(); - int right = left + child.getMeasuredWidth(); - layoutLeft = left; - layoutRight = right; - left = right + params.getMarginEnd(); - } - if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { - int ltrLeft = layoutLeft; - layoutLeft = getWidth() - layoutRight; - layoutRight = getWidth() - ltrLeft; - } - child.layout(layoutLeft, top, layoutRight, bottom); - } - updateTouchListener(); - } - - @Override - public LayoutParams generateLayoutParams(AttributeSet attrs) { - return new MarginLayoutParams(getContext(), attrs); - } - /** * Set a {@link Drawable} to be displayed as a background on the header. */ @@ -252,23 +150,34 @@ public class NotificationHeaderView extends ViewGroup { } /** - * Sets the margin end for the text portion of the header, excluding right-aligned elements - * @param headerTextMarginEnd margin size + * Sets the extra margin at the end of the top line of left-aligned text + icons. + * This value will have the margin required to accommodate the expand button added to it. + * + * @param extraMarginEnd extra margin */ @RemotableViewMethod - public void setHeaderTextMarginEnd(int headerTextMarginEnd) { - if (mHeaderTextMarginEnd != headerTextMarginEnd) { - mHeaderTextMarginEnd = headerTextMarginEnd; - requestLayout(); - } + public void setTopLineExtraMarginEnd(int extraMarginEnd) { + mTopLineView.setHeaderTextMarginEnd(extraMarginEnd + mHeadingEndMargin); } /** - * Get the current margin end value for the header text - * @return margin size + * Get the current margin end value for the header text. + * Add this to {@link #getTopLineBaseMarginEnd()} to get the total margin of the top line. + * + * @return extra margin */ - public int getHeaderTextMarginEnd() { - return mHeaderTextMarginEnd; + public int getTopLineExtraMarginEnd() { + return mTopLineView.getHeaderTextMarginEnd() - mHeadingEndMargin; + } + + /** + * Get the base margin at the end of the top line view. + * Add this to {@link #getTopLineExtraMarginEnd()} to get the total margin of the top line. + * + * @return base margin + */ + public int getTopLineBaseMarginEnd() { + return mHeadingEndMargin; } /** diff --git a/core/java/android/view/NotificationTopLineView.java b/core/java/android/view/NotificationTopLineView.java index 24748222b3af7..f6073ca2f0b2e 100644 --- a/core/java/android/view/NotificationTopLineView.java +++ b/core/java/android/view/NotificationTopLineView.java @@ -40,7 +40,8 @@ public class NotificationTopLineView extends ViewGroup { private final int mGravityY; private final int mChildMinWidth; private final int mContentEndMargin; - private View mAppName; + @Nullable private View mAppName; + @Nullable private View mTitle; private View mHeaderText; private View mSecondaryHeaderText; private OnClickListener mFeedbackListener; @@ -92,6 +93,7 @@ public class NotificationTopLineView extends ViewGroup { protected void onFinishInflate() { super.onFinishInflate(); mAppName = findViewById(R.id.app_name_text); + mTitle = findViewById(R.id.title); mHeaderText = findViewById(R.id.header_text); mSecondaryHeaderText = findViewById(R.id.header_text_secondary); mProfileBadge = findViewById(R.id.profile_badge); @@ -144,9 +146,17 @@ public class NotificationTopLineView extends ViewGroup { int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth); if (totalWidth > givenWidth - endMargin) { int overFlow = totalWidth - givenWidth + endMargin; - // We are overflowing, lets shrink the app name first - overFlow = shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mAppName, - mChildMinWidth); + if (mAppName != null) { + // We are overflowing, lets shrink the app name first + overFlow = shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mAppName, + mChildMinWidth); + } + + if (mTitle != null) { + // still overflowing, we shrink the title text + overFlow = shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mTitle, + mChildMinWidth); + } // still overflowing, we shrink the header text overFlow = shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mHeaderText, 0); @@ -298,6 +308,13 @@ public class NotificationTopLineView extends ViewGroup { return mHeaderTextMarginEnd; } + /** + * Set padding at the start of the view. + */ + public void setPaddingStart(int paddingStart) { + setPaddingRelative(paddingStart, getPaddingTop(), getPaddingEnd(), getPaddingBottom()); + } + private class HeaderTouchListener implements OnTouchListener { private Rect mFeedbackRect; diff --git a/core/java/com/android/internal/widget/MediaNotificationView.java b/core/java/com/android/internal/widget/MediaNotificationView.java index 9bb45012b61a3..f42d5da30b19f 100644 --- a/core/java/com/android/internal/widget/MediaNotificationView.java +++ b/core/java/com/android/internal/widget/MediaNotificationView.java @@ -98,12 +98,14 @@ public class MediaNotificationView extends FrameLayout { mMainColumn.setLayoutParams(params); reMeasure = true; } + // TODO(b/172652345): validate all this logic (especially positioning of expand button) // margin for the entire header line int headerMarginEnd = imageEndMargin; // margin for the header text (not including the expand button and other icons) - int headerTextMarginEnd = size + imageEndMargin; - if (headerTextMarginEnd != mHeader.getHeaderTextMarginEnd()) { - mHeader.setHeaderTextMarginEnd(headerTextMarginEnd); + int headerExtraMarginEnd = Math.max(0, + size + imageEndMargin - mHeader.getTopLineBaseMarginEnd()); + if (headerExtraMarginEnd != mHeader.getTopLineExtraMarginEnd()) { + mHeader.setTopLineExtraMarginEnd(headerExtraMarginEnd); reMeasure = true; } params = (MarginLayoutParams) mHeader.getLayoutParams(); diff --git a/core/res/res/drawable/notification_icon_circle.xml b/core/res/res/drawable/notification_icon_circle.xml new file mode 100644 index 0000000000000..b10a52d41b6a9 --- /dev/null +++ b/core/res/res/drawable/notification_icon_circle.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/core/res/res/drawable/notification_large_icon_outline.xml b/core/res/res/drawable/notification_large_icon_outline.xml new file mode 100644 index 0000000000000..bac03d2fe1c49 --- /dev/null +++ b/core/res/res/drawable/notification_large_icon_outline.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/core/res/res/layout/notification_material_action_list.xml b/core/res/res/layout/notification_material_action_list.xml index bf66e69b52d37..552a1bd6aa2ee 100644 --- a/core/res/res/layout/notification_material_action_list.xml +++ b/core/res/res/layout/notification_material_action_list.xml @@ -1,5 +1,4 @@ - - - + + + android:gravity="end" + android:orientation="horizontal" + android:paddingEnd="@dimen/bubble_gone_padding_end" + android:background="@color/notification_action_list_background_color" + > - + + - - - + - - + diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml index d11875e0f8903..a26473ad60102 100644 --- a/core/res/res/layout/notification_template_header.xml +++ b/core/res/res/layout/notification_template_header.xml @@ -1,5 +1,4 @@ - - - + - - + android:gravity="center_vertical" + android:orientation="horizontal" + 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 34c7fa734f210..e5de55ddd07b4 100644 --- a/core/res/res/layout/notification_template_material_base.xml +++ b/core/res/res/layout/notification_template_material_base.xml @@ -1,5 +1,4 @@ - - + + + + + + + + + - - + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/notification_heading_margin_end" + android:layout_marginStart="@dimen/notification_content_margin_start" + android:orientation="vertical" + > + + + + + + + + + + + + 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 21068908ffe8d..c9592a793cdf4 100644 --- a/core/res/res/layout/notification_template_material_big_base.xml +++ b/core/res/res/layout/notification_template_material_big_base.xml @@ -1,5 +1,4 @@ - - - - + + + android:layout_gravity="start" + /> + + + + + + style="@style/NotificationMediaActionContainer" + > + + /> + + /> + + /> + + /> + + /> - + /> diff --git a/core/res/res/layout/notification_template_material_big_picture.xml b/core/res/res/layout/notification_template_material_big_picture.xml index 7a1cc1eff167d..dd975eb27ac9b 100644 --- a/core/res/res/layout/notification_template_material_big_picture.xml +++ b/core/res/res/layout/notification_template_material_big_picture.xml @@ -1,5 +1,4 @@ - - - - + + + + + + + android:id="@+id/notification_action_list_margin_target" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="top" + android:layout_marginTop="@dimen/notification_content_margin_top" + android:clipToPadding="false" + android:orientation="vertical" + > + - - - - - + + + + - - + + + + + + + + android:layout_marginTop="@dimen/notification_content_margin" + /> + 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 d5ea96f6bc169..117991bc6bebc 100644 --- a/core/res/res/layout/notification_template_material_big_text.xml +++ b/core/res/res/layout/notification_template_material_big_text.xml @@ -1,5 +1,4 @@ - - - - + + + android:id="@+id/notification_action_list_margin_target" + android:layout_width="match_parent" + 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:clipToPadding="false" + android:orientation="vertical" + > + - - + + - - + + + + + + diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index 48cfa073d08bb..5e3d6471fdf70 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -359,8 +359,8 @@ /> + diff --git a/core/res/res/layout/notification_template_material_messaging.xml b/core/res/res/layout/notification_template_material_messaging.xml index 10c750972961b..f37bda5cc5f67 100644 --- a/core/res/res/layout/notification_template_material_messaging.xml +++ b/core/res/res/layout/notification_template_material_messaging.xml @@ -57,5 +57,6 @@ android:layout_marginEnd="@dimen/notification_content_margin_end" /> - + + diff --git a/core/res/res/layout/notification_template_reply_icon.xml b/core/res/res/layout/notification_template_reply_icon.xml new file mode 100644 index 0000000000000..695f7c8b5c6fc --- /dev/null +++ b/core/res/res/layout/notification_template_reply_icon.xml @@ -0,0 +1,27 @@ + + + + diff --git a/core/res/res/layout/notification_template_right_icon.xml b/core/res/res/layout/notification_template_right_icon.xml index ee416ad36b8a9..d22d4c20dad29 100644 --- a/core/res/res/layout/notification_template_right_icon.xml +++ b/core/res/res/layout/notification_template_right_icon.xml @@ -1,5 +1,4 @@ - - - - - - - - + diff --git a/core/res/res/layout/notification_template_text.xml b/core/res/res/layout/notification_template_text.xml index 01b14ae0592dc..b72f6bf02c88c 100644 --- a/core/res/res/layout/notification_template_text.xml +++ b/core/res/res/layout/notification_template_text.xml @@ -1,5 +1,4 @@ - - - - - - - + + + + android:visibility="gone" + /> + + android:singleLine="true" + /> + + android:visibility="gone" + /> + + android:singleLine="true" + /> + + android:visibility="gone" + /> + + android:visibility="gone" + /> + + + /> + + /> + - + diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 544be54eb7859..a5e5fbf763f71 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -207,12 +207,15 @@ 16dp - - 16dp + + 52dp - + 16dp + + 48dp + 8dp @@ -228,6 +231,13 @@ 48dp + + 36dp + + + 48dp + 1dp @@ -243,8 +253,11 @@ 8dp - - 50dp + + 48dp + + + 56dp 49.5dp @@ -258,12 +271,18 @@ 0dp - - 3dp - 18dp + + 24dp + + + 4dp + + + 16dp + 18dp @@ -276,12 +295,21 @@ 4dp - - -2px + + 48dp 1dp + + 18dp + + + 20sp + + + 56dp + 106dp @@ -310,7 +338,7 @@ 20dp - @dimen/notification_header_height + @dimen/notification_header_big_height 8dp @@ -679,7 +707,11 @@ 280dp - 36dp + 52dp + + 16dp + + 36dp 0.5 @@ -702,6 +734,8 @@ @dimen/notification_right_icon_size 52dp + + 28dp 80dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index fba431c66f531..065aef50f2970 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -218,6 +218,7 @@ + @@ -2871,14 +2872,13 @@ + - - @@ -3379,6 +3379,7 @@ + @@ -3399,8 +3400,6 @@ - - @@ -3935,8 +3934,9 @@ + + - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java index 25c8e7feb9b23..216b83f2b4d52 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java @@ -33,6 +33,7 @@ import com.android.systemui.statusbar.notification.row.NotificationContentView; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Objects; /** * A Util to manage {@link android.view.NotificationHeaderView} objects and their redundancies. @@ -324,13 +325,15 @@ public class NotificationHeaderUtil { @Override public boolean compare(View parent, View child, Object parentData, Object childData) { TextView parentView = (TextView) parent; + CharSequence parentText = parentView == null ? "" : parentView.getText(); TextView childView = (TextView) child; - return parentView.getText().equals(childView.getText()); + CharSequence childText = childView == null ? "" : childView.getText(); + return Objects.equals(parentText, childText); } @Override public boolean isEmpty(View view) { - return TextUtils.isEmpty(((TextView) view).getText()); + return view == null || TextUtils.isEmpty(((TextView) view).getText()); } } @@ -369,7 +372,9 @@ public class NotificationHeaderUtil { @Override public void apply(View parent, View view, boolean apply, boolean reset) { - view.setVisibility(apply ? View.GONE : View.VISIBLE); + if (view != null) { + view.setVisibility(apply ? View.GONE : View.VISIBLE); + } } } 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 79c300782ad9e..328774550f243 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 @@ -318,30 +318,13 @@ public class NotificationContentView extends FrameLayout { // We need to update the expanded and the collapsed header to have exactly the same with to // have the expand buttons laid out at the same location. NotificationHeaderView contractedHeader = mContractedWrapper.getNotificationHeader(); - if (contractedHeader != null) { - if (mExpandedChild != null - && mExpandedWrapper.getNotificationHeader() != null) { - NotificationHeaderView expandedHeader = mExpandedWrapper.getNotificationHeader(); - - int headerTextMargin = expandedHeader.getHeaderTextMarginEnd(); - if (headerTextMargin != contractedHeader.getHeaderTextMarginEnd()) { - contractedHeader.setHeaderTextMarginEnd(headerTextMargin); - return true; - } - } else { - int paddingEnd = mNotificationContentMarginEnd; - if (contractedHeader.getPaddingEnd() != paddingEnd) { - contractedHeader.setPadding( - contractedHeader.isLayoutRtl() - ? paddingEnd - : contractedHeader.getPaddingLeft(), - contractedHeader.getPaddingTop(), - contractedHeader.isLayoutRtl() - ? contractedHeader.getPaddingLeft() - : paddingEnd, - contractedHeader.getPaddingBottom()); - return true; - } + if (contractedHeader != null && mExpandedWrapper != null + && mExpandedWrapper.getNotificationHeader() != null) { + NotificationHeaderView expandedHeader = mExpandedWrapper.getNotificationHeader(); + int headerTextMargin = expandedHeader.getTopLineExtraMarginEnd(); + if (headerTextMargin != contractedHeader.getTopLineExtraMarginEnd()) { + contractedHeader.setTopLineExtraMarginEnd(headerTextMargin); + return true; } } return false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index 5aeacaba6f644..bde3d5a1e1746 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -28,7 +28,6 @@ import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -63,8 +62,8 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { private TextView mAppNameText; private ImageView mWorkProfileImage; private View mAudiblyAlertedIcon; - private FrameLayout mIconContainer; private View mFeedbackIcon; + private View mRightIcon; private boolean mIsLowPriority; private boolean mTransformLowPriorityTitle; @@ -103,11 +102,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { } protected void resolveHeaderViews() { - mIconContainer = mView.findViewById(com.android.internal.R.id.header_icon_container); mIcon = mView.findViewById(com.android.internal.R.id.icon); mHeaderText = mView.findViewById(com.android.internal.R.id.header_text); mAppNameText = mView.findViewById(com.android.internal.R.id.app_name_text); mExpandButton = mView.findViewById(com.android.internal.R.id.expand_button); + mRightIcon = mView.findViewById(com.android.internal.R.id.right_icon); mWorkProfileImage = mView.findViewById(com.android.internal.R.id.profile_badge); mNotificationHeader = mView.findViewById(com.android.internal.R.id.notification_header); mNotificationTopLine = mView.findViewById(com.android.internal.R.id.notification_top_line); @@ -145,6 +144,9 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { updateCropToPaddingForImageViews(); Notification notification = row.getEntry().getSbn().getNotification(); mIcon.setTag(ImageTransformState.ICON_TAG, notification.getSmallIcon()); + if (mRightIcon != null) { + mRightIcon.setClipToOutline(true); + } // We need to reset all views that are no longer transforming in case a view was previously // transformed, but now we decided to transform its container instead. @@ -165,19 +167,16 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { MarginLayoutParams layoutParams = (MarginLayoutParams) mAppNameText.getLayoutParams(); layoutParams.setMarginStart(0); } - if (mIconContainer != null) { - MarginLayoutParams layoutParams = (MarginLayoutParams) mIconContainer.getLayoutParams(); - layoutParams.width = - mIconContainer.getContext().getResources().getDimensionPixelSize( - com.android.internal.R.dimen.conversation_content_start); - final int marginStart = - mIconContainer.getContext().getResources().getDimensionPixelSize( - com.android.internal.R.dimen.notification_content_margin_start); - layoutParams.setMarginStart(marginStart * -1); + if (mNotificationTopLine != null) { + int paddingStart = mNotificationTopLine.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.conversation_content_start); + mNotificationTopLine.setPaddingStart(paddingStart); } if (mIcon != null) { MarginLayoutParams layoutParams = (MarginLayoutParams) mIcon.getLayoutParams(); - layoutParams.setMarginEnd(0); + int marginStart = mIcon.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.conversation_icon_circle_start); + layoutParams.setMarginStart(marginStart); } } @@ -189,20 +188,20 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { com.android.internal.R.style.TextAppearance_DeviceDefault_Notification_Info); mAppNameText.setTextAppearance(textAppearance); MarginLayoutParams layoutParams = (MarginLayoutParams) mAppNameText.getLayoutParams(); - final int marginStart = mAppNameText.getContext().getResources().getDimensionPixelSize( + final int marginStart = mAppNameText.getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_app_name_margin_start); layoutParams.setMarginStart(marginStart); } - if (mIconContainer != null) { - MarginLayoutParams layoutParams = (MarginLayoutParams) mIconContainer.getLayoutParams(); - layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; - layoutParams.setMarginStart(0); + if (mNotificationTopLine != null) { + int paddingStart = mNotificationTopLine.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.notification_content_margin_start); + mNotificationTopLine.setPaddingStart(paddingStart); } if (mIcon != null) { MarginLayoutParams layoutParams = (MarginLayoutParams) mIcon.getLayoutParams(); - final int marginEnd = mIcon.getContext().getResources().getDimensionPixelSize( - com.android.internal.R.dimen.notification_header_icon_margin_end); - layoutParams.setMarginEnd(marginEnd); + int marginStart = mIcon.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.notification_icon_circle_start); + layoutParams.setMarginStart(marginStart); } } diff --git a/packages/SystemUI/tools/lint/baseline.xml b/packages/SystemUI/tools/lint/baseline.xml index 096a63901b9d2..3e494032b8e25 100644 --- a/packages/SystemUI/tools/lint/baseline.xml +++ b/packages/SystemUI/tools/lint/baseline.xml @@ -2907,17 +2907,6 @@ column="12"/> - - - - Date: Thu, 5 Nov 2020 17:03:33 -0500 Subject: [PATCH 03/14] Remove the reply action entirely. Bug: 163626038 Test: manual Change-Id: I28992441300ffdecc58900730ff9d858d6c0a009 --- config/hiddenapi-max-target-o.txt | 1 - core/java/android/app/Notification.java | 105 +----------------- .../res/drawable/ic_reply_notification.xml | 32 ------ ...otification_template_material_big_base.xml | 1 - ...fication_template_material_big_picture.xml | 2 - ...otification_template_material_big_text.xml | 1 - .../notification_template_material_inbox.xml | 1 - ...tification_template_material_messaging.xml | 1 - .../notification_template_reply_icon.xml | 27 ----- core/res/res/values/dimens.xml | 5 - core/res/res/values/symbols.xml | 3 - .../notification/TransformState.java | 3 - .../NotificationTemplateViewWrapper.java | 39 ------- 13 files changed, 6 insertions(+), 215 deletions(-) delete mode 100644 core/res/res/drawable/ic_reply_notification.xml delete mode 100644 core/res/res/layout/notification_template_reply_icon.xml diff --git a/config/hiddenapi-max-target-o.txt b/config/hiddenapi-max-target-o.txt index eefe493efbc49..592b4aedf9521 100644 --- a/config/hiddenapi-max-target-o.txt +++ b/config/hiddenapi-max-target-o.txt @@ -92442,7 +92442,6 @@ Lcom/android/internal/R$id;->remote_input_send:I Lcom/android/internal/R$id;->replaceText:I Lcom/android/internal/R$id;->replace_app_icon:I Lcom/android/internal/R$id;->replace_message:I -Lcom/android/internal/R$id;->reply_icon_action:I Lcom/android/internal/R$id;->resolver_list:I Lcom/android/internal/R$id;->rew:I Lcom/android/internal/R$id;->rightSpacer:I diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 113ec4df3c9f4..1e673cf0305cb 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4884,7 +4884,7 @@ public class Notification implements Parcelable final Bundle ex = mN.extras; updateBackgroundColor(contentView, p); bindNotificationHeader(contentView, p); - bindLargeIconAndReply(contentView, p, result); + bindLargeIconAndApplyMargin(contentView, p, result); boolean showProgress = handleProgressBar(contentView, ex, p); if (p.title != null && p.title.length() > 0) { contentView.setViewVisibility(R.id.title, View.VISIBLE); @@ -5101,16 +5101,14 @@ public class Notification implements Parcelable } } - private void bindLargeIconAndReply(RemoteViews contentView, + private void bindLargeIconAndApplyMargin(RemoteViews contentView, @NonNull StandardTemplateParams p, @Nullable TemplateBindResult result) { if (result == null) { result = new TemplateBindResult(); } boolean largeIconShown = bindLargeIcon(contentView, p); - boolean replyIconShown = bindReplyIcon(contentView, p); calculateLargeIconMarginEnd(largeIconShown, result); - calculateReplyIconMarginEnd(replyIconShown, result); if (p.mHeaderless) { // views in the headerless (collapsed) state contentView.setViewLayoutMarginEnd(R.id.notification_standard_view_column, @@ -5138,21 +5136,6 @@ public class Notification implements Parcelable result.setRightIconState(largeIconShown, extraMarginEnd, expanderSize); } - private void calculateReplyIconMarginEnd(boolean replyIconShown, - @NonNull TemplateBindResult result) { - int marginEnd = 0; - if (replyIconShown) { - int iconSize = mContext.getResources().getDimensionPixelSize( - R.dimen.notification_reply_icon_size); - int contentMargin = mContext.getResources().getDimensionPixelSize( - R.dimen.notification_content_margin_end); - int replyInset = mContext.getResources().getDimensionPixelSize( - R.dimen.notification_reply_inset); - marginEnd = iconSize + contentMargin - replyInset * 2; - } - result.setReplyIconState(replyIconShown, marginEnd); - } - /** * Bind the large icon. * @return if the largeIcon is visible @@ -5173,48 +5156,6 @@ public class Notification implements Parcelable return showLargeIcon; } - /** - * Bind the reply icon. - * @return if the reply icon is visible - */ - private boolean bindReplyIcon(RemoteViews contentView, StandardTemplateParams p) { - boolean actionVisible = !p.hideReplyIcon && !p.mHeaderless; - Action action = null; - if (actionVisible) { - action = findReplyAction(); - actionVisible = action != null; - } - if (actionVisible) { - contentView.setViewVisibility(R.id.reply_icon_action, View.VISIBLE); - contentView.setDrawableTint(R.id.reply_icon_action, - false /* targetBackground */, - getNeutralColor(p), - PorterDuff.Mode.SRC_ATOP); - contentView.setOnClickPendingIntent(R.id.reply_icon_action, action.actionIntent); - contentView.setRemoteInputs(R.id.reply_icon_action, action.mRemoteInputs); - } else { - contentView.setRemoteInputs(R.id.reply_icon_action, null); - } - contentView.setViewVisibility(R.id.reply_icon_action, - actionVisible ? View.VISIBLE : View.GONE); - return actionVisible; - } - - private Action findReplyAction() { - ArrayList actions = mActions; - if (mOriginalActions != null) { - actions = mOriginalActions; - } - int numActions = actions.size(); - for (int i = 0; i < numActions; i++) { - Action action = actions.get(i); - if (hasValidRemoteInput(action)) { - return action; - } - } - return null; - } - private void bindNotificationHeader(RemoteViews contentView, StandardTemplateParams p) { bindSmallIcon(contentView, p); bindHeaderAppName(contentView, p); @@ -7131,10 +7072,7 @@ public class Notification implements Parcelable StandardTemplateParams p = mBuilder.mParams.reset() .viewType(StandardTemplateParams.VIEW_TYPE_BIG) .fillTextsFrom(mBuilder).text(null); - TemplateBindResult result = new TemplateBindResult(); - RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource(), p, - result); - contentView.setInt(R.id.big_text, "setImageEndMargin", result.getTextMarginEnd()); + RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource(), p, null); CharSequence bigTextText = mBuilder.processLegacyText(mBigText); if (TextUtils.isEmpty(bigTextText)) { @@ -7147,8 +7085,6 @@ public class Notification implements Parcelable mBuilder.setTextViewColorSecondary(contentView, R.id.big_text, p); contentView.setViewVisibility(R.id.big_text, TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE); - contentView.setBoolean(R.id.big_text, "setHasImage", - result.isReplyIconVisible()); return contentView; } @@ -7738,7 +7674,6 @@ public class Notification implements Parcelable .title(conversationTitle) .text(null) .hideLargeIcon(hideRightIcons || isOneToOne) - .hideReplyIcon(hideRightIcons) .headerTextSecondary(conversationTitle); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions( isConversationLayout @@ -10998,8 +10933,6 @@ public class Notification implements Parcelable boolean mRightIconVisible; int mRightIconMarginEnd; int mExpanderSize; - boolean mReplyIconVisible; - int mReplyIconMarginEnd; /** * @return the margin end that needs to be added to the heading so that it won't overlap @@ -11023,31 +10956,11 @@ public class Notification implements Parcelable /** * @return the margin end that needs to be added to the title text of the big state - * so that it won't overlap with either the large icon or the reply action. + * so that it won't overlap with the large icon, but assuming the text can run under + * the expander when that icon is not visible. */ public int getTitleMarginEnd() { - return mRightIconVisible ? getHeadingFullMarginEnd() : mReplyIconMarginEnd; - } - - /** - * @return the margin end that needs to be added to the topmost content of the big state - * so that it won't overlap with the reply action. - */ - public int getTextMarginEnd() { - return mReplyIconMarginEnd; - } - - /** - * Is the icon container visible on the right size because of the reply button or the - * right icon. - */ - public boolean isReplyIconVisible() { - return mReplyIconVisible; - } - - public void setReplyIconState(boolean visible, int marginEnd) { - mReplyIconVisible = visible; - mReplyIconMarginEnd = marginEnd; + return mRightIconVisible ? getHeadingFullMarginEnd() : 0; } public void setRightIconState(boolean visible, int marginEnd, int expanderSize) { @@ -11074,7 +10987,6 @@ public class Notification implements Parcelable CharSequence summaryText; int maxRemoteInputHistory = Style.MAX_REMOTE_INPUT_HISTORY_LINES; boolean hideLargeIcon; - boolean hideReplyIcon; boolean allowColorization = true; boolean forceDefaultColor = false; @@ -11132,11 +11044,6 @@ public class Notification implements Parcelable return this; } - final StandardTemplateParams hideReplyIcon(boolean hideReplyIcon) { - this.hideReplyIcon = hideReplyIcon; - return this; - } - final StandardTemplateParams disallowColorization() { this.allowColorization = false; return this; diff --git a/core/res/res/drawable/ic_reply_notification.xml b/core/res/res/drawable/ic_reply_notification.xml deleted file mode 100644 index a9864b09207a6..0000000000000 --- a/core/res/res/drawable/ic_reply_notification.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - 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 c9592a793cdf4..36903fffb26cb 100644 --- a/core/res/res/layout/notification_template_material_big_base.xml +++ b/core/res/res/layout/notification_template_material_big_base.xml @@ -67,7 +67,6 @@ - - - - diff --git a/core/res/res/layout/notification_template_material_inbox.xml b/core/res/res/layout/notification_template_material_inbox.xml index 4bf70736b8839..eb8925819cd32 100644 --- a/core/res/res/layout/notification_template_material_inbox.xml +++ b/core/res/res/layout/notification_template_material_inbox.xml @@ -129,5 +129,4 @@ - diff --git a/core/res/res/layout/notification_template_material_messaging.xml b/core/res/res/layout/notification_template_material_messaging.xml index f37bda5cc5f67..de9814b9f1f12 100644 --- a/core/res/res/layout/notification_template_material_messaging.xml +++ b/core/res/res/layout/notification_template_material_messaging.xml @@ -58,5 +58,4 @@ - diff --git a/core/res/res/layout/notification_template_reply_icon.xml b/core/res/res/layout/notification_template_reply_icon.xml deleted file mode 100644 index 695f7c8b5c6fc..0000000000000 --- a/core/res/res/layout/notification_template_reply_icon.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index a5e5fbf763f71..9c9e3a91a41f3 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -216,9 +216,6 @@ 48dp - - 8dp - 72dp @@ -710,8 +707,6 @@ 52dp 16dp - - 36dp 0.5 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 065aef50f2970..41323c91ea965 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2873,7 +2873,6 @@ - @@ -3379,7 +3378,6 @@ - @@ -3400,7 +3398,6 @@ - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java index 9a8cff0f8dc1d..20d10d3e0a6ca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java @@ -456,9 +456,6 @@ public class TransformState { if (view instanceof ImageView) { ImageTransformState result = ImageTransformState.obtain(); result.initFrom(view, transformInfo); - if (view.getId() == com.android.internal.R.id.reply_icon_action) { - ((TransformState) result).setIsSameAsAnyView(true); - } return result; } if (view instanceof ProgressBar) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java index 76ec59e0ec28d..4f2cf6e4c1651 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java @@ -22,8 +22,6 @@ import android.app.PendingIntent; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; -import android.graphics.PorterDuffColorFilter; -import android.graphics.drawable.Drawable; import android.service.notification.StatusBarNotification; import android.util.ArraySet; import android.view.View; @@ -56,7 +54,6 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp private TextView mTitle; private TextView mText; protected View mActionsContainer; - private ImageView mReplyAction; private int mContentHeight; private int mMinHeightHint; @@ -156,7 +153,6 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp } mActionsContainer = mView.findViewById(com.android.internal.R.id.actions_container); mActions = mView.findViewById(com.android.internal.R.id.actions); - mReplyAction = mView.findViewById(com.android.internal.R.id.reply_icon_action); mRemoteInputHistory = mView.findViewById( com.android.internal.R.id.notification_material_reply_container); updatePendingIntentCancellations(); @@ -190,31 +186,6 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp }); } } - if (mReplyAction != null) { - // Let's reset the view on update, assuming the new pending intent isn't cancelled - // anymore. The color filter automatically resets when it's updated. - mReplyAction.setEnabled(true); - performOnPendingIntentCancellation(mReplyAction, () -> { - if (mReplyAction != null && mReplyAction.isEnabled()) { - mReplyAction.setEnabled(false); - // The visual appearance doesn't look disabled enough yet, let's add the - // alpha as well. Since Alpha doesn't play nicely right now with the - // transformation, we rather blend it manually with the background color. - Drawable drawable = mReplyAction.getDrawable().mutate(); - PorterDuffColorFilter colorFilter = - (PorterDuffColorFilter) drawable.getColorFilter(); - float disabledAlpha = mView.getResources().getFloat( - com.android.internal.R.dimen.notification_action_disabled_alpha); - if (colorFilter != null) { - int color = colorFilter.getColor(); - color = blendColorWithBackground(color, disabledAlpha); - drawable.mutate().setColorFilter(color, colorFilter.getMode()); - } else { - mReplyAction.setAlpha(disabledAlpha); - } - } - }); - } } private int blendColorWithBackground(int color, float alpha) { @@ -259,16 +230,6 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp } } - @Override - public boolean disallowSingleClick(float x, float y) { - if (mReplyAction != null && mReplyAction.getVisibility() == View.VISIBLE) { - if (isOnView(mReplyAction, x, y) || isOnView(mPicture, x, y)) { - return true; - } - } - return super.disallowSingleClick(x, y); - } - @Override public void onContentUpdated(ExpandableNotificationRow row) { // Reinspect the notification. Before the super call, because the super call also updates From b5839a11e9ba0478f555501dd5cf7ccc1e69b09e Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 6 Nov 2020 14:55:04 -0500 Subject: [PATCH 04/14] Increase the expand button touchable area. The touchable area used to be a 48x48 square, but we actually want the entire right-hand side of the notification to be touchable in the collapsed state. Bug: 163626038 Test: atest SystemUITests Test: manual - check touch bounds and validate w/ TalkBack Change-Id: I9c1b5a0e01d841ed5d448ee5e1030b7f1cbbb2f2 --- .../internal/widget/ConversationLayout.java | 15 +----- .../widget/NotificationExpandButton.java | 47 +++++++++++++++---- .../notification_template_material_base.xml | 28 ++++++----- ...ication_template_material_conversation.xml | 6 +-- core/res/res/values/symbols.xml | 2 +- .../systemui/statusbar/TransformableView.java | 1 + ...ficationConversationTemplateViewWrapper.kt | 5 +- .../NotificationHeaderViewWrapper.java | 5 +- 8 files changed, 66 insertions(+), 43 deletions(-) diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index 289a36f5380db..40e671ffd27ce 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -134,7 +134,6 @@ public class ConversationLayout extends FrameLayout private CachingIconView mConversationIconBadgeBg; private Icon mLargeIcon; private View mExpandButtonContainer; - private View mExpandButtonInnerContainer; private ViewGroup mExpandButtonAndContentContainer; private NotificationExpandButton mExpandButton; private MessagingLinearLayout mImageMessageContainer; @@ -266,7 +265,6 @@ public class ConversationLayout extends FrameLayout mConversationHeader = findViewById(R.id.conversation_header); mContentContainer = findViewById(R.id.notification_action_list_margin_target); mExpandButtonAndContentContainer = findViewById(R.id.expand_button_and_content_container); - mExpandButtonInnerContainer = findViewById(R.id.expand_button_inner_container); mExpandButton = findViewById(R.id.expand_button); mExpandButtonExpandedTopMargin = getResources().getDimensionPixelSize( R.dimen.conversation_expand_button_top_margin_expanded); @@ -1217,25 +1215,18 @@ public class ConversationLayout extends FrameLayout } private void updateExpandButton() { - int drawableId; - int contentDescriptionId; int gravity; int topMargin = 0; ViewGroup newContainer; if (mIsCollapsed) { - drawableId = R.drawable.ic_expand_notification; - contentDescriptionId = R.string.expand_button_content_description_collapsed; gravity = Gravity.CENTER; newContainer = mExpandButtonAndContentContainer; } else { - drawableId = R.drawable.ic_collapse_notification; - contentDescriptionId = R.string.expand_button_content_description_expanded; gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; topMargin = mExpandButtonExpandedTopMargin; newContainer = this; } - mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); - mExpandButton.setColorFilter(mExpandButton.getOriginalNotificationColor()); + mExpandButton.setExpanded(!mIsCollapsed); // We need to make sure that the expand button is in the linearlayout pushing over the // content when collapsed, but allows the content to flow under it when expanded. @@ -1250,8 +1241,6 @@ public class ConversationLayout extends FrameLayout layoutParams.gravity = gravity; layoutParams.topMargin = topMargin; mExpandButton.setLayoutParams(layoutParams); - - mExpandButtonInnerContainer.setContentDescription(mContext.getText(contentDescriptionId)); } private void updateContentEndPaddings() { @@ -1298,7 +1287,7 @@ public class ConversationLayout extends FrameLayout mExpandable = expandable; if (expandable) { mExpandButtonContainer.setVisibility(VISIBLE); - mExpandButtonInnerContainer.setOnClickListener(onClickListener); + mExpandButton.setOnClickListener(onClickListener); mConversationIconContainer.setOnClickListener(onClickListener); } else { mExpandButtonContainer.setVisibility(GONE); diff --git a/core/java/com/android/internal/widget/NotificationExpandButton.java b/core/java/com/android/internal/widget/NotificationExpandButton.java index 986412d2ce5d0..8add34f328bfe 100644 --- a/core/java/com/android/internal/widget/NotificationExpandButton.java +++ b/core/java/com/android/internal/widget/NotificationExpandButton.java @@ -23,6 +23,7 @@ import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.view.RemotableViewMethod; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.Button; import android.widget.ImageView; @@ -36,33 +37,58 @@ import com.android.internal.R; @RemoteViews.RemoteView public class NotificationExpandButton extends ImageView { + private final int mMinTouchTargetSize; private boolean mExpanded; private int mOriginalNotificationColor; public NotificationExpandButton(Context context) { - super(context); + this(context, null, 0, 0); } public NotificationExpandButton(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); + this(context, attrs, 0, 0); } public NotificationExpandButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); + this(context, attrs, defStyleAttr, 0); } public NotificationExpandButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); + mMinTouchTargetSize = (int) (getResources().getDisplayMetrics().density * 48 + 0.5); } + /** + * Show the touchable area of the view for a11y. + * If the parent is the touch container, then that view's bounds are the touchable area. + */ @Override public void getBoundsOnScreen(Rect outRect, boolean clipToParent) { - super.getBoundsOnScreen(outRect, clipToParent); + ViewGroup parent = (ViewGroup) getParent(); + if (parent != null && parent.getId() == R.id.expand_button_touch_container) { + parent.getBoundsOnScreen(outRect, clipToParent); + } else { + super.getBoundsOnScreen(outRect, clipToParent); + } extendRectToMinTouchSize(outRect); } + /** + * Determined if the given point should be touchable. + * If the parent is the touch container, then any point in that view should be touchable. + */ + @Override + public boolean pointInView(float localX, float localY, float slop) { + ViewGroup parent = (ViewGroup) getParent(); + if (parent != null && parent.getId() == R.id.expand_button_touch_container) { + // If our parent is checking with us, then the point must be within its bounds. + return true; + } + return super.pointInView(localX, localY, slop); + } + @RemotableViewMethod public void setOriginalNotificationColor(int color) { mOriginalNotificationColor = color; @@ -81,11 +107,14 @@ public class NotificationExpandButton extends ImageView { } private void extendRectToMinTouchSize(Rect rect) { - int touchTargetSize = (int) (getResources().getDisplayMetrics().density * 48); - rect.left = rect.centerX() - touchTargetSize / 2; - rect.right = rect.left + touchTargetSize; - rect.top = rect.centerY() - touchTargetSize / 2; - rect.bottom = rect.top + touchTargetSize; + if (rect.width() < mMinTouchTargetSize) { + rect.left = rect.centerX() - mMinTouchTargetSize / 2; + rect.right = rect.left + mMinTouchTargetSize; + } + if (rect.height() < mMinTouchTargetSize) { + rect.top = rect.centerY() - mMinTouchTargetSize / 2; + rect.bottom = rect.top + mMinTouchTargetSize; + } } @Override diff --git a/core/res/res/layout/notification_template_material_base.xml b/core/res/res/layout/notification_template_material_base.xml index e5de55ddd07b4..d50cd9eee20f8 100644 --- a/core/res/res/layout/notification_template_material_base.xml +++ b/core/res/res/layout/notification_template_material_base.xml @@ -105,16 +105,22 @@ android:scaleType="centerCrop" /> - + + + + + diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index 5e3d6471fdf70..a0dcd84ea8f1d 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -33,6 +33,7 @@ android:clipToPadding="false" android:paddingTop="12dp" android:paddingBottom="12dp" + android:importantForAccessibility="no" > diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 41323c91ea965..763bd36743c04 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3944,7 +3944,7 @@ - + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java index 063252f08f368..e932bfee84307 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java @@ -28,6 +28,7 @@ public interface TransformableView { int TRANSFORMING_VIEW_IMAGE = 3; int TRANSFORMING_VIEW_PROGRESS = 4; int TRANSFORMING_VIEW_ACTIONS = 5; + int TRANSFORMING_VIEW_EXPANDER = 6; /** * Get the current state of a view in a transform animation diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt index 17f326b69848f..c49f6cbda8ac9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationConversationTemplateViewWrapper.kt @@ -50,7 +50,6 @@ class NotificationConversationTemplateViewWrapper constructor( private lateinit var conversationBadgeBg: View private lateinit var expandButton: View private lateinit var expandButtonContainer: View - private lateinit var expandButtonInnerContainer: View private lateinit var imageMessageContainer: ViewGroup private lateinit var messagingLinearLayout: MessagingLinearLayout private lateinit var conversationTitleView: View @@ -70,8 +69,6 @@ class NotificationConversationTemplateViewWrapper constructor( expandButton = requireViewById(com.android.internal.R.id.expand_button) expandButtonContainer = requireViewById(com.android.internal.R.id.expand_button_container) - expandButtonInnerContainer = - requireViewById(com.android.internal.R.id.expand_button_inner_container) importanceRing = requireViewById(com.android.internal.R.id.conversation_icon_badge_ring) appName = requireViewById(com.android.internal.R.id.app_name_text) conversationTitleView = requireViewById(com.android.internal.R.id.conversation_text) @@ -137,7 +134,7 @@ class NotificationConversationTemplateViewWrapper constructor( ) } - override fun getExpandButton() = expandButtonInnerContainer + override fun getExpandButton() = super.getExpandButton() override fun setShelfIconVisible(visible: Boolean) { if (conversationLayout.isImportantConversation) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index bde3d5a1e1746..d228ce159d489 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -240,8 +240,9 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { protected void updateTransformedTypes() { mTransformationHelper.reset(); - mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_ICON, - mIcon); + mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_ICON, mIcon); + mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_EXPANDER, + mExpandButton); mTransformationHelper.addViewTransformingToSimilar(mWorkProfileImage); if (mIsLowPriority && mHeaderText != null) { mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_TITLE, From 8a0554d59e238f5676ba7bb7cfd5bb6916e406e0 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 9 Nov 2020 11:50:18 -0500 Subject: [PATCH 05/14] Round corners of BigPicture Bug: 163626038 Test: manual Change-Id: I71383c42b6b76d04dcc74551bf994ce1307a873f --- .../notification_big_picture_outline.xml | 21 +++++++++++++++++++ ...fication_template_material_big_picture.xml | 1 + ...ficationBigPictureTemplateViewWrapper.java | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 core/res/res/drawable/notification_big_picture_outline.xml diff --git a/core/res/res/drawable/notification_big_picture_outline.xml b/core/res/res/drawable/notification_big_picture_outline.xml new file mode 100644 index 0000000000000..4c4fa50c43c33 --- /dev/null +++ b/core/res/res/drawable/notification_big_picture_outline.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/core/res/res/layout/notification_template_material_big_picture.xml b/core/res/res/layout/notification_template_material_big_picture.xml index 91243b8eb9dc0..38853c64a3c8f 100644 --- a/core/res/res/layout/notification_template_material_big_picture.xml +++ b/core/res/res/layout/notification_template_material_big_picture.xml @@ -71,6 +71,7 @@ android:layout_marginTop="13dp" android:layout_marginStart="@dimen/notification_content_margin_start" android:layout_marginEnd="@dimen/notification_content_margin_end" + android:background="@drawable/notification_big_picture_outline" android:scaleType="centerCrop" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java index 7248bcef621cc..1d36ad3f13d5a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigPictureTemplateViewWrapper.java @@ -40,6 +40,8 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl public void onContentUpdated(ExpandableNotificationRow row) { super.onContentUpdated(row); updateImageTag(row.getEntry().getSbn()); + // Round the corners of the big picture content + mView.findViewById(com.android.internal.R.id.big_picture).setClipToOutline(true); } private void updateImageTag(StatusBarNotification notification) { From 6417924719884dcdcd5eaf8588699da512a69814 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 9 Nov 2020 11:51:10 -0500 Subject: [PATCH 06/14] Ensure headerless notification with large icon is big enough. Bug: 163626038 Test: manual Change-Id: Ia00c57caf7a34c7249ffdd5516b7c59c7c2f1873 --- core/res/res/layout/notification_template_material_base.xml | 2 ++ core/res/res/values/dimens.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/res/res/layout/notification_template_material_base.xml b/core/res/res/layout/notification_template_material_base.xml index d50cd9eee20f8..25ec8a3837a3f 100644 --- a/core/res/res/layout/notification_template_material_base.xml +++ b/core/res/res/layout/notification_template_material_base.xml @@ -99,6 +99,8 @@ 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_marginEnd="@dimen/notification_header_expand_icon_size" android:background="@drawable/notification_large_icon_outline" android:importantForAccessibility="no" diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 9c9e3a91a41f3..023bea7f5a669 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -705,6 +705,8 @@ 280dp 52dp + + 12dp 16dp From 6ab53b16fe0e4a9ffbf3198a2c47e45ba0eac0e6 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 9 Nov 2020 13:39:04 -0500 Subject: [PATCH 07/14] Notification Title is 16pt in Big state Bug: 163626038 Test: manual Change-Id: Ifc4089a8c8ef8fe78b85ecc4f50c6bbacc46e2e4 --- core/res/res/layout/notification_template_part_line1.xml | 2 +- core/res/res/layout/notification_template_text.xml | 2 +- core/res/res/values/dimens.xml | 9 +++++++-- core/res/res/values/styles_device_defaults.xml | 3 +++ core/res/res/values/styles_material.xml | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/res/res/layout/notification_template_part_line1.xml b/core/res/res/layout/notification_template_part_line1.xml index 622f080653a45..fc5bd9cc6c0b8 100644 --- a/core/res/res/layout/notification_template_part_line1.xml +++ b/core/res/res/layout/notification_template_part_line1.xml @@ -22,7 +22,7 @@ android:orientation="horizontal" > 1dp - 46dp + 50dp 20dp @@ -451,6 +451,8 @@ 14sp 14sp + + 16sp 12sp @@ -469,7 +471,10 @@ 11dp - 0.5dp + 6dp + + + 20sp 5dp diff --git a/core/res/res/values/styles_device_defaults.xml b/core/res/res/values/styles_device_defaults.xml index ef019ba927693..439ae48ebc549 100644 --- a/core/res/res/values/styles_device_defaults.xml +++ b/core/res/res/values/styles_device_defaults.xml @@ -290,6 +290,9 @@ easier. + diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml index 67536fde9b0bf..158289a39d5c8 100644 --- a/core/res/res/values/styles_material.xml +++ b/core/res/res/values/styles_material.xml @@ -477,6 +477,11 @@ please see styles_device_defaults.xml. @dimen/notification_title_text_size + + From b90803f72bae2b9367058e7f16600d5e6d1ac039 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 9 Nov 2020 14:41:16 -0500 Subject: [PATCH 08/14] Hide app name from minimized notifications Bug: 163626038 Test: manual Change-Id: Ic579e2640ad4d2d11bdce856a46e8aa9d00c9c92 --- core/java/android/app/Notification.java | 59 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 1e673cf0305cb..ab748120b6b05 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5158,10 +5158,10 @@ public class Notification implements Parcelable private void bindNotificationHeader(RemoteViews contentView, StandardTemplateParams p) { bindSmallIcon(contentView, p); - bindHeaderAppName(contentView, p); - bindHeaderText(contentView, p); - bindHeaderTextSecondary(contentView, p); - bindHeaderChronometerAndTime(contentView, p); + boolean hasTextToLeft = bindHeaderAppName(contentView, p); + hasTextToLeft |= bindHeaderTextSecondary(contentView, p, hasTextToLeft); + hasTextToLeft |= bindHeaderText(contentView, p, hasTextToLeft); + bindHeaderChronometerAndTime(contentView, p, hasTextToLeft); bindProfileBadge(contentView, p); bindAlertedIcon(contentView, p); bindFeedbackIcon(contentView, p); @@ -5183,10 +5183,12 @@ public class Notification implements Parcelable } private void bindHeaderChronometerAndTime(RemoteViews contentView, - StandardTemplateParams p) { + StandardTemplateParams p, boolean hasTextToLeft) { if (showsTimeOrChronometer()) { - contentView.setViewVisibility(R.id.time_divider, View.VISIBLE); - setTextViewColorSecondary(contentView, R.id.time_divider, p); + if (hasTextToLeft) { + contentView.setViewVisibility(R.id.time_divider, View.VISIBLE); + setTextViewColorSecondary(contentView, R.id.time_divider, p); + } if (mN.extras.getBoolean(EXTRA_SHOW_CHRONOMETER)) { contentView.setViewVisibility(R.id.chronometer, View.VISIBLE); contentView.setLong(R.id.chronometer, "setBase", @@ -5207,7 +5209,11 @@ public class Notification implements Parcelable } } - private void bindHeaderText(RemoteViews contentView, StandardTemplateParams p) { + /** + * @return true if the header text will be visible + */ + private boolean bindHeaderText(RemoteViews contentView, StandardTemplateParams p, + boolean hasTextToLeft) { CharSequence summaryText = p.summaryText; if (summaryText == null && mStyle != null && mStyle.mSummaryTextSet && mStyle.hasSummaryInHeader()) { @@ -5224,20 +5230,32 @@ public class Notification implements Parcelable processLegacyText(summaryText))); setTextViewColorSecondary(contentView, R.id.header_text, p); contentView.setViewVisibility(R.id.header_text, View.VISIBLE); - contentView.setViewVisibility(R.id.header_text_divider, View.VISIBLE); - setTextViewColorSecondary(contentView, R.id.header_text_divider, p); + if (hasTextToLeft) { + contentView.setViewVisibility(R.id.header_text_divider, View.VISIBLE); + setTextViewColorSecondary(contentView, R.id.header_text_divider, p); + } + return true; } + return false; } - private void bindHeaderTextSecondary(RemoteViews contentView, StandardTemplateParams p) { + /** + * @return true if the secondary header text will be visible + */ + private boolean bindHeaderTextSecondary(RemoteViews contentView, StandardTemplateParams p, + boolean hasTextToLeft) { if (!TextUtils.isEmpty(p.headerTextSecondary)) { contentView.setTextViewText(R.id.header_text_secondary, processTextSpans( processLegacyText(p.headerTextSecondary))); setTextViewColorSecondary(contentView, R.id.header_text_secondary, p); contentView.setViewVisibility(R.id.header_text_secondary, View.VISIBLE); - contentView.setViewVisibility(R.id.header_text_secondary_divider, View.VISIBLE); - setTextViewColorSecondary(contentView, R.id.header_text_secondary_divider, p); + if (hasTextToLeft) { + contentView.setViewVisibility(R.id.header_text_secondary_divider, View.VISIBLE); + setTextViewColorSecondary(contentView, R.id.header_text_secondary_divider, p); + } + return true; } + return false; } /** @@ -5274,13 +5292,23 @@ public class Notification implements Parcelable return String.valueOf(name); } - private void bindHeaderAppName(RemoteViews contentView, StandardTemplateParams p) { + + /** + * @return true if the app name will be visible + */ + private boolean bindHeaderAppName(RemoteViews contentView, StandardTemplateParams p) { + if (p.mViewType == StandardTemplateParams.VIEW_TYPE_MINIMIZED) { + contentView.setViewVisibility(R.id.app_name_text, View.GONE); + return false; + } + contentView.setViewVisibility(R.id.app_name_text, View.VISIBLE); contentView.setTextViewText(R.id.app_name_text, loadHeaderAppName()); if (isColorized(p)) { setTextViewColorPrimary(contentView, R.id.app_name_text, p); } else { contentView.setTextColor(R.id.app_name_text, getSecondaryTextColor(p)); } + return true; } private boolean isColorized(StandardTemplateParams p) { @@ -5504,7 +5532,7 @@ public class Notification implements Parcelable */ public RemoteViews makeNotificationHeader() { return makeNotificationHeader(mParams.reset() - .viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED) + .viewType(StandardTemplateParams.VIEW_TYPE_GROUP_HEADER) .fillTextsFrom(this)); } @@ -10977,6 +11005,7 @@ public class Notification implements Parcelable public static int VIEW_TYPE_HEADS_UP = 3; public static int VIEW_TYPE_MINIMIZED = 4; public static int VIEW_TYPE_PUBLIC = 5; + public static int VIEW_TYPE_GROUP_HEADER = 6; int mViewType = VIEW_TYPE_UNSPECIFIED; boolean mHeaderless; From 41cdfc0ae8b2f2ba8ddae318a90f27d99f6922ae Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Mon, 9 Nov 2020 17:00:16 -0500 Subject: [PATCH 09/14] Remove the unneeded icon spacing in the InboxStyle. Because the LargeIcon is was moved up a 'line' to the top of the notification, the only lines which can intersect it are the header and title lines; the first line of text from the inbox style no longer can. This also sort of depends on ag/13018219 which fixed the vertical spacing enough to make this look good. Bug: 163626038 Test: manual Change-Id: Ic9ed82eb3c0e9c7e619917351c3461ffe1713857 --- core/java/android/app/Notification.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index ab748120b6b05..db03c2f89afd0 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -8256,8 +8256,6 @@ public class Notification implements Parcelable mBuilder.processTextSpans(mBuilder.processLegacyText(str))); mBuilder.setTextViewColorSecondary(contentView, rowIds[i], p); contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0); - handleInboxImageMargin(contentView, rowIds[i], first, - result.getHeadingFullMarginEnd()); if (first) { onlyViewId = rowIds[i]; } else { @@ -8303,20 +8301,6 @@ public class Notification implements Parcelable } return false; } - - private void handleInboxImageMargin(RemoteViews contentView, int id, boolean first, - int marginEndValue) { - int endMargin = 0; - if (first) { - final int max = mBuilder.mN.extras.getInt(EXTRA_PROGRESS_MAX, 0); - final boolean ind = mBuilder.mN.extras.getBoolean(EXTRA_PROGRESS_INDETERMINATE); - boolean hasProgress = max != 0 || ind; - if (!hasProgress) { - endMargin = marginEndValue; - } - } - contentView.setViewLayoutMarginEnd(id, endMargin); - } } /** From 6f96b0b7c2cfd8c6028e58a011ec3be47b7f7bfd Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 10 Nov 2020 13:57:33 -0500 Subject: [PATCH 10/14] Fix HUNs * Add and prefer a heads up template which is the base template + actions * When a HUN shows a template with a header, only allow hiding that header if there is no large icon to avoid a visual mess. Bug: 163626038 Test: manual Change-Id: Ia42e0a6b1b1ecd4dd438a817f9442a838a2bdb5c --- core/java/android/app/Notification.java | 18 ++++--- ...cation_template_material_heads_up_base.xml | 54 +++++++++++++++++++ core/res/res/values/symbols.xml | 1 + .../NotificationTemplateViewWrapper.java | 11 +++- 4 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 core/res/res/layout/notification_template_material_heads_up_base.xml diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index db03c2f89afd0..d57215bdc01a3 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -384,6 +384,7 @@ public class Notification implements Parcelable private static final ArraySet STANDARD_LAYOUTS = new ArraySet<>(); static { STANDARD_LAYOUTS.add(R.layout.notification_template_material_base); + STANDARD_LAYOUTS.add(R.layout.notification_template_material_heads_up_base); STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_base); STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_picture); STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_text); @@ -4876,7 +4877,8 @@ public class Notification implements Parcelable private RemoteViews applyStandardTemplate(int resId, StandardTemplateParams p, TemplateBindResult result) { - p.headerless(resId == getBaseLayoutResource()); + p.headerless(resId == getBaseLayoutResource() + || resId == getHeadsUpBaseLayoutResource()); RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -5144,10 +5146,7 @@ public class Notification implements Parcelable if (mN.mLargeIcon == null && mN.largeIcon != null) { mN.mLargeIcon = Icon.createWithBitmap(mN.largeIcon); } - // Hide the large icon in Heads Up view, because the icon is partly within header, - // which for HUNs will be hidden and cropped. - boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon - && p.mViewType != StandardTemplateParams.VIEW_TYPE_HEADS_UP; + boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon; if (showLargeIcon) { contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); contentView.setImageViewIcon(R.id.right_icon, mN.mLargeIcon); @@ -5610,7 +5609,7 @@ public class Notification implements Parcelable .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP) .fillTextsFrom(this) .setMaxRemoteInputHistory(1); - return applyStandardTemplateWithActions(getBigBaseLayoutResource(), + return applyStandardTemplateWithActions(getHeadsUpBaseLayoutResource(), p, null /* result */); } @@ -6168,6 +6167,10 @@ public class Notification implements Parcelable return R.layout.notification_template_material_base; } + private int getHeadsUpBaseLayoutResource() { + return R.layout.notification_template_material_heads_up_base; + } + private int getBigBaseLayoutResource() { return R.layout.notification_template_material_big_base; } @@ -7088,6 +7091,7 @@ public class Notification implements Parcelable @Override public RemoteViews makeHeadsUpContentView(boolean increasedHeight) { if (increasedHeight && mBuilder.mActions.size() > 0) { + // TODO(b/163626038): pass VIEW_TYPE_HEADS_UP? return makeBigContentView(); } return super.makeHeadsUpContentView(increasedHeight); @@ -8657,7 +8661,7 @@ public class Notification implements Parcelable } TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource(), + mBuilder.getHeadsUpBaseLayoutResource(), StandardTemplateParams.VIEW_TYPE_HEADS_UP, result); buildIntoRemoteViewContent(remoteViews, headsUpContentView, result, false); return remoteViews; diff --git a/core/res/res/layout/notification_template_material_heads_up_base.xml b/core/res/res/layout/notification_template_material_heads_up_base.xml new file mode 100644 index 0000000000000..3153db8d13c3d --- /dev/null +++ b/core/res/res/layout/notification_template_material_heads_up_base.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 763bd36743c04..0d2886ba75c31 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2184,6 +2184,7 @@ + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java index 4f2cf6e4c1651..e9934c0053b09 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.row.wrapper; +import static android.view.View.VISIBLE; + import static com.android.systemui.statusbar.notification.row.ExpandableNotificationRow.DEFAULT_HEADER_VISIBLE_AMOUNT; import android.app.PendingIntent; @@ -61,6 +63,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp private ArraySet mCancelledPendingIntents = new ArraySet<>(); private UiOffloadThread mUiOffloadThread; private View mRemoteInputHistory; + private boolean mCanHideHeader; private float mHeaderTranslation; protected NotificationTemplateViewWrapper(Context ctx, View view, @@ -236,6 +239,10 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp // the transformation types and we need to have our values set by then. resolveTemplateViews(row.getEntry().getSbn()); super.onContentUpdated(row); + // With the modern templates, a large icon visually overlaps the header, so we can't + // simply hide the header -- just show the + mCanHideHeader = mNotificationHeader != null + && (mPicture == null || mPicture.getVisibility() != VISIBLE); if (row.getHeaderVisibleAmount() != DEFAULT_HEADER_VISIBLE_AMOUNT) { setHeaderVisibleAmount(row.getHeaderVisibleAmount()); } @@ -294,14 +301,14 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp @Override public int getHeaderTranslation(boolean forceNoHeader) { - return forceNoHeader ? mFullHeaderTranslation : (int) mHeaderTranslation; + return forceNoHeader && mCanHideHeader ? mFullHeaderTranslation : (int) mHeaderTranslation; } @Override public void setHeaderVisibleAmount(float headerVisibleAmount) { super.setHeaderVisibleAmount(headerVisibleAmount); float headerTranslation = 0f; - if (mNotificationHeader != null) { + if (mCanHideHeader && mNotificationHeader != null) { mNotificationHeader.setAlpha(headerVisibleAmount); headerTranslation = (1.0f - headerVisibleAmount) * mFullHeaderTranslation; } From 87257cbb6e51a3a36c6f565d8614177c0fe77195 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 12 Nov 2020 15:02:33 -0500 Subject: [PATCH 11/14] Fix the placement of the work profile and feedback badges. * Removed some dead code from NotificationTopLineView * Icons appear left-aligned, as they do with conversations * Fixed the order (also with conversations) to ensure that the 'alerted' icon disappearing doesn't cause movement (at least when the header text fits; otherwise some amount of movement is unavoidable). Bug: 163626038 Test: manual Change-Id: I8e19dd504f8c861f752cd2705048f015ab0e3106 --- .../android/view/NotificationTopLineView.java | 42 ++++------------- ...ication_template_material_conversation.xml | 45 ++++++++++--------- .../layout/notification_top_line_views.xml | 24 +++++----- 3 files changed, 44 insertions(+), 67 deletions(-) diff --git a/core/java/android/view/NotificationTopLineView.java b/core/java/android/view/NotificationTopLineView.java index f6073ca2f0b2e..a8eabe5a7967b 100644 --- a/core/java/android/view/NotificationTopLineView.java +++ b/core/java/android/view/NotificationTopLineView.java @@ -26,9 +26,6 @@ import android.widget.RemoteViews; import com.android.internal.R; -import java.util.Arrays; -import java.util.List; - /** * The top line of content in a notification view. * This includes the text views and badges but excludes the icon and the expander. @@ -39,17 +36,14 @@ import java.util.List; public class NotificationTopLineView extends ViewGroup { private final int mGravityY; private final int mChildMinWidth; - private final int mContentEndMargin; @Nullable private View mAppName; @Nullable private View mTitle; private View mHeaderText; private View mSecondaryHeaderText; private OnClickListener mFeedbackListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); - private View mProfileBadge; private View mFeedbackIcon; private int mHeaderTextMarginEnd; - private List mIconsAtEnd; private int mMaxAscent; private int mMaxDescent; @@ -72,7 +66,6 @@ public class NotificationTopLineView extends ViewGroup { super(context, attrs, defStyleAttr, defStyleRes); Resources res = getResources(); mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width); - mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end); // NOTE: Implementation only supports TOP, BOTTOM, and CENTER_VERTICAL gravities, // with CENTER_VERTICAL being the default. @@ -96,9 +89,7 @@ public class NotificationTopLineView extends ViewGroup { mTitle = findViewById(R.id.title); mHeaderText = findViewById(R.id.header_text); mSecondaryHeaderText = findViewById(R.id.header_text_secondary); - mProfileBadge = findViewById(R.id.profile_badge); mFeedbackIcon = findViewById(R.id.feedback); - mIconsAtEnd = Arrays.asList(mProfileBadge, mFeedbackIcon); } @Override @@ -111,7 +102,6 @@ public class NotificationTopLineView extends ViewGroup { int wrapContentHeightSpec = MeasureSpec.makeMeasureSpec(givenHeight, MeasureSpec.AT_MOST); int totalWidth = getPaddingStart(); - int iconWidth = getPaddingEnd(); int maxChildHeight = -1; mMaxAscent = -1; mMaxDescent = -1; @@ -127,12 +117,7 @@ public class NotificationTopLineView extends ViewGroup { int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec, lp.topMargin + lp.bottomMargin, lp.height); child.measure(childWidthSpec, childHeightSpec); - // Icons that should go at the end - if (mIconsAtEnd.contains(child)) { - iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); - } else { - totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); - } + totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); int childBaseline = child.getBaseline(); int childHeight = child.getMeasuredHeight(); if (childBaseline != -1) { @@ -143,7 +128,7 @@ public class NotificationTopLineView extends ViewGroup { } // Ensure that there is at least enough space for the icons - int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth); + int endMargin = Math.max(mHeaderTextMarginEnd, getPaddingEnd()); if (totalWidth > givenWidth - endMargin) { int overFlow = totalWidth - givenWidth + endMargin; if (mAppName != null) { @@ -184,7 +169,6 @@ public class NotificationTopLineView extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int left = getPaddingStart(); - int end = getMeasuredWidth(); int childCount = getChildCount(); int ownHeight = b - t; int childSpace = ownHeight - mPaddingTop - mPaddingBottom; @@ -238,22 +222,12 @@ public class NotificationTopLineView extends ViewGroup { childTop = mPaddingTop; } - // Icons that should go at the end - if (mIconsAtEnd.contains(child)) { - if (end == getMeasuredWidth()) { - layoutRight = end - mContentEndMargin; - } else { - layoutRight = end - params.getMarginEnd(); - } - layoutLeft = layoutRight - child.getMeasuredWidth(); - end = layoutLeft - params.getMarginStart(); - } else { - left += params.getMarginStart(); - int right = left + child.getMeasuredWidth(); - layoutLeft = left; - layoutRight = right; - left = right + params.getMarginEnd(); - } + left += params.getMarginStart(); + int right = left + child.getMeasuredWidth(); + layoutLeft = left; + layoutRight = right; + left = right + params.getMarginEnd(); + if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { int ltrLeft = layoutLeft; layoutLeft = getWidth() - layoutRight; diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index a0dcd84ea8f1d..520ae282b9421 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -207,17 +207,19 @@ android:visibility="gone" /> - + /> + /> + + + - diff --git a/core/res/res/layout/notification_top_line_views.xml b/core/res/res/layout/notification_top_line_views.xml index 5d3feeb0725da..51974ac7dcf31 100644 --- a/core/res/res/layout/notification_top_line_views.xml +++ b/core/res/res/layout/notification_top_line_views.xml @@ -98,18 +98,6 @@ android:visibility="gone" /> - - + + From dc81adf34e104cdf5e7d44c17d7ae24ff58f4eda Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 12 Nov 2020 09:29:16 -0500 Subject: [PATCH 12/14] Reduce notification minimized height Bug: 163626038 Test: manual Change-Id: Ic5e94389f2f41eebcecc8df393ff2f26c1d7e426 --- .../NotificationMaxHeightFrameLayout.java | 81 +++++++++++++++++++ .../notification_template_material_base.xml | 4 +- ...cation_template_material_heads_up_base.xml | 51 +++++++----- core/res/res/values/dimens.xml | 2 +- packages/SystemUI/res/values/dimens.xml | 10 ++- .../row/ExpandableNotificationRow.java | 28 +++++-- 6 files changed, 146 insertions(+), 30 deletions(-) create mode 100644 core/java/com/android/internal/widget/NotificationMaxHeightFrameLayout.java diff --git a/core/java/com/android/internal/widget/NotificationMaxHeightFrameLayout.java b/core/java/com/android/internal/widget/NotificationMaxHeightFrameLayout.java new file mode 100644 index 0000000000000..6d5fb66b27ef9 --- /dev/null +++ b/core/java/com/android/internal/widget/NotificationMaxHeightFrameLayout.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 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. + */ + +package com.android.internal.widget; + +import android.annotation.Nullable; +import android.content.Context; +import android.util.AttributeSet; +import android.widget.FrameLayout; +import android.widget.RemoteViews; + +/** + * This custom subclass of FrameLayout enforces that its calculated height be no larger than the + * standard height of a notification. This is not required in the normal case, as the + * NotificationContentView gets this same value from the ExpandableNotificationRow, and enforces it + * as a maximum. It is required in the case of the HUN version of the headerless notification, + * because that style puts the actions below the headerless portion. If we don't cap this, then in + * certain situations (larger fonts, decorated custom views) the contents of the headerless + * notification push on the margins and increase the size of that view, which causes the actions to + * be cropped on the bottom by the HUN notification max height. + */ +@RemoteViews.RemoteView +public class NotificationMaxHeightFrameLayout extends FrameLayout { + private final int mNotificationMaxHeight; + + public NotificationMaxHeightFrameLayout(Context context) { + this(context, null, 0, 0); + } + + public NotificationMaxHeightFrameLayout(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0, 0); + } + + public NotificationMaxHeightFrameLayout(Context context, @Nullable AttributeSet attrs, + int defStyleAttr) { + this(context, attrs, defStyleAttr, 0); + } + + public NotificationMaxHeightFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, + int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + // `notification_min_height` refers to "minimized" not "minimum"; it is a max height + mNotificationMaxHeight = getFontScaledHeight(mContext, + com.android.internal.R.dimen.notification_min_height); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (MeasureSpec.getSize(heightMeasureSpec) > mNotificationMaxHeight) { + final int mode = MeasureSpec.getMode(heightMeasureSpec); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(mNotificationMaxHeight, mode); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + + /** + * NOTE: This is copied from com.android.systemui.statusbar.notification.NotificationUtils + * + * @param dimenId the dimen to look up + * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp + */ + private static int getFontScaledHeight(Context context, int dimenId) { + final int dimensionPixelSize = context.getResources().getDimensionPixelSize(dimenId); + final float factor = Math.max(1.0f, context.getResources().getDisplayMetrics().scaledDensity + / context.getResources().getDisplayMetrics().density); + return (int) (dimensionPixelSize * factor); + } +} diff --git a/core/res/res/layout/notification_template_material_base.xml b/core/res/res/layout/notification_template_material_base.xml index 25ec8a3837a3f..46b3a8f4644fb 100644 --- a/core/res/res/layout/notification_template_material_base.xml +++ b/core/res/res/layout/notification_template_material_base.xml @@ -14,7 +14,7 @@ ~ limitations under the License --> - - + diff --git a/core/res/res/layout/notification_template_material_heads_up_base.xml b/core/res/res/layout/notification_template_material_heads_up_base.xml index 3153db8d13c3d..d55499130dccd 100644 --- a/core/res/res/layout/notification_template_material_heads_up_base.xml +++ b/core/res/res/layout/notification_template_material_heads_up_base.xml @@ -23,32 +23,43 @@ android:tag="headsUp" > - - - - - - - + + + + + + + + + diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 1c51cb961e050..4eeeb18cbcd5f 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -308,7 +308,7 @@ 56dp - 106dp + 76dp 64dp diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index d946f7cb11c15..0e4f4ddf01c96 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -133,17 +133,23 @@ 92dp + + 106dp + 294dp 128dp - + 148dp + + 162dp + - 162dp + 132dp 188dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 2253b2ba26f20..b7613b41f1ec0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -35,7 +35,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Color; import android.graphics.Path; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.AnimationDrawable; @@ -154,10 +153,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private int mIconTransformContentShift; private int mMaxHeadsUpHeightBeforeN; private int mMaxHeadsUpHeightBeforeP; + private int mMaxHeadsUpHeightBeforeS; private int mMaxHeadsUpHeight; private int mMaxHeadsUpHeightIncreased; private int mNotificationMinHeightBeforeN; private int mNotificationMinHeightBeforeP; + private int mNotificationMinHeightBeforeS; private int mNotificationMinHeight; private int mNotificationMinHeightLarge; private int mNotificationMinHeightMedia; @@ -647,6 +648,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView != com.android.internal.R.id.status_bar_latest_event_content; boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; boolean beforeP = mEntry.targetSdk < Build.VERSION_CODES.P; + boolean beforeS = mEntry.targetSdk < Build.VERSION_CODES.S; int minHeight; View expandedView = layout.getExpandedChild(); @@ -654,8 +656,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView && expandedView.findViewById(com.android.internal.R.id.media_actions) != null; boolean showCompactMediaSeekbar = mMediaManager.getShowCompactMediaSeekbar(); - if (customView && beforeP && !mIsSummaryWithChildren) { - minHeight = beforeN ? mNotificationMinHeightBeforeN : mNotificationMinHeightBeforeP; + if (customView && beforeS && !mIsSummaryWithChildren) { + if (beforeN) { + minHeight = mNotificationMinHeightBeforeN; + } else if (beforeP) { + minHeight = mNotificationMinHeightBeforeP; + } else { + minHeight = mNotificationMinHeightBeforeS; + } } else if (isMediaLayout && showCompactMediaSeekbar) { minHeight = mNotificationMinHeightMedia; } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { @@ -667,8 +675,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView layout.getHeadsUpChild().getId() != com.android.internal.R.id.status_bar_latest_event_content; int headsUpHeight; - if (headsUpCustom && beforeP) { - headsUpHeight = beforeN ? mMaxHeadsUpHeightBeforeN : mMaxHeadsUpHeightBeforeP; + if (headsUpCustom && beforeS) { + if (beforeN) { + headsUpHeight = mMaxHeadsUpHeightBeforeN; + } else if (beforeP) { + headsUpHeight = mMaxHeadsUpHeightBeforeP; + } else { + headsUpHeight = mMaxHeadsUpHeightBeforeS; + } } else if (mUseIncreasedHeadsUpHeight && layout == mPrivateLayout) { headsUpHeight = mMaxHeadsUpHeightIncreased; } else { @@ -1604,6 +1618,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView R.dimen.notification_min_height_legacy); mNotificationMinHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_before_p); + mNotificationMinHeightBeforeS = NotificationUtils.getFontScaledHeight(mContext, + R.dimen.notification_min_height_before_s); mNotificationMinHeight = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height); mNotificationMinHeightLarge = NotificationUtils.getFontScaledHeight(mContext, @@ -1616,6 +1632,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView R.dimen.notification_max_heads_up_height_legacy); mMaxHeadsUpHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_max_heads_up_height_before_p); + mMaxHeadsUpHeightBeforeS = NotificationUtils.getFontScaledHeight(mContext, + R.dimen.notification_max_heads_up_height_before_s); mMaxHeadsUpHeight = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_max_heads_up_height); mMaxHeadsUpHeightIncreased = NotificationUtils.getFontScaledHeight(mContext, From f3f70badef9ca0d16485dce33bc08a1e99048600 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 13 Nov 2020 10:44:01 -0500 Subject: [PATCH 13/14] Fix/hack MessagingStyle notifications * Restore the icon size to 36dp * Give them increased height to accommodate the legacy layouts Bug: 163626038 Bug: 173204301 Test: manual Change-Id: Ib6b178b56f094e3053fc7e1d1b459c6f38b15385 --- core/res/res/values/dimens.xml | 2 +- .../notification/row/ExpandableNotificationRow.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 4eeeb18cbcd5f..d7722efbffd46 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -734,7 +734,7 @@ 256dp - @dimen/notification_right_icon_size + 36dp 52dp 28dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index b7613b41f1ec0..ff789a73d6c78 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -70,6 +70,7 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.ContrastColorUtil; import com.android.internal.widget.CachingIconView; +import com.android.internal.widget.MessagingLayout; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; @@ -654,6 +655,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView View expandedView = layout.getExpandedChild(); boolean isMediaLayout = expandedView != null && expandedView.findViewById(com.android.internal.R.id.media_actions) != null; + boolean isMessagingLayout = layout.getContractedChild() instanceof MessagingLayout; boolean showCompactMediaSeekbar = mMediaManager.getShowCompactMediaSeekbar(); if (customView && beforeS && !mIsSummaryWithChildren) { @@ -666,6 +668,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } } else if (isMediaLayout && showCompactMediaSeekbar) { minHeight = mNotificationMinHeightMedia; + } else if (isMessagingLayout) { + // TODO(b/173204301): MessagingStyle notifications currently look broken when we enforce + // the standard notification height, so we have to afford them more vertical space to + // make sure we don't crop them terribly. We actually need to revisit this and give + // them a headerless design, then remove this hack. + minHeight = mNotificationMinHeightLarge; } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { minHeight = mNotificationMinHeightLarge; } else { From 89cc6a1fc321e709312f71f199fa3757a3ee94cb Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 13 Nov 2020 13:51:03 -0500 Subject: [PATCH 14/14] Update variable names to reduce confusion. I considered renaming the dimens as well, but that requires refactors across more repos, and seems excessive in this otherwise functional refactor. Test: manual Change-Id: I2fb6e5b20159644803facca3f79da9b0cd097ad0 --- .../row/ExpandableNotificationRow.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index ff789a73d6c78..a7c866d6f9309 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -157,13 +157,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private int mMaxHeadsUpHeightBeforeS; private int mMaxHeadsUpHeight; private int mMaxHeadsUpHeightIncreased; - private int mNotificationMinHeightBeforeN; - private int mNotificationMinHeightBeforeP; - private int mNotificationMinHeightBeforeS; - private int mNotificationMinHeight; - private int mNotificationMinHeightLarge; - private int mNotificationMinHeightMedia; - private int mNotificationMaxHeight; + private int mMaxSmallHeightBeforeN; + private int mMaxSmallHeightBeforeP; + private int mMaxSmallHeightBeforeS; + private int mMaxSmallHeight; + private int mMaxSmallHeightLarge; + private int mMaxSmallHeightMedia; + private int mMaxExpandedHeight; private int mIncreasedPaddingBetweenElements; private int mNotificationLaunchHeight; private boolean mMustStayOnScreen; @@ -650,7 +650,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView boolean beforeN = mEntry.targetSdk < Build.VERSION_CODES.N; boolean beforeP = mEntry.targetSdk < Build.VERSION_CODES.P; boolean beforeS = mEntry.targetSdk < Build.VERSION_CODES.S; - int minHeight; + int smallHeight; View expandedView = layout.getExpandedChild(); boolean isMediaLayout = expandedView != null @@ -660,24 +660,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (customView && beforeS && !mIsSummaryWithChildren) { if (beforeN) { - minHeight = mNotificationMinHeightBeforeN; + smallHeight = mMaxSmallHeightBeforeN; } else if (beforeP) { - minHeight = mNotificationMinHeightBeforeP; + smallHeight = mMaxSmallHeightBeforeP; } else { - minHeight = mNotificationMinHeightBeforeS; + smallHeight = mMaxSmallHeightBeforeS; } } else if (isMediaLayout && showCompactMediaSeekbar) { - minHeight = mNotificationMinHeightMedia; + smallHeight = mMaxSmallHeightMedia; } else if (isMessagingLayout) { // TODO(b/173204301): MessagingStyle notifications currently look broken when we enforce // the standard notification height, so we have to afford them more vertical space to // make sure we don't crop them terribly. We actually need to revisit this and give // them a headerless design, then remove this hack. - minHeight = mNotificationMinHeightLarge; + smallHeight = mMaxSmallHeightLarge; } else if (mUseIncreasedCollapsedHeight && layout == mPrivateLayout) { - minHeight = mNotificationMinHeightLarge; + smallHeight = mMaxSmallHeightLarge; } else { - minHeight = mNotificationMinHeight; + smallHeight = mMaxSmallHeight; } boolean headsUpCustom = layout.getHeadsUpChild() != null && layout.getHeadsUpChild().getId() @@ -701,7 +701,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (headsUpWrapper != null) { headsUpHeight = Math.max(headsUpHeight, headsUpWrapper.getMinLayoutHeight()); } - layout.setHeights(minHeight, headsUpHeight, mNotificationMaxHeight); + layout.setHeights(smallHeight, headsUpHeight, mMaxExpandedHeight); } @NonNull @@ -1622,19 +1622,19 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } private void initDimens() { - mNotificationMinHeightBeforeN = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeightBeforeN = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_legacy); - mNotificationMinHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeightBeforeP = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_before_p); - mNotificationMinHeightBeforeS = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeightBeforeS = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_before_s); - mNotificationMinHeight = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeight = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height); - mNotificationMinHeightLarge = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeightLarge = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_increased); - mNotificationMinHeightMedia = NotificationUtils.getFontScaledHeight(mContext, + mMaxSmallHeightMedia = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_min_height_media); - mNotificationMaxHeight = NotificationUtils.getFontScaledHeight(mContext, + mMaxExpandedHeight = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_max_height); mMaxHeadsUpHeightBeforeN = NotificationUtils.getFontScaledHeight(mContext, R.dimen.notification_max_heads_up_height_legacy);