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

Commit 365ec096 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed that indents on an ellipsis of a staticlayout were dropped

If a layout had an ellipsis and in addition also indents,
the indents were ignored and the text would go over the indents.

Test: runtest -x cts/tests/tests/text/src/android/text/cts/StaticLayoutTest.java
Test: runtest -x cts/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java
Test: runtest -x cts/tests/tests/widget/src/android/widget/cts/TextViewTest.java
Change-Id: I4cc89dad8301f6b1bb46a479395fd72c8476e477
Fixes: 36081667
parent 10790672
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1031,6 +1031,7 @@ public class StaticLayout extends Layout {
                                   float avail, TextUtils.TruncateAt where,
                                   int line, float textWidth, TextPaint paint,
                                   boolean forceEllipsis) {
        avail -= getTotalInsets(line);
        if (textWidth <= avail && !forceEllipsis) {
            // Everything fits!
            mLines[mColumns * line + ELLIPSIS_START] = 0;
@@ -1134,6 +1135,17 @@ public class StaticLayout extends Layout {
        mLines[mColumns * line + ELLIPSIS_COUNT] = ellipsisCount;
    }

    private float getTotalInsets(int line) {
        int totalIndent = 0;
        if (mLeftIndents != null) {
            totalIndent = mLeftIndents[Math.min(line, mLeftIndents.length - 1)];
        }
        if (mRightIndents != null) {
            totalIndent += mRightIndents[Math.min(line, mRightIndents.length - 1)];
        }
        return totalIndent;
    }

    // Override the base class so we can directly access our members,
    // rather than relying on member functions.
    // The logic mirrors that of Layout.getLineForVertical