Improved the headsup notification for messages
Previously the heads up notifications and also the collapsed versions were not
displaying in the new style.
They are now displayed in the new style of heads up notifications.
Test: add messaging notification in heads up
Bug: 63708826
Change-Id: I041584cd6ee740fd8c59f332f727ed83c89e777f
diff --git a/core/java/com/android/internal/widget/MessagingLinearLayout.java b/core/java/com/android/internal/widget/MessagingLinearLayout.java
index e050d45..8428e8c 100644
--- a/core/java/com/android/internal/widget/MessagingLinearLayout.java
+++ b/core/java/com/android/internal/widget/MessagingLinearLayout.java
@@ -42,12 +42,7 @@
*/
private int mSpacing;
- /**
- * The maximum height allowed.
- */
- private int mMaxHeight;
-
- private int mIndentLines;
+ private int mMaxDisplayedLines = Integer.MAX_VALUE;
/**
* Id of the child that's also visible in the contracted layout.
@@ -111,6 +106,7 @@
totalHeight = mPaddingTop + mPaddingBottom;
boolean first = true;
+ int linesRemaining = mMaxDisplayedLines;
// Starting from the bottom: we measure every view as if it were the only one. If it still
@@ -121,7 +117,11 @@
}
final View child = getChildAt(i);
LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams();
-
+ MessagingChild messagingChild = null;
+ if (child instanceof MessagingChild) {
+ messagingChild = (MessagingChild) child;
+ messagingChild.setMaxDisplayedLines(linesRemaining);
+ }
int spacing = first ? 0 : mSpacing;
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, totalHeight
- mPaddingTop - mPaddingBottom + spacing);
@@ -131,8 +131,8 @@
lp.bottomMargin + spacing);
first = false;
int measureType = MessagingChild.MEASURED_NORMAL;
- if (child instanceof MessagingChild) {
- measureType = ((MessagingChild) child).getMeasuredType();
+ if (messagingChild != null) {
+ measureType = messagingChild.getMeasuredType();
linesRemaining -= messagingChild.getConsumedLines();
}
boolean isShortened = measureType == MessagingChild.MEASURED_SHORTENED;
@@ -143,7 +143,7 @@
child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin
+ mPaddingLeft + mPaddingRight);
lp.hide = false;
- if (isShortened) {
+ if (isShortened || linesRemaining <= 0) {
break;
}
} else {
@@ -239,21 +239,21 @@
}
/**
- * Sets how many lines should be indented to avoid a floating image.
+ * Sets how many lines should be displayed at most
*/
@RemotableViewMethod
- public boolean setNumIndentLines(int numberLines) {
- boolean changed = numberLines != mIndentLines;
- mIndentLines = numberLines;
- return changed;
+ public void setMaxDisplayedLines(int numberLines) {
+ mMaxDisplayedLines = numberLines;
}
public interface MessagingChild {
int MEASURED_NORMAL = 0;
int MEASURED_SHORTENED = 1;
int MEASURED_TOO_SMALL = 2;
+
int getMeasuredType();
int getConsumedLines();
+ void setMaxDisplayedLines(int lines);
}
public static class LayoutParams extends MarginLayoutParams {