From b9d36649ca458cb5326a144fd88e26b92efba728 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Fri, 19 Oct 2012 13:36:58 -0400 Subject: Properly show emoji in the notification ticker. Add an emoji test to StatusBarTest (working around some difficulties in actually putting high-Unicode chars in the layout xml). Bug: 7378383 Change-Id: Ifce9844b26f67d2799521623e5161aa4dad69ed1 --- .../android/systemui/statusbar/phone/Ticker.java | 19 +++++++--- .../res/layout/notification_builder_test.xml | 12 +++++++ .../statusbartest/NotificationBuilderTest.java | 42 +++++++++++++++++----- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/Ticker.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/Ticker.java index 67846a3..ecc70d6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/Ticker.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/Ticker.java @@ -53,6 +53,16 @@ public abstract class Ticker { private TextSwitcher mTextSwitcher; private float mIconScale; + public static boolean isGraphicOrEmoji(char c) { + int gc = Character.getType(c); + return gc != Character.CONTROL + && gc != Character.FORMAT + && gc != Character.UNASSIGNED + && gc != Character.LINE_SEPARATOR + && gc != Character.PARAGRAPH_SEPARATOR + && gc != Character.SPACE_SEPARATOR; + } + private final class Segment { StatusBarNotification notification; Drawable icon; @@ -68,7 +78,7 @@ public abstract class Ticker { } CharSequence rtrim(CharSequence substr, int start, int end) { - while (end > start && !TextUtils.isGraphic(substr.charAt(end-1))) { + while (end > start && !isGraphicOrEmoji(substr.charAt(end-1))) { end--; } if (end > start) { @@ -101,7 +111,7 @@ public abstract class Ticker { this.first = false; int index = this.next; final int len = this.text.length(); - while (index < len && !TextUtils.isGraphic(this.text.charAt(index))) { + while (index < len && !isGraphicOrEmoji(this.text.charAt(index))) { index++; } if (index >= len) { @@ -136,7 +146,7 @@ public abstract class Ticker { this.text = text; int index = 0; final int len = text.length(); - while (index < len && !TextUtils.isGraphic(text.charAt(index))) { + while (index < len && !isGraphicOrEmoji(text.charAt(index))) { index++; } this.current = index; @@ -194,7 +204,8 @@ public abstract class Ticker { final Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(n.pkg, n.user, n.notification.icon, n.notification.iconLevel, 0, n.notification.tickerText)); - final Segment newSegment = new Segment(n, icon, n.notification.tickerText); + final CharSequence text = n.notification.tickerText; + final Segment newSegment = new Segment(n, icon, text); // If there's already a notification schedule for this package and id, remove it. for (int i=0; i + +