diff options
| author | 2018-04-18 14:31:07 +0800 | |
|---|---|---|
| committer | 2018-04-23 16:19:21 +0800 | |
| commit | 384804b42deaa7a679f8afbb0c7c69cf4aa68f06 (patch) | |
| tree | b0b392cf27228756fef07c1eae74430d7dc7de46 | |
| parent | c8303adb4700ebbb921f0067a7ff21ef1c75c2fc (diff) | |
Split the reply icon permanently from the right icon
Previously these would overlap, but they are now completely
separate.
Test: ensure that all notification styles still work with the new affordance.
Change-Id: I16f5f863b4afac27494a4a7615631bca240ca532
Fixes: 72750728
| -rw-r--r-- | core/java/android/app/Notification.java | 254 | ||||
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 22 | ||||
| -rw-r--r-- | core/java/com/android/internal/widget/ImageFloatingTextView.java | 14 | ||||
| -rw-r--r-- | core/res/res/drawable/ic_reply_notification.xml | 26 | ||||
| -rw-r--r-- | core/res/res/drawable/ic_reply_notification_large.xml | 29 | ||||
| -rw-r--r-- | core/res/res/drawable/notification_reply_background.xml | 24 | ||||
| -rw-r--r-- | core/res/res/layout/notification_template_right_icon.xml | 29 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 16 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 4 |
9 files changed, 220 insertions, 198 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 4f88a03db435..a69bd8d57b29 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4278,7 +4278,6 @@ public class Notification implements Parcelable private void resetStandardTemplate(RemoteViews contentView) { resetNotificationHeader(contentView); - resetContentMargins(contentView); contentView.setViewVisibility(R.id.right_icon, View.GONE); contentView.setViewVisibility(R.id.title, View.GONE); contentView.setTextViewText(R.id.title, null); @@ -4310,24 +4309,23 @@ public class Notification implements Parcelable mN.mUsesStandardHeader = false; } - private void resetContentMargins(RemoteViews contentView) { - contentView.setViewLayoutMarginEndDimen(R.id.line1, 0); - contentView.setViewLayoutMarginEndDimen(R.id.text, 0); - } - - private RemoteViews applyStandardTemplate(int resId) { - return applyStandardTemplate(resId, mParams.reset().fillTextsFrom(this)); + private RemoteViews applyStandardTemplate(int resId, TemplateBindResult result) { + return applyStandardTemplate(resId, mParams.reset().fillTextsFrom(this), + result); } /** * @param hasProgress whether the progress bar should be shown and set + * @param result */ - private RemoteViews applyStandardTemplate(int resId, boolean hasProgress) { + private RemoteViews applyStandardTemplate(int resId, boolean hasProgress, + TemplateBindResult result) { return applyStandardTemplate(resId, mParams.reset().hasProgress(hasProgress) - .fillTextsFrom(this)); + .fillTextsFrom(this), result); } - private RemoteViews applyStandardTemplate(int resId, StandardTemplateParams p) { + private RemoteViews applyStandardTemplate(int resId, StandardTemplateParams p, + TemplateBindResult result) { RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -4335,7 +4333,7 @@ public class Notification implements Parcelable final Bundle ex = mN.extras; updateBackgroundColor(contentView); bindNotificationHeader(contentView, p.ambient, p.headerTextSecondary); - bindLargeIcon(contentView, p.hideLargeIcon || p.ambient, p.alwaysShowReply); + bindLargeIconAndReply(contentView, p, result); boolean showProgress = handleProgressBar(p.hasProgress, contentView, ex); if (p.title != null) { contentView.setViewVisibility(R.id.title, View.VISIBLE); @@ -4531,8 +4529,31 @@ public class Notification implements Parcelable } } - private void bindLargeIcon(RemoteViews contentView, boolean hideLargeIcon, - boolean alwaysShowReply) { + private void bindLargeIconAndReply(RemoteViews contentView, StandardTemplateParams p, + TemplateBindResult result) { + boolean largeIconShown = bindLargeIcon(contentView, p.hideLargeIcon || p.ambient); + boolean showReplyIcon = bindReplyIcon(contentView, p.hideReplyIcon || p.ambient); + contentView.setViewVisibility(R.id.right_icon_container, + largeIconShown || showReplyIcon ? View.VISIBLE : View.GONE); + int marginEndDimen = 0; + if (largeIconShown && showReplyIcon) { + marginEndDimen = R.dimen.notification_content_picture_and_reply_margin; + } else if (largeIconShown || showReplyIcon) { + marginEndDimen = R.dimen.notification_content_picture_margin; + } + contentView.setViewLayoutMarginEndDimen(R.id.line1, marginEndDimen); + contentView.setViewLayoutMarginEndDimen(R.id.text, marginEndDimen); + contentView.setViewLayoutMarginEndDimen(R.id.progress, marginEndDimen); + if (result != null) { + result.setIconMarginEndDimen(marginEndDimen); + } + } + + /** + * Bind the large icon. + * @return if the largeIcon is visible + */ + private boolean bindLargeIcon(RemoteViews contentView, boolean hideLargeIcon) { if (mN.mLargeIcon == null && mN.largeIcon != null) { mN.mLargeIcon = Icon.createWithBitmap(mN.largeIcon); } @@ -4541,51 +4562,35 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); contentView.setImageViewIcon(R.id.right_icon, mN.mLargeIcon); processLargeLegacyIcon(mN.mLargeIcon, contentView); - int endMargin = R.dimen.notification_content_picture_margin; - contentView.setViewLayoutMarginEndDimen(R.id.line1, endMargin); - contentView.setViewLayoutMarginEndDimen(R.id.text, endMargin); - contentView.setViewLayoutMarginEndDimen(R.id.progress, endMargin); } - // Bind the reply action - Action action = findReplyAction(); + return showLargeIcon; + } - boolean actionVisible = action != null && (showLargeIcon || alwaysShowReply); - int replyId = showLargeIcon ? R.id.reply_icon_action : R.id.right_icon; + /** + * Bind the reply icon. + * @return if the reply icon is visible + */ + private boolean bindReplyIcon(RemoteViews contentView, boolean hideReplyIcon) { + boolean actionVisible = !hideReplyIcon; + Action action = null; if (actionVisible) { - // We're only showing the icon as big if we're hiding the large icon - int contrastColor = resolveContrastColor(); - int iconColor; - if (showLargeIcon) { - contentView.setDrawableTint(R.id.reply_icon_action, - true /* targetBackground */, - contrastColor, PorterDuff.Mode.SRC_ATOP); - contentView.setOnClickPendingIntent(R.id.right_icon, - action.actionIntent); - contentView.setRemoteInputs(R.id.right_icon, action.mRemoteInputs); - iconColor = NotificationColorUtil.isColorLight(contrastColor) - ? Color.BLACK : Color.WHITE; - } else { - contentView.setImageViewResource(R.id.right_icon, - R.drawable.ic_reply_notification_large); - contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); - iconColor = contrastColor; - } - contentView.setDrawableTint(replyId, + 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 */, - iconColor, + getPrimaryTextColor(), PorterDuff.Mode.SRC_ATOP); - contentView.setOnClickPendingIntent(replyId, - action.actionIntent); - contentView.setRemoteInputs(replyId, action.mRemoteInputs); + contentView.setOnClickPendingIntent(R.id.reply_icon_action, action.actionIntent); + contentView.setRemoteInputs(R.id.reply_icon_action, action.mRemoteInputs); } else { - contentView.setRemoteInputs(R.id.right_icon, null); + contentView.setRemoteInputs(R.id.reply_icon_action, null); } - contentView.setViewVisibility(R.id.reply_icon_action, actionVisible && showLargeIcon - ? View.VISIBLE - : View.GONE); - contentView.setViewVisibility(R.id.right_icon_container, actionVisible || showLargeIcon - ? View.VISIBLE - : View.GONE); + contentView.setViewVisibility(R.id.reply_icon_action, + actionVisible ? View.VISIBLE : View.GONE); + return actionVisible; } private Action findReplyAction() { @@ -4770,13 +4775,15 @@ public class Notification implements Parcelable R.dimen.notification_content_margin); } - private RemoteViews applyStandardTemplateWithActions(int layoutId) { - return applyStandardTemplateWithActions(layoutId, mParams.reset().fillTextsFrom(this)); + private RemoteViews applyStandardTemplateWithActions(int layoutId, + TemplateBindResult result) { + return applyStandardTemplateWithActions(layoutId, mParams.reset().fillTextsFrom(this), + result); } private RemoteViews applyStandardTemplateWithActions(int layoutId, - StandardTemplateParams p) { - RemoteViews big = applyStandardTemplate(layoutId, p); + StandardTemplateParams p, TemplateBindResult result) { + RemoteViews big = applyStandardTemplate(layoutId, p, result); resetStandardTemplateWithActions(big); @@ -4883,7 +4890,7 @@ public class Notification implements Parcelable return styleView; } } - return applyStandardTemplate(getBaseLayoutResource()); + return applyStandardTemplate(getBaseLayoutResource(), null /* result */); } private boolean useExistingRemoteView() { @@ -4902,7 +4909,8 @@ public class Notification implements Parcelable result = mStyle.makeBigContentView(); hideLine1Text(result); } else if (mActions.size() != 0) { - result = applyStandardTemplateWithActions(getBigBaseLayoutResource()); + result = applyStandardTemplateWithActions(getBigBaseLayoutResource(), + null /* result */); } makeHeaderExpanded(result); return result; @@ -4939,7 +4947,8 @@ public class Notification implements Parcelable public RemoteViews makeAmbientNotification() { RemoteViews ambient = applyStandardTemplateWithActions( R.layout.notification_template_material_ambient, - mParams.reset().ambient(true).fillTextsFrom(this).hasProgress(false)); + mParams.reset().ambient(true).fillTextsFrom(this).hasProgress(false), + null /* result */); return ambient; } @@ -4982,7 +4991,7 @@ public class Notification implements Parcelable return null; } - return applyStandardTemplateWithActions(getBigBaseLayoutResource()); + return applyStandardTemplateWithActions(getBigBaseLayoutResource(), null /* result */); } /** @@ -5863,6 +5872,18 @@ public class Notification implements Parcelable } protected RemoteViews getStandardView(int layoutId) { + return getStandardView(layoutId, null); + } + + /** + * Get the standard view for this style. + * + * @param layoutId The layout id to use + * @param result The result where template bind information is saved. + * @return A remoteView for this style. + * @hide + */ + protected RemoteViews getStandardView(int layoutId, TemplateBindResult result) { checkBuilder(); // Nasty. @@ -5872,7 +5893,7 @@ public class Notification implements Parcelable mBuilder.setContentTitle(mBigContentTitle); } - RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId); + RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId, result); mBuilder.getAllExtras().putCharSequence(EXTRA_TITLE, oldBuilderContentTitle); @@ -6169,7 +6190,8 @@ public class Notification implements Parcelable mBuilder.mN.largeIcon = null; } - RemoteViews contentView = getStandardView(mBuilder.getBigPictureLayoutResource()); + RemoteViews contentView = getStandardView(mBuilder.getBigPictureLayoutResource(), + null /* result */); if (mSummaryTextSet) { contentView.setTextViewText(R.id.text, mBuilder.processTextSpans( mBuilder.processLegacyText(mSummaryText))); @@ -6356,7 +6378,9 @@ public class Notification implements Parcelable CharSequence text = mBuilder.getAllExtras().getCharSequence(EXTRA_TEXT); mBuilder.getAllExtras().putCharSequence(EXTRA_TEXT, null); - RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource()); + TemplateBindResult result = new TemplateBindResult(); + RemoteViews contentView = getStandardView(mBuilder.getBigTextLayoutResource(), result); + contentView.setInt(R.id.big_text, "setImageEndMarginDimen", result.getIconMarginEndDimen()); mBuilder.getAllExtras().putCharSequence(EXTRA_TEXT, text); @@ -6739,7 +6763,7 @@ public class Notification implements Parcelable mBuilder.mOriginalActions = mBuilder.mActions; mBuilder.mActions = new ArrayList<>(); RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, - true /* showReplyIcon */); + false /* hideLargeIcon */); mBuilder.mActions = mBuilder.mOriginalActions; mBuilder.mOriginalActions = null; return remoteViews; @@ -6826,7 +6850,7 @@ public class Notification implements Parcelable */ @Override public RemoteViews makeBigContentView() { - return makeMessagingView(false /* displayImagesAtEnd */, false /* showReplyIcon */); + return makeMessagingView(false /* displayImagesAtEnd */, true /* hideLargeIcon */); } /** @@ -6834,11 +6858,11 @@ public class Notification implements Parcelable * * @param displayImagesAtEnd should images be displayed at the end of the content instead * of inline. - * @param showReplyIcon Should the reply affordance be shown at the end of the notification + * @param hideRightIcons Should the reply affordance be shown at the end of the notification * @return the created remoteView. */ @NonNull - private RemoteViews makeMessagingView(boolean displayImagesAtEnd, boolean showReplyIcon) { + private RemoteViews makeMessagingView(boolean displayImagesAtEnd, boolean hideRightIcons) { CharSequence conversationTitle = !TextUtils.isEmpty(super.mBigContentTitle) ? super.mBigContentTitle : mConversationTitle; @@ -6849,20 +6873,18 @@ public class Notification implements Parcelable nameReplacement = conversationTitle; conversationTitle = null; } - boolean hideLargeIcon = !showReplyIcon || isOneToOne; + TemplateBindResult bindResult = new TemplateBindResult(); RemoteViews contentView = mBuilder.applyStandardTemplateWithActions( mBuilder.getMessagingLayoutResource(), mBuilder.mParams.reset().hasProgress(false).title(conversationTitle).text(null) - .hideLargeIcon(hideLargeIcon) - .headerTextSecondary(conversationTitle) - .alwaysShowReply(showReplyIcon)); + .hideLargeIcon(hideRightIcons || isOneToOne) + .hideReplyIcon(hideRightIcons) + .headerTextSecondary(conversationTitle), + bindResult); addExtras(mBuilder.mN.extras); // also update the end margin if there is an image - int endMargin = R.dimen.notification_content_margin_end; - if (showReplyIcon) { - endMargin = R.dimen.notification_content_plus_picture_margin_end; - } - contentView.setViewLayoutMarginEndDimen(R.id.notification_main_column, endMargin); + contentView.setViewLayoutMarginEndDimen(R.id.notification_main_column, + bindResult.getIconMarginEndDimen()); contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor", mBuilder.resolveContrastColor()); contentView.setBoolean(R.id.status_bar_latest_event_content, "setDisplayImagesAtEnd", @@ -6934,7 +6956,7 @@ public class Notification implements Parcelable @Override public RemoteViews makeHeadsUpContentView(boolean increasedHeight) { RemoteViews remoteViews = makeMessagingView(true /* displayImagesAtEnd */, - false /* showReplyIcon */); + true /* hideLargeIcon */); remoteViews.setInt(R.id.notification_messaging, "setMaxDisplayedLines", 1); return remoteViews; } @@ -7275,7 +7297,8 @@ public class Notification implements Parcelable CharSequence oldBuilderContentText = mBuilder.mN.extras.getCharSequence(EXTRA_TEXT); mBuilder.getAllExtras().putCharSequence(EXTRA_TEXT, null); - RemoteViews contentView = getStandardView(mBuilder.getInboxLayoutResource()); + TemplateBindResult result = new TemplateBindResult(); + RemoteViews contentView = getStandardView(mBuilder.getInboxLayoutResource(), result); mBuilder.getAllExtras().putCharSequence(EXTRA_TEXT, oldBuilderContentText); @@ -7304,7 +7327,8 @@ public class Notification implements Parcelable mBuilder.processTextSpans(mBuilder.processLegacyText(str))); mBuilder.setTextViewColorSecondary(contentView, rowIds[i]); contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0); - handleInboxImageMargin(contentView, rowIds[i], first); + handleInboxImageMargin(contentView, rowIds[i], first, + result.getIconMarginEndDimen()); if (first) { onlyViewId = rowIds[i]; } else { @@ -7336,14 +7360,15 @@ public class Notification implements Parcelable return !Objects.equals(getLines(), newS.getLines()); } - private void handleInboxImageMargin(RemoteViews contentView, int id, boolean first) { + private void handleInboxImageMargin(RemoteViews contentView, int id, boolean first, + int marginEndDimen) { 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 (mBuilder.mN.hasLargeIcon() && !hasProgress) { - endMargin = R.dimen.notification_content_picture_margin; + if (!hasProgress) { + endMargin = marginEndDimen; } } contentView.setViewLayoutMarginEndDimen(id, endMargin); @@ -7535,7 +7560,8 @@ public class Notification implements Parcelable private RemoteViews makeMediaContentView() { RemoteViews view = mBuilder.applyStandardTemplate( - R.layout.notification_template_material_media, false /* hasProgress */); + R.layout.notification_template_material_media, false, /* hasProgress */ + null /* result */); final int numActions = mBuilder.mActions.size(); final int N = mActionsToShowInCompact == null @@ -7559,7 +7585,7 @@ public class Notification implements Parcelable // handle the content margin int endMargin = R.dimen.notification_content_margin_end; if (mBuilder.mN.hasLargeIcon()) { - endMargin = R.dimen.notification_content_plus_picture_margin_end; + endMargin = R.dimen.notification_media_image_margin_end; } view.setViewLayoutMarginEndDimen(R.id.notification_main_column, endMargin); return view; @@ -7580,8 +7606,7 @@ public class Notification implements Parcelable return null; } RemoteViews big = mBuilder.applyStandardTemplate( - R.layout.notification_template_material_big_media, - false); + R.layout.notification_template_material_big_media, false, null /* result */); if (actionCount > 0) { big.removeAllViews(com.android.internal.R.id.media_actions); @@ -7677,16 +7702,18 @@ public class Notification implements Parcelable if (mBuilder.mActions.size() == 0) { return makeStandardTemplateWithCustomContent(headsUpContentView); } + TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource()); - buildIntoRemoteViewContent(remoteViews, headsUpContentView); + mBuilder.getBigBaseLayoutResource(), result); + buildIntoRemoteViewContent(remoteViews, headsUpContentView, result); return remoteViews; } private RemoteViews makeStandardTemplateWithCustomContent(RemoteViews customContent) { + TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplate( - mBuilder.getBaseLayoutResource()); - buildIntoRemoteViewContent(remoteViews, customContent); + mBuilder.getBaseLayoutResource(), result); + buildIntoRemoteViewContent(remoteViews, customContent, result); return remoteViews; } @@ -7697,14 +7724,15 @@ public class Notification implements Parcelable if (mBuilder.mActions.size() == 0) { return makeStandardTemplateWithCustomContent(bigContentView); } + TemplateBindResult result = new TemplateBindResult(); RemoteViews remoteViews = mBuilder.applyStandardTemplateWithActions( - mBuilder.getBigBaseLayoutResource()); - buildIntoRemoteViewContent(remoteViews, bigContentView); + mBuilder.getBigBaseLayoutResource(), result); + buildIntoRemoteViewContent(remoteViews, bigContentView, result); return remoteViews; } private void buildIntoRemoteViewContent(RemoteViews remoteViews, - RemoteViews customContent) { + RemoteViews customContent, TemplateBindResult result) { if (customContent != null) { // Need to clone customContent before adding, because otherwise it can no longer be // parceled independently of remoteViews. @@ -7714,11 +7742,14 @@ public class Notification implements Parcelable remoteViews.setReapplyDisallowed(); } // also update the end margin if there is an image - int endMargin = R.dimen.notification_content_margin_end; - if (mBuilder.mN.hasLargeIcon()) { - endMargin = R.dimen.notification_content_plus_picture_margin_end; + Resources resources = mBuilder.mContext.getResources(); + int endMargin = resources.getDimensionPixelSize( + R.dimen.notification_content_margin_end); + int marginEndDimen = result.getIconMarginEndDimen(); + if (marginEndDimen != 0) { + endMargin += resources.getDimensionPixelSize(marginEndDimen); } - remoteViews.setViewLayoutMarginEndDimen(R.id.notification_main_column, endMargin); + remoteViews.setViewLayoutMarginEnd(R.id.notification_main_column, endMargin); } /** @@ -9322,6 +9353,25 @@ public class Notification implements Parcelable } } + /** + * A result object where information about the template that was created is saved. + */ + private static class TemplateBindResult { + int mIconMarginEndDimen; + + /** + * Get the margin end dimension that needs to be added to any fields that may overlap + * with the right actions. + */ + public int getIconMarginEndDimen() { + return mIconMarginEndDimen; + } + + public void setIconMarginEndDimen(int iconMarginEndDimen) { + this.mIconMarginEndDimen = iconMarginEndDimen; + } + } + private static class StandardTemplateParams { boolean hasProgress = true; boolean ambient = false; @@ -9329,7 +9379,7 @@ public class Notification implements Parcelable CharSequence text; CharSequence headerTextSecondary; boolean hideLargeIcon; - public boolean alwaysShowReply; + boolean hideReplyIcon; final StandardTemplateParams reset() { hasProgress = true; @@ -9360,13 +9410,13 @@ public class Notification implements Parcelable return this; } - final StandardTemplateParams alwaysShowReply(boolean alwaysShowReply) { - this.alwaysShowReply = alwaysShowReply; + final StandardTemplateParams hideLargeIcon(boolean hideLargeIcon) { + this.hideLargeIcon = hideLargeIcon; return this; } - final StandardTemplateParams hideLargeIcon(boolean hideLargeIcon) { - this.hideLargeIcon = hideLargeIcon; + final StandardTemplateParams hideReplyIcon(boolean hideReplyIcon) { + this.hideReplyIcon = hideReplyIcon; return this; } diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index b6bd14ed5efd..ff9daee180bf 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -1999,6 +1999,7 @@ public class RemoteViews implements Parcelable, Filter { /** Set width */ public static final int LAYOUT_WIDTH = 2; public static final int LAYOUT_MARGIN_BOTTOM_DIMEN = 3; + public static final int LAYOUT_MARGIN_END = 4; final int mProperty; final int mValue; @@ -2036,11 +2037,14 @@ public class RemoteViews implements Parcelable, Filter { if (layoutParams == null) { return; } + int value = mValue; switch (mProperty) { case LAYOUT_MARGIN_END_DIMEN: + value = resolveDimenPixelOffset(target, mValue); + // fall-through + case LAYOUT_MARGIN_END: if (layoutParams instanceof ViewGroup.MarginLayoutParams) { - int resolved = resolveDimenPixelOffset(target, mValue); - ((ViewGroup.MarginLayoutParams) layoutParams).setMarginEnd(resolved); + ((ViewGroup.MarginLayoutParams) layoutParams).setMarginEnd(value); target.setLayoutParams(layoutParams); } break; @@ -2980,6 +2984,20 @@ public class RemoteViews implements Parcelable, Filter { } /** + * Equivalent to calling {@link android.view.ViewGroup.MarginLayoutParams#setMarginEnd(int)}. + * Only works if the {@link View#getLayoutParams()} supports margins. + * Hidden for now since we don't want to support this for all different layout margins yet. + * + * @param viewId The id of the view to change + * @param endMargin a value in pixels for the end margin. + * @hide + */ + public void setViewLayoutMarginEnd(int viewId, @DimenRes int endMargin) { + addAction(new LayoutParamAction(viewId, LayoutParamAction.LAYOUT_MARGIN_END, + endMargin)); + } + + /** * Equivalent to setting {@link android.view.ViewGroup.MarginLayoutParams#bottomMargin}. * * @param bottomMarginDimen a dimen resource to read the margin from or 0 to clear the margin. diff --git a/core/java/com/android/internal/widget/ImageFloatingTextView.java b/core/java/com/android/internal/widget/ImageFloatingTextView.java index 09f7282f097a..eb8e48057638 100644 --- a/core/java/com/android/internal/widget/ImageFloatingTextView.java +++ b/core/java/com/android/internal/widget/ImageFloatingTextView.java @@ -47,6 +47,7 @@ public class ImageFloatingTextView extends TextView { private boolean mFirstMeasure = true; private int mLayoutMaxLines = -1; private boolean mBlockLayouts; + private int mImageEndMargin; public ImageFloatingTextView(Context context) { this(context, null); @@ -98,13 +99,11 @@ public class ImageFloatingTextView extends TextView { } // we set the endmargin on the requested number of lines. - int endMargin = getContext().getResources().getDimensionPixelSize( - R.dimen.notification_content_picture_margin); int[] margins = null; if (mIndentLines > 0) { margins = new int[mIndentLines + 1]; for (int i = 0; i < mIndentLines; i++) { - margins[i] = endMargin; + margins[i] = mImageEndMargin; } } if (mResolvedDirection == LAYOUT_DIRECTION_RTL) { @@ -116,6 +115,15 @@ public class ImageFloatingTextView extends TextView { return builder.build(); } + @RemotableViewMethod + public void setImageEndMarginDimen(int imageEndMargin) { + if (imageEndMargin != 0) { + mImageEndMargin = getContext().getResources().getDimensionPixelSize(imageEndMargin); + } else { + mImageEndMargin = 0; + } + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = MeasureSpec.getSize(heightMeasureSpec); diff --git a/core/res/res/drawable/ic_reply_notification.xml b/core/res/res/drawable/ic_reply_notification.xml index 88b8c5b7ddef..e75afddfead3 100644 --- a/core/res/res/drawable/ic_reply_notification.xml +++ b/core/res/res/drawable/ic_reply_notification.xml @@ -13,15 +13,17 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="10dp" - android:height="10dp" - android:viewportWidth="24.0" - android:viewportHeight="24.0"> - <path - android:fillColor="#FFFFFFFF" - android:pathData="M10.0,9.0L10.0,5.0l-7.0,7.0 7.0,7.0l0.0,-4.1c5.0,0.0 8.5,1.6 11.0,5.1 -1.0,-5.0 -4.0,-10.0 -11.0,-11.0z"/> - <path - android:pathData="M0 0h24v24H0z" - android:fillColor="#00000000"/> -</vector> +<inset xmlns:android="http://schemas.android.com/apk/res/android" + android:inset="8dp"> + <vector android:width="24dp" + android:height="24dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0"> + <path + android:fillColor="#FFFFFFFF" + android:pathData="M10.0,9.0L10.0,5.0l-7.0,7.0 7.0,7.0l0.0,-4.1c5.0,0.0 8.5,1.6 11.0,5.1 -1.0,-5.0 -4.0,-10.0 -11.0,-11.0z"/> + <path + android:fillColor="#00000000" + android:pathData="M0 0h24v24H0z"/> + </vector> +</inset> diff --git a/core/res/res/drawable/ic_reply_notification_large.xml b/core/res/res/drawable/ic_reply_notification_large.xml deleted file mode 100644 index e75afddfead3..000000000000 --- a/core/res/res/drawable/ic_reply_notification_large.xml +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - ~ Copyright (C) 2017 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 - --> -<inset xmlns:android="http://schemas.android.com/apk/res/android" - android:inset="8dp"> - <vector android:width="24dp" - android:height="24dp" - android:viewportHeight="24.0" - android:viewportWidth="24.0"> - <path - android:fillColor="#FFFFFFFF" - android:pathData="M10.0,9.0L10.0,5.0l-7.0,7.0 7.0,7.0l0.0,-4.1c5.0,0.0 8.5,1.6 11.0,5.1 -1.0,-5.0 -4.0,-10.0 -11.0,-11.0z"/> - <path - android:fillColor="#00000000" - android:pathData="M0 0h24v24H0z"/> - </vector> -</inset> diff --git a/core/res/res/drawable/notification_reply_background.xml b/core/res/res/drawable/notification_reply_background.xml deleted file mode 100644 index 08e22f2f9729..000000000000 --- a/core/res/res/drawable/notification_reply_background.xml +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - ~ Copyright (C) 2017 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 - --> - -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="oval"> - <solid - android:color="#ff757575"/> - <size - android:width="16dp" - android:height="16dp"/> -</shape> diff --git a/core/res/res/layout/notification_template_right_icon.xml b/core/res/res/layout/notification_template_right_icon.xml index 0b97e45b8eed..ee416ad36b8a 100644 --- a/core/res/res/layout/notification_template_right_icon.xml +++ b/core/res/res/layout/notification_template_right_icon.xml @@ -14,30 +14,29 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<!-- The view only has 8dp padding at the end instead of notification_content_margin_end, + since the reply icon has an inset of 8dp and we want it to visually start at the start of the + icon. --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/right_icon_container" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/notification_content_margin_top" + android:layout_marginEnd="8dp" android:layout_gravity="top|end"> <ImageView android:id="@+id/right_icon" android:layout_width="@dimen/notification_right_icon_size" android:layout_height="@dimen/notification_right_icon_size" android:layout_gravity="top|end" - android:layout_marginEnd="@dimen/notification_content_margin_end" + android:layout_marginEnd="8dp" android:scaleType="centerCrop" android:importantForAccessibility="no" /> - <ImageButton android:id="@+id/reply_icon_action" - android:layout_width="16dp" - android:layout_height="16dp" - android:layout_gravity="top|end" - android:layout_marginTop="27dp" - android:layout_marginEnd="16dp" - android:background="@drawable/notification_reply_background" - android:src="@drawable/ic_reply_notification" - android:scaleType="center" - android:contentDescription="@string/notification_reply_button_accessibility" - visiblity="gone"/> -</FrameLayout> + <ImageView android:id="@+id/reply_icon_action" + android:layout_width="@dimen/notification_right_icon_size" + android:layout_height="@dimen/notification_right_icon_size" + android:layout_gravity="top|end" + android:contentDescription="@string/notification_reply_button_accessibility" + android:scaleType="centerCrop" + android:src="@drawable/ic_reply_notification"/> +</LinearLayout> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index a135b28c196a..08e2f455cacf 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -162,19 +162,17 @@ <!-- The margin on the start of the content view --> <dimen name="notification_content_margin_start">16dp</dimen> - <!-- The margin on the end of the content view - Keep in sync with notification_content_plus_picture_margin! --> + <!-- The margin on the end of the content view. --> <dimen name="notification_content_margin_end">16dp</dimen> - <!-- The margin on the end of the content view with a picture. - Keep in sync with notification_content_plus_picture_margin! --> + <!-- The margin on the end of the content view with a picture. --> <dimen name="notification_content_picture_margin">56dp</dimen> - <!-- The margin on the end of the content view with a picture, plus the standard - content end margin. - Keep equal to (notification_content_picture_margin + notification_content_margin_end)! - --> - <dimen name="notification_content_plus_picture_margin_end">72dp</dimen> + <!-- The margin on the end of the content view with a picture and a reply button --> + <dimen name="notification_content_picture_and_reply_margin">92dp</dimen> + + <!-- The margin for text at the end of the image view for media notifications --> + <dimen name="notification_media_image_margin_end">72dp</dimen> <!-- The additional margin on the sides of the ambient view. --> <dimen name="notification_extra_margin_ambient">16dp</dimen> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 590f98800874..3ee333cadadc 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2690,6 +2690,7 @@ <java-symbol type="dimen" name="notification_content_margin_start" /> <java-symbol type="dimen" name="notification_content_margin_end" /> <java-symbol type="dimen" name="notification_content_picture_margin" /> + <java-symbol type="dimen" name="notification_content_picture_and_reply_margin" /> <java-symbol type="dimen" name="notification_content_margin_top" /> <java-symbol type="dimen" name="notification_content_margin" /> <java-symbol type="dimen" name="notification_header_background_height" /> @@ -2873,7 +2874,7 @@ <java-symbol type="bool" name="config_supportPreRebootSecurityLogs" /> - <java-symbol type="dimen" name="notification_content_plus_picture_margin_end" /> + <java-symbol type="dimen" name="notification_media_image_margin_end" /> <java-symbol type="id" name="notification_action_list_margin_target" /> <!-- Pinner Service --> @@ -3252,7 +3253,6 @@ <java-symbol type="id" name="clip_children_set_tag" /> <java-symbol type="id" name="clip_to_padding_tag" /> <java-symbol type="id" name="clip_children_tag" /> - <java-symbol type="drawable" name="ic_reply_notification_large" /> <java-symbol type="dimen" name="messaging_avatar_size" /> <java-symbol type="dimen" name="messaging_image_rounding" /> <java-symbol type="dimen" name="messaging_image_min_size" /> |