From f4cc6003a0e683ee0c46146ce5c97347190bbc1e Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Wed, 11 Jan 2023 17:20:59 +0000 Subject: [PATCH] Store string of most recent shaped text for debugging Bug: 264262853 Test: Manually check the device Change-Id: Ibc7a45df48bb5d36cdcbd0aee4df6d5aa902282e --- .../android/systemui/animation/TextInterpolator.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt index 0448c818f7655..681e4d1fdd023 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt @@ -122,6 +122,9 @@ class TextInterpolator( shapeText(value) } + var shapedText: String = "" + private set + init { // shapeText needs to be called after all members are initialized. shapeText(layout) @@ -484,10 +487,12 @@ class TextInterpolator( layout: Layout, paint: TextPaint ): List> { + var text = StringBuilder() val out = mutableListOf>() for (lineNo in 0 until layout.lineCount) { // Shape all lines. val lineStart = layout.getLineStart(lineNo) - var count = layout.getLineEnd(lineNo) - lineStart + val lineEnd = layout.getLineEnd(lineNo) + var count = lineEnd - lineStart // Do not render the last character in the line if it's a newline and unprintable val last = lineStart + count - 1 if (last > lineStart && last < layout.text.length && layout.text[last] == '\n') { @@ -500,7 +505,13 @@ class TextInterpolator( runs.add(glyphs) } out.add(runs) + + if (lineNo > 0) { + text.append("\n") + } + text.append(layout.text.substring(lineStart, lineEnd)) } + shapedText = text.toString() return out } }