From c6def223a4b58560a1576b20d89e3d35877e6a5e Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 29 Nov 2023 13:52:12 +0000 Subject: Remove Unicode whitespace before AM/PM in the status bar The regression is introduced in Android 14 with ICU 72 when \u202f is used in the time format for en-US. UCharacter.isUWhitespace is a better way to determine Unicode whitespace characters than the characters used in the java language as in JLS 3.6, because the time format comes from the ICU following the Unicode / CLDR spec. Flag: NA Bug: 312903894 Test: Verified that MAGIC1 is inserted before \u202f Test: Inspected the TextView.mText via https://google.github.io/web-hv (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e01e702f5dc541cbdd3812ea9dbdd2ac58d9c503) Merged-In: I7b660b94c6ef75dbe96be8bcd2b074c8edd73ba7 Change-Id: I7b660b94c6ef75dbe96be8bcd2b074c8edd73ba7 --- packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java index 6875b523a962..ea140cb99d19 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.TypedArray; import android.graphics.Rect; +import android.icu.lang.UCharacter; import android.icu.text.DateTimePatternGenerator; import android.os.Bundle; import android.os.Handler; @@ -452,7 +453,7 @@ public class Clock extends TextView implements if (a >= 0) { // Move a back so any whitespace before AM/PM is also in the alternate size. final int b = a; - while (a > 0 && Character.isWhitespace(format.charAt(a-1))) { + while (a > 0 && UCharacter.isUWhiteSpace(format.charAt(a - 1))) { a--; } format = format.substring(0, a) + MAGIC1 + format.substring(a, b) -- cgit v1.2.3-59-g8ed1b