diff options
author | Gilles Debunne <debunne@google.com> | 2011-01-04 17:15:14 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2011-01-04 18:05:53 -0800 |
commit | d434d2334d2362f77d3a3fb0b1f788f667039bbf (patch) | |
tree | 0b6b8e386b1eae5344d5455d37c7a248af22105d | |
parent | b1c36cdaf1f969af7895a8b2805273a85c0c16ca (diff) | |
download | frameworks_base-d434d2334d2362f77d3a3fb0b1f788f667039bbf.zip frameworks_base-d434d2334d2362f77d3a3fb0b1f788f667039bbf.tar.gz frameworks_base-d434d2334d2362f77d3a3fb0b1f788f667039bbf.tar.bz2 |
MaxLines is respected in TextViews, even when ellipsize is set to end.
Bug 3322607
Re-applying the revert that fixed the ANR (https://android-git.corp.google.com/g/#change,87129),
whith an updated here value that seems to fix the problem.
This layout code is pretty involved, with destabilizing variable names and
uses. Althought I tested it, this fix is not 100% garanteed.
Change-Id: I1f4b09b329fb8a328ae8ab26ae472e343453beda
-rw-r--r-- | api/current.xml | 38 | ||||
-rw-r--r-- | core/java/android/text/StaticLayout.java | 182 |
2 files changed, 111 insertions, 109 deletions
diff --git a/api/current.xml b/api/current.xml index f8f3f7c..042e96a 100644 --- a/api/current.xml +++ b/api/current.xml @@ -138921,7 +138921,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -138976,7 +138976,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -138987,7 +138987,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -138998,7 +138998,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -139244,7 +139244,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -139266,7 +139266,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -139343,7 +139343,7 @@ synchronized="false" static="true" final="false" - deprecated="deprecated" + deprecated="not deprecated" visibility="public" > </method> @@ -139387,7 +139387,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -139398,7 +139398,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -139409,7 +139409,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -139420,7 +139420,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -139524,7 +139524,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > </method> @@ -256491,7 +256491,7 @@ return="java.beans.PropertyChangeListener[]" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256504,7 +256504,7 @@ return="java.beans.PropertyChangeListener[]" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256515,7 +256515,7 @@ return="boolean" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256528,7 +256528,7 @@ return="void" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256543,7 +256543,7 @@ return="void" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256800,7 +256800,7 @@ return="void" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" @@ -256813,7 +256813,7 @@ return="void" abstract="false" native="false" - synchronized="false" + synchronized="true" static="false" final="false" deprecated="not deprecated" diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 3dd1ecd..43dce53 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -361,101 +361,103 @@ public class StaticLayout extends Layout if (fitbottom > okbottom) okbottom = fitbottom; } - } else if (breakOnlyAtSpaces) { - if (ok != here) { - // Log.e("text", "output ok " + here + " to " +ok); + } else { + if (breakOnlyAtSpaces) { + if (ok != here) { + // Log.e("text", "output ok " + here + " to " +ok); - while (ok < spanEnd && chs[ok - paraStart] == ' ') { - ok++; - } + while (ok < spanEnd && chs[ok - paraStart] == ' ') { + ok++; + } - v = out(source, - here, ok, - okascent, okdescent, oktop, okbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - ok == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, okwidth, - paint); - - here = ok; + v = out(source, + here, ok, + okascent, okdescent, oktop, okbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + ok == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, okwidth, + paint); + + here = ok; + } else { + // Act like it fit even though it didn't. + + fitwidth = w; + here = fit = j + 1; + + if (fmtop < fittop) + fittop = fmtop; + if (fmascent < fitascent) + fitascent = fmascent; + if (fmdescent > fitdescent) + fitdescent = fmdescent; + if (fmbottom > fitbottom) + fitbottom = fmbottom; + } } else { - // Act like it fit even though it didn't. - - fitwidth = w; - fit = j + 1; - - if (fmtop < fittop) - fittop = fmtop; - if (fmascent < fitascent) - fitascent = fmascent; - if (fmdescent > fitdescent) - fitdescent = fmdescent; - if (fmbottom > fitbottom) - fitbottom = fmbottom; - } - } else { - if (ok != here) { - // Log.e("text", "output ok " + here + " to " +ok); + if (ok != here) { + // Log.e("text", "output ok " + here + " to " +ok); - while (ok < spanEnd && chs[ok - paraStart] == ' ') { - ok++; - } + while (ok < spanEnd && chs[ok - paraStart] == ' ') { + ok++; + } - v = out(source, - here, ok, - okascent, okdescent, oktop, okbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - ok == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, okwidth, - paint); - - here = ok; - } else if (fit != here) { - // Log.e("text", "output fit " + here + " to " +fit); - v = out(source, - here, fit, - fitascent, fitdescent, - fittop, fitbottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - fit == bufend, includepad, trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, fitwidth, - paint); - - here = fit; - } else { - // Log.e("text", "output one " + here + " to " +(here + 1)); - // XXX not sure why the existing fm wasn't ok. - // measureText(paint, mWorkPaint, - // source, here, here + 1, fm, tab, - // null); - - v = out(source, - here, here+1, - fm.ascent, fm.descent, - fm.top, fm.bottom, - v, - spacingmult, spacingadd, chooseht, - choosehtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - here + 1 == bufend, includepad, - trackpad, - chs, widths, here - paraStart, - where, ellipsizedWidth, - widths[here - paraStart], paint); - - here = here + 1; + v = out(source, + here, ok, + okascent, okdescent, oktop, okbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + ok == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, okwidth, + paint); + + here = ok; + } else if (fit != here) { + // Log.e("text", "output fit " + here + " to " +fit); + v = out(source, + here, fit, + fitascent, fitdescent, + fittop, fitbottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + fit == bufend, includepad, trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, fitwidth, + paint); + + here = fit; + } else { + // Log.e("text", "output one " + here + " to " +(here + 1)); + // XXX not sure why the existing fm wasn't ok. + // measureText(paint, mWorkPaint, + // source, here, here + 1, fm, tab, + // null); + + v = out(source, + here, here+1, + fm.ascent, fm.descent, + fm.top, fm.bottom, + v, + spacingmult, spacingadd, chooseht, + choosehtv, fm, hasTabOrEmoji, + needMultiply, paraStart, chdirs, dir, easy, + here + 1 == bufend, includepad, + trackpad, + chs, widths, here - paraStart, + where, ellipsizedWidth, + widths[here - paraStart], paint); + + here = here + 1; + } } if (here < spanStart) { |