summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ibrahim Yilmaz <iyz@google.com> 2023-09-08 11:57:39 +0000
committer Ibrahim Yilmaz <iyz@google.com> 2024-03-18 19:23:47 +0000
commitf2f481f256d580c885b95a75801eeeebee684a85 (patch)
tree4cff24b5cb1fcbb601bb8da5b527fc4b6771a324
parent6ea0cc1e4c1d5c2161dee0314e4ef82e1802cce8 (diff)
Limit ImageFloatingTextView maxLine to 10
ImageFloatingTextView is used in Notifications to render Notification content. IFTV adjust its maxLine and apply ellipsize when needed based on the available height. While notification height is limited, ImageFloatingTextView's first StaticLayout creation calculates the line beyond the available height. This CL limits maxLine to 10 when max limit is enabled. Bug: 298610449 Test: SystemUITests Change-Id: Ic79bb9734cdbcbee25d06a271042337137007788
-rw-r--r--core/java/com/android/internal/widget/ImageFloatingTextView.java10
-rw-r--r--core/res/res/values/config.xml5
-rw-r--r--core/res/res/values/symbols.xml1
3 files changed, 16 insertions, 0 deletions
diff --git a/core/java/com/android/internal/widget/ImageFloatingTextView.java b/core/java/com/android/internal/widget/ImageFloatingTextView.java
index 5da64350619c..352e6d8e7b59 100644
--- a/core/java/com/android/internal/widget/ImageFloatingTextView.java
+++ b/core/java/com/android/internal/widget/ImageFloatingTextView.java
@@ -31,6 +31,8 @@ import android.view.RemotableViewMethod;
import android.widget.RemoteViews;
import android.widget.TextView;
+import com.android.internal.R;
+
/**
* A TextView that can float around an image on the end.
*
@@ -49,6 +51,7 @@ public class ImageFloatingTextView extends TextView {
private int mMaxLinesForHeight = -1;
private int mLayoutMaxLines = -1;
private int mImageEndMargin;
+ private final int mMaxLineUpperLimit;
private int mStaticLayoutCreationCountInOnMeasure = 0;
@@ -71,6 +74,8 @@ public class ImageFloatingTextView extends TextView {
super(context, attrs, defStyleAttr, defStyleRes);
setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL_FAST);
setBreakStrategy(Layout.BREAK_STRATEGY_HIGH_QUALITY);
+ mMaxLineUpperLimit =
+ getResources().getInteger(R.integer.config_notificationLongTextMaxLineCount);
}
@Override
@@ -102,6 +107,11 @@ public class ImageFloatingTextView extends TextView {
} else {
maxLines = getMaxLines() >= 0 ? getMaxLines() : Integer.MAX_VALUE;
}
+
+ if (mMaxLineUpperLimit > 0) {
+ maxLines = Math.min(maxLines, mMaxLineUpperLimit);
+ }
+
builder.setMaxLines(maxLines);
mLayoutMaxLines = maxLines;
if (shouldEllipsize) {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index e3f1cb619eb5..efba7099d678 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1483,6 +1483,11 @@
<!-- Number of notifications to keep in the notification service historical archive -->
<integer name="config_notificationServiceArchiveSize">100</integer>
+ <!-- Upper limit imposed for long text content for BigTextStyle, MessagingStyle and
+ ConversationStyle notifications for performance reasons, and that line count is also
+ capped by vertical space available. It is only enabled when the value is positive int.-->
+ <integer name="config_notificationLongTextMaxLineCount">10</integer>
+
<!-- Allow the menu hard key to be disabled in LockScreen on some devices -->
<bool name="config_disableMenuKeyInLockScreen">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index f4b42f6b3fb2..668a88c4370a 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2078,6 +2078,7 @@
<java-symbol type="integer" name="config_notificationsBatteryMediumARGB" />
<java-symbol type="integer" name="config_notificationsBatteryNearlyFullLevel" />
<java-symbol type="integer" name="config_notificationServiceArchiveSize" />
+ <java-symbol type="integer" name="config_notificationLongTextMaxLineCount" />
<java-symbol type="dimen" name="config_rotaryEncoderAxisScrollTickInterval" />
<java-symbol type="integer" name="config_recentVibrationsDumpSizeLimit" />
<java-symbol type="integer" name="config_previousVibrationsDumpSizeLimit" />