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
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 94c463c..353dfed 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -1031,6 +1031,7 @@
                                    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 @@
         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