Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6f19da0 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Fix bug #5197549 android.text.cts.StaticLayoutTest#testGetEllipsisCount...

Merge "Fix bug #5197549 android.text.cts.StaticLayoutTest#testGetEllipsisCount fails on IRK49E mysid-userdebug"
parents 25c82e6c aef455fd
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -729,13 +729,23 @@ public class StaticLayout extends Layout {
                    start - widthStart, end - start);
        }

        // If ellipsize is in marquee mode, do not apply ellipsis on the first line
        if (ellipsize != null && (ellipsize != TextUtils.TruncateAt.MARQUEE || j != 0)) {
        if (ellipsize != null) {
            // If there is only one line, then do any type of ellipsis except when it is MARQUEE
            // if there are multiple lines, just allow END ellipsis on the last line
            boolean firstLine = (j == 0);
            boolean currentLineIsTheLastVisibleOne = (j + 1 == mMaximumVisibleLineCount);
            boolean forceEllipsis = moreChars && (mLineCount + 1 == mMaximumVisibleLineCount);

            boolean doEllipsis = (firstLine && !moreChars &&
                                ellipsize != TextUtils.TruncateAt.MARQUEE) ||
                        (!firstLine && (currentLineIsTheLastVisibleOne || !moreChars) &&
                                ellipsize == TextUtils.TruncateAt.END);
            if (doEllipsis) {
                calculateEllipsis(start, end, widths, widthStart,
                        ellipsisWidth, ellipsize, j,
                        textWidth, paint, forceEllipsis);
            }
        }

        mLineCount++;
        return v;
@@ -797,8 +807,8 @@ public class StaticLayout extends Layout {

            ellipsisStart = i;
            ellipsisCount = len - i;
            if (forceEllipsis && ellipsisCount == 0 && i > 0) {
                ellipsisStart = i - 1;
            if (forceEllipsis && ellipsisCount == 0 && len > 0) {
                ellipsisStart = len - 1;
                ellipsisCount = 1;
            }
        } else {