From f2f481f256d580c885b95a75801eeeebee684a85 Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Fri, 8 Sep 2023 11:57:39 +0000 Subject: 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 --- .../com/android/internal/widget/ImageFloatingTextView.java | 10 ++++++++++ core/res/res/values/config.xml | 5 +++++ core/res/res/values/symbols.xml | 1 + 3 files changed, 16 insertions(+) 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 @@ 100 + + 10 + false 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 @@ + -- cgit v1.2.3-59-g8ed1b