Skip to content

Commit 46c78b4

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #5387832 [UI/Visual] Address of the website is not displayed properly(second line of the address is partly shown)"
2 parents 86b7349 + a130e5f commit 46c78b4

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

core/java/android/text/DynamicLayout.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public DynamicLayout(CharSequence base, CharSequence display,
7676
boolean includepad,
7777
TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
7878
this(base, display, paint, width, align, TextDirectionHeuristics.FIRSTSTRONG_LTR,
79-
spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth);
79+
spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth, Integer.MAX_VALUE);
8080
}
8181

8282
/**
@@ -93,7 +93,7 @@ public DynamicLayout(CharSequence base, CharSequence display,
9393
int width, Alignment align, TextDirectionHeuristic textDir,
9494
float spacingmult, float spacingadd,
9595
boolean includepad,
96-
TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
96+
TextUtils.TruncateAt ellipsize, int ellipsizedWidth, int maxLines) {
9797
super((ellipsize == null)
9898
? display
9999
: (display instanceof Spanned)
@@ -135,6 +135,8 @@ public DynamicLayout(CharSequence base, CharSequence display,
135135
mEllipsize = true;
136136
}
137137

138+
mMaxLines = maxLines;
139+
138140
// Initial state is a single line with 0 characters (0 to 0),
139141
// with top at 0 and bottom at whatever is natural, and
140142
// undefined ellipsis.
@@ -283,7 +285,7 @@ private void reflow(CharSequence s, int where, int before, int after) {
283285
reflowed.generate(text, where, where + after,
284286
getPaint(), getWidth(), getAlignment(), getTextDirectionHeuristic(),
285287
getSpacingMultiplier(), getSpacingAdd(),
286-
false, true, mEllipsizedWidth, mEllipsizeAt);
288+
false, true, mEllipsizedWidth, mEllipsizeAt, mMaxLines);
287289
int n = reflowed.getLineCount();
288290

289291
// If the new layout has a blank line at the end, but it is not
@@ -488,6 +490,8 @@ public int getEllipsisCount(int line) {
488490

489491
private int mTopPadding, mBottomPadding;
490492

493+
private int mMaxLines;
494+
491495
private static StaticLayout sStaticLayout = new StaticLayout(null);
492496

493497
private static final Object[] sLock = new Object[0];

core/java/android/text/StaticLayout.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public StaticLayout(CharSequence source, int bufstart, int bufend,
139139

140140
generate(source, bufstart, bufend, paint, outerwidth, align, textDir,
141141
spacingmult, spacingadd, includepad, includepad,
142-
ellipsizedWidth, ellipsize);
142+
ellipsizedWidth, ellipsize, mMaximumVisibleLineCount);
143143

144144
mMeasured = MeasuredText.recycle(mMeasured);
145145
mFontMetricsInt = null;
@@ -160,7 +160,7 @@ public StaticLayout(CharSequence source, int bufstart, int bufend,
160160
Alignment align, TextDirectionHeuristic textDir,
161161
float spacingmult, float spacingadd,
162162
boolean includepad, boolean trackpad,
163-
float ellipsizedWidth, TextUtils.TruncateAt ellipsize) {
163+
float ellipsizedWidth, TextUtils.TruncateAt ellipsize, int maxLines) {
164164
mLineCount = 0;
165165

166166
int v = 0;
@@ -477,13 +477,13 @@ public StaticLayout(CharSequence source, int bufstart, int bufend,
477477
width = restWidth;
478478
}
479479
}
480-
if (mLineCount >= mMaximumVisibleLineCount) {
480+
if (mLineCount >= maxLines) {
481481
break;
482482
}
483483
}
484484
}
485485

486-
if (paraEnd != here && mLineCount < mMaximumVisibleLineCount) {
486+
if (paraEnd != here && mLineCount < maxLines) {
487487
if ((fitTop | fitBottom | fitDescent | fitAscent) == 0) {
488488
paint.getFontMetricsInt(fm);
489489

@@ -514,7 +514,7 @@ public StaticLayout(CharSequence source, int bufstart, int bufend,
514514
}
515515

516516
if ((bufEnd == bufStart || source.charAt(bufEnd - 1) == CHAR_NEW_LINE) &&
517-
mLineCount < mMaximumVisibleLineCount) {
517+
mLineCount < maxLines) {
518518
// Log.e("text", "output last " + bufEnd);
519519

520520
paint.getFontMetricsInt(fm);

core/java/android/widget/TextView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6253,7 +6253,7 @@ private Layout makeSingleLayout(int w, BoringLayout.Metrics boring, int ellipsis
62536253
result = new DynamicLayout(mText, mTransformed, mTextPaint, w,
62546254
alignment, mTextDir, mSpacingMult,
62556255
mSpacingAdd, mIncludePad, mInput == null ? effectiveEllipsize : null,
6256-
ellipsisWidth);
6256+
ellipsisWidth, mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE);
62576257
} else {
62586258
if (boring == UNKNOWN_BORING) {
62596259
boring = BoringLayout.isBoring(mTransformed, mTextPaint, mTextDir, mBoring);

0 commit comments

Comments
 (0)