From 5b873f1366e84241015a81786761ef147790bf9b Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Fri, 5 Feb 2021 11:58:13 -0800 Subject: [PATCH] Fix ellipsis reinitialization for static cached StaticLayout. DynamicLayout uses a static StaticLayout instance internally to avoid allocations. For the specific case of multiline, TruncateAt.START, and no ellipsization needed (may also be triggered by slightly different params), the ellipsis results for a reused static instance are not modified. If the instance was previously ellipsized, the new result keeps that ellipsization result even though it shouldn't be ellipsized (at least for some lines). Bug: 179524847 Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \ TextViewTest Change-Id: I1b4142648ec1b6b3fc2ece0ec55aac9539497134 --- core/java/android/text/StaticLayout.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 85911fffc1bfa..f99d4300a8484 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -977,6 +977,9 @@ public class StaticLayout extends Layout { calculateEllipsis(start, end, measured, widthStart, ellipsisWidth, ellipsize, j, textWidth, paint, forceEllipsis); + } else { + mLines[mColumns * j + ELLIPSIS_START] = 0; + mLines[mColumns * j + ELLIPSIS_COUNT] = 0; } }