summaryrefslogtreecommitdiffstats
path: root/core/java/android/text
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2015-06-10 09:37:32 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2015-06-15 16:34:53 +0900
commitf4a3f3a03c72b6a38dc2f3f965531dc2a12460df (patch)
tree1100ec572ba5ed280167034d02e730c0759a2685 /core/java/android/text
parent4ba81a0878d058734e9eb2c298d7fc4df7e597ed (diff)
downloadframeworks_base-f4a3f3a03c72b6a38dc2f3f965531dc2a12460df.zip
frameworks_base-f4a3f3a03c72b6a38dc2f3f965531dc2a12460df.tar.gz
frameworks_base-f4a3f3a03c72b6a38dc2f3f965531dc2a12460df.tar.bz2
Fix: Ellipsis is wrongly applied or not applied in TextView.
In current implementation, ellipsis is applied after coptuting line breaks without limiting line count. As a result, ellipsis can be skipped or- wrongly applied because the breaks are computed to fit with the width. With this change, the last line and overflowed part are treated as a single line when the number of breaks exceeds the remaining line count. Bug: 6615676 Bug: 18514378 Bug: 20177499 Change-Id: I1d90e299404960cdd22746bad572411b119f7360
Diffstat (limited to 'core/java/android/text')
-rw-r--r--core/java/android/text/StaticLayout.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 464710b..b6fa4e4c 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -714,6 +714,27 @@ public class StaticLayout extends Layout {
float[] lineWidths = lineBreaks.widths;
int[] flags = lineBreaks.flags;
+ final int remainingLineCount = mMaximumVisibleLineCount - mLineCount;
+ final boolean ellipsisMayBeApplied = ellipsize != null
+ && (ellipsize == TextUtils.TruncateAt.END
+ || (mMaximumVisibleLineCount == 1
+ && ellipsize != TextUtils.TruncateAt.MARQUEE));
+ if (remainingLineCount < breakCount && ellipsisMayBeApplied) {
+ // Treat the last line and overflowed lines as a single line.
+ breaks[remainingLineCount - 1] = breaks[breakCount - 1];
+ // Calculate width and flag.
+ float width = 0;
+ int flag = 0;
+ for (int i = remainingLineCount - 1; i < breakCount; i++) {
+ width += lineWidths[i];
+ flag |= flags[i] & TAB_MASK;
+ }
+ lineWidths[remainingLineCount - 1] = width;
+ flags[remainingLineCount - 1] = flag;
+
+ breakCount = remainingLineCount;
+ }
+
// here is the offset of the starting character of the line we are currently measuring
int here = paraStart;