From 0fb49d82a665997648d9d6737c6caf464c417905 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 13 May 2021 11:39:50 -0400 Subject: [PATCH] Set the height of the right_icon in addition to the width This ensures that the Notification fully specifies the size of the notification in the RemoteViews, and ensures that CTS tests pass. Fixes: 180652028 Test: atest NotificationTemplateApi30Test Change-Id: Ie5715880437f1e42b16226196cf67ca52bc09ee1 --- core/java/android/app/Notification.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index c6989ad4b694e..fc2c6ac7301ee 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5338,7 +5338,7 @@ public class Notification implements Parcelable } final float extraMarginEndDpIfVisible = viewWidthDp + iconMarginDp; result.setRightIconState(rightIcon != null /* visible */, viewWidthDp, - extraMarginEndDpIfVisible, expanderSizeDp); + viewHeightDp, extraMarginEndDpIfVisible, expanderSizeDp); } /** @@ -5375,6 +5375,8 @@ public class Notification implements Parcelable if (rightIcon != null) { contentView.setViewLayoutWidth(R.id.right_icon, result.mRightIconWidthDp, TypedValue.COMPLEX_UNIT_DIP); + contentView.setViewLayoutHeight(R.id.right_icon, + result.mRightIconHeightDp, TypedValue.COMPLEX_UNIT_DIP); contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); contentView.setImageViewIcon(R.id.right_icon, rightIcon); contentView.setIntTag(R.id.right_icon, R.id.tag_keep_when_showing_left_icon, @@ -12119,6 +12121,7 @@ public class Notification implements Parcelable private static class TemplateBindResult { boolean mRightIconVisible; float mRightIconWidthDp; + float mRightIconHeightDp; /** * The margin end that needs to be added to the heading so that it won't overlap @@ -12143,10 +12146,11 @@ public class Notification implements Parcelable */ public final MarginSet mTitleMarginSet = new MarginSet(); - public void setRightIconState(boolean visible, float widthDp, + public void setRightIconState(boolean visible, float widthDp, float heightDp, float marginEndDpIfVisible, float expanderSizeDp) { mRightIconVisible = visible; mRightIconWidthDp = widthDp; + mRightIconHeightDp = heightDp; mHeadingExtraMarginSet.setValues(0, marginEndDpIfVisible); mHeadingFullMarginSet.setValues(expanderSizeDp, marginEndDpIfVisible + expanderSizeDp); mTitleMarginSet.setValues(0, marginEndDpIfVisible + expanderSizeDp);