From 1250cd140767231a92919d94a0173b3d0bd9a730 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Wed, 6 Jun 2018 15:40:47 +0800 Subject: [PATCH] Fix solid circle show on message notification Message app or other apps will use some format code or controll code on SenderName to fit RTL or other design, and symbols will produced by these code. The special code pattern not include these code, so it will go charIcon flow. Although these code is not visible, we should just ignore them to get symbol strings Change-Id: I20ef459b10ba7504ec0c997ed815cb485817d2bc Fixes: 109746235 Test: Check notification form message app on RTL Test: atest SystemUITests --- .../android/internal/widget/MessagingLayout.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/widget/MessagingLayout.java b/core/java/com/android/internal/widget/MessagingLayout.java index 0fd610908fd55..4ba93bc50dff0 100644 --- a/core/java/com/android/internal/widget/MessagingLayout.java +++ b/core/java/com/android/internal/widget/MessagingLayout.java @@ -60,6 +60,13 @@ import java.util.regex.Pattern; public class MessagingLayout extends FrameLayout { private static final float COLOR_SHIFT_AMOUNT = 60; + /** + * Pattren for filter some ingonable characters. + * p{Z} for any kind of whitespace or invisible separator. + * p{C} for any kind of punctuation character. + */ + private static final Pattern IGNORABLE_CHAR_PATTERN + = Pattern.compile("[\\p{C}\\p{Z}]"); private static final Pattern SPECIAL_CHAR_PATTERN = Pattern.compile ("[!@#$%&*()_+=|<>?{}\\[\\]~-]"); private static final Consumer REMOVE_MESSAGE @@ -233,7 +240,10 @@ public class MessagingLayout extends FrameLayout { continue; } if (!uniqueNames.containsKey(senderName)) { - char c = senderName.charAt(0); + // Only use visible characters to get uniqueNames + String pureSenderName = IGNORABLE_CHAR_PATTERN + .matcher(senderName).replaceAll("" /* replacement */); + char c = pureSenderName.charAt(0); if (uniqueCharacters.containsKey(c)) { // this character was already used, lets make it more unique. We first need to // resolve the existing character if it exists @@ -245,7 +255,7 @@ public class MessagingLayout extends FrameLayout { uniqueNames.put(senderName, findNameSplit((String) senderName)); } else { uniqueNames.put(senderName, Character.toString(c)); - uniqueCharacters.put(c, senderName); + uniqueCharacters.put(c, pureSenderName); } } }