Fix bug #6661824 Hebrew Text can be clipped
- use the correct ellipsis char in both measurement and rendered string
Change-Id: Ia00285fc16da528f18702719026503b5d0610642
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index c453a5d..ba43aae 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -1695,8 +1695,14 @@
return text.getSpans(start, end, type);
}
+ private char getEllipsisChar(TextUtils.TruncateAt method) {
+ return (method == TextUtils.TruncateAt.END_SMALL) ?
+ ELLIPSIS_TWO_DOTS[0] :
+ ELLIPSIS_NORMAL[0];
+ }
+
private void ellipsize(int start, int end, int line,
- char[] dest, int destoff) {
+ char[] dest, int destoff, TextUtils.TruncateAt method) {
int ellipsisCount = getEllipsisCount(line);
if (ellipsisCount == 0) {
@@ -1710,7 +1716,7 @@
char c;
if (i == ellipsisStart) {
- c = '\u2026'; // ellipsis
+ c = getEllipsisChar(method); // ellipsis
} else {
c = '\uFEFF'; // 0-width space
}
@@ -1784,7 +1790,7 @@
TextUtils.getChars(mText, start, end, dest, destoff);
for (int i = line1; i <= line2; i++) {
- mLayout.ellipsize(start, end, i, dest, destoff);
+ mLayout.ellipsize(start, end, i, dest, destoff, mMethod);
}
}
@@ -1889,4 +1895,6 @@
/* package */ static final Directions DIRS_ALL_RIGHT_TO_LEFT =
new Directions(new int[] { 0, RUN_LENGTH_MASK | RUN_RTL_FLAG });
+ /* package */ static final char[] ELLIPSIS_NORMAL = { '\u2026' }; // this is "..."
+ /* package */ static final char[] ELLIPSIS_TWO_DOTS = { '\u2025' }; // this is ".."
}