Skip to content

Commit 15c9c61

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #6661824 Hebrew Text can be clipped" into jb-dev
2 parents 9b1767b + 8d44fff commit 15c9c61

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

core/java/android/text/Layout.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,8 +1696,14 @@ protected final boolean isSpanned() {
16961696
return text.getSpans(start, end, type);
16971697
}
16981698

1699+
private char getEllipsisChar(TextUtils.TruncateAt method) {
1700+
return (method == TextUtils.TruncateAt.END_SMALL) ?
1701+
ELLIPSIS_TWO_DOTS[0] :
1702+
ELLIPSIS_NORMAL[0];
1703+
}
1704+
16991705
private void ellipsize(int start, int end, int line,
1700-
char[] dest, int destoff) {
1706+
char[] dest, int destoff, TextUtils.TruncateAt method) {
17011707
int ellipsisCount = getEllipsisCount(line);
17021708

17031709
if (ellipsisCount == 0) {
@@ -1711,7 +1717,7 @@ private void ellipsize(int start, int end, int line,
17111717
char c;
17121718

17131719
if (i == ellipsisStart) {
1714-
c = '\u2026'; // ellipsis
1720+
c = getEllipsisChar(method); // ellipsis
17151721
} else {
17161722
c = '\uFEFF'; // 0-width space
17171723
}
@@ -1785,7 +1791,7 @@ public void getChars(int start, int end, char[] dest, int destoff) {
17851791
TextUtils.getChars(mText, start, end, dest, destoff);
17861792

17871793
for (int i = line1; i <= line2; i++) {
1788-
mLayout.ellipsize(start, end, i, dest, destoff);
1794+
mLayout.ellipsize(start, end, i, dest, destoff, mMethod);
17891795
}
17901796
}
17911797

@@ -1890,4 +1896,6 @@ public enum Alignment {
18901896
/* package */ static final Directions DIRS_ALL_RIGHT_TO_LEFT =
18911897
new Directions(new int[] { 0, RUN_LENGTH_MASK | RUN_RTL_FLAG });
18921898

1899+
/* package */ static final char[] ELLIPSIS_NORMAL = { '\u2026' }; // this is "..."
1900+
/* package */ static final char[] ELLIPSIS_TWO_DOTS = { '\u2025' }; // this is ".."
18931901
}

core/java/android/text/StaticLayout.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ private void calculateEllipsis(int lineStart, int lineEnd,
745745
}
746746

747747
float ellipsisWidth = paint.measureText(
748-
(where == TextUtils.TruncateAt.END_SMALL) ? ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL);
748+
(where == TextUtils.TruncateAt.END_SMALL) ?
749+
ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL, 0, 1);
749750
int ellipsisStart = 0;
750751
int ellipsisCount = 0;
751752
int len = lineEnd - lineStart;
@@ -985,9 +986,6 @@ void finish() {
985986

986987
private static final double EXTRA_ROUNDING = 0.5;
987988

988-
private static final String ELLIPSIS_NORMAL = "\u2026"; // this is "..."
989-
private static final String ELLIPSIS_TWO_DOTS = "\u2025"; // this is ".."
990-
991989
private static final int CHAR_FIRST_HIGH_SURROGATE = 0xD800;
992990
private static final int CHAR_LAST_LOW_SURROGATE = 0xDFFF;
993991

0 commit comments

Comments
 (0)