diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 870aed4dcb193..9212c14549393 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -933,6 +933,11 @@
14sp
6sp
+
+ 100dp
+
64dp
350dp
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 4256cd63dc4bf..8030bde2553b8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -80,6 +80,7 @@ public class NotificationContentView extends FrameLayout {
private RemoteInputView mHeadsUpRemoteInput;
private SmartReplyConstants mSmartReplyConstants;
+ private SmartReplyView mExpandedSmartReplyView;
private SmartReplyLogger mSmartReplyLogger;
private NotificationViewWrapper mContractedWrapper;
@@ -184,7 +185,11 @@ public class NotificationContentView extends FrameLayout {
}
int maxChildHeight = 0;
if (mExpandedChild != null) {
- int size = Math.min(maxSize, mNotificationMaxHeight);
+ int notificationMaxHeight = mNotificationMaxHeight;
+ if (mExpandedSmartReplyView != null) {
+ notificationMaxHeight += mExpandedSmartReplyView.getHeightUpperLimit();
+ }
+ int size = Math.min(maxSize, notificationMaxHeight);
ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
boolean useExactly = false;
if (layoutParams.height >= 0) {
@@ -1348,10 +1353,10 @@ public class NotificationContentView extends FrameLayout {
private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent,
NotificationData.Entry entry) {
if (mExpandedChild != null) {
- SmartReplyView view =
+ mExpandedSmartReplyView =
applySmartReplyView(mExpandedChild, remoteInput, pendingIntent, entry);
- if (view != null && remoteInput != null && remoteInput.getChoices() != null
- && remoteInput.getChoices().length > 0) {
+ if (mExpandedSmartReplyView != null && remoteInput != null
+ && remoteInput.getChoices() != null && remoteInput.getChoices().length > 0) {
mSmartReplyLogger.smartRepliesAdded(entry, remoteInput.getChoices().length);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index 4c79ee32f8e83..6d2f5ce77467e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -25,6 +25,7 @@ import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.SmartReplyLogger;
+import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import java.text.BreakIterator;
@@ -48,6 +49,12 @@ public class SmartReplyView extends ViewGroup {
private final SmartReplyConstants mConstants;
private final KeyguardDismissUtil mKeyguardDismissUtil;
+ /**
+ * The upper bound for the height of this view in pixels. Notifications are automatically
+ * recreated on density or font size changes so caching this should be fine.
+ */
+ private final int mHeightUpperLimit;
+
/** Spacing to be applied between views. */
private final int mSpacing;
@@ -69,6 +76,9 @@ public class SmartReplyView extends ViewGroup {
mConstants = Dependency.get(SmartReplyConstants.class);
mKeyguardDismissUtil = Dependency.get(KeyguardDismissUtil.class);
+ mHeightUpperLimit = NotificationUtils.getFontScaledHeight(mContext,
+ R.dimen.smart_reply_button_max_height);
+
int spacing = 0;
int singleLineButtonPaddingHorizontal = 0;
int doubleLineButtonPaddingHorizontal = 0;
@@ -98,10 +108,19 @@ public class SmartReplyView extends ViewGroup {
mSingleToDoubleLineButtonWidthIncrease =
2 * (doubleLineButtonPaddingHorizontal - singleLineButtonPaddingHorizontal);
+
mBreakIterator = BreakIterator.getLineInstance();
reallocateCandidateButtonQueueForSqueezing();
}
+ /**
+ * Returns an upper bound for the height of this view in pixels. This method is intended to be
+ * invoked before onMeasure, so it doesn't do any analysis on the contents of the buttons.
+ */
+ public int getHeightUpperLimit() {
+ return mHeightUpperLimit;
+ }
+
private void reallocateCandidateButtonQueueForSqueezing() {
// Instead of clearing the priority queue, we re-allocate so that it would fit all buttons
// exactly. This avoids (1) wasting memory because PriorityQueue never shrinks and