summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2012-10-19 13:36:58 -0400
committerDaniel Sandler <dsandler@android.com>2012-10-19 13:38:11 -0400
commitb9d36649ca458cb5326a144fd88e26b92efba728 (patch)
tree8a03fb8bb423e595e37dc1d747541dcba0dc8711 /tests
parenta1f739ea83b6d770b8469ae1c2c4161f6fe96334 (diff)
downloadframeworks_base-b9d36649ca458cb5326a144fd88e26b92efba728.zip
frameworks_base-b9d36649ca458cb5326a144fd88e26b92efba728.tar.gz
frameworks_base-b9d36649ca458cb5326a144fd88e26b92efba728.tar.bz2
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
Diffstat (limited to 'tests')
-rw-r--r--tests/StatusBar/res/layout/notification_builder_test.xml12
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java42
2 files changed, 46 insertions, 8 deletions
diff --git a/tests/StatusBar/res/layout/notification_builder_test.xml b/tests/StatusBar/res/layout/notification_builder_test.xml
index 6c384f7..94fc089 100644
--- a/tests/StatusBar/res/layout/notification_builder_test.xml
+++ b/tests/StatusBar/res/layout/notification_builder_test.xml
@@ -371,6 +371,12 @@
android:tag="Oh my goodness. SOMETHING HAPPENED!!!!"
/>
<RadioButton
+ android:id="@+id/text_emoji"
+ style="@style/FieldContents"
+ android:text="emoji"
+ android:tag="_ Cactus _ Cactus _"
+ />
+ <RadioButton
android:id="@+id/text_haiku"
style="@style/FieldContents"
android:text="haiku"
@@ -572,6 +578,12 @@
android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
/>
<RadioButton
+ android:id="@+id/ticker_emoji"
+ style="@style/FieldContents"
+ android:text="emoji"
+ android:tag="_ Cactus _ Cactus _"
+ />
+ <RadioButton
android:id="@+id/ticker_custom"
style="@style/FieldContents.Disabled"
android:text="custom view"
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
index fefd890..2f0c173 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
@@ -32,6 +32,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.os.Handler;
+import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.Log;
import android.net.Uri;
@@ -187,6 +188,20 @@ public class NotificationBuilderTest extends Activity
mNM.notify(id, n);
}
+ private static CharSequence subst(CharSequence in, char ch, CharSequence sub) {
+ int i=0;
+ SpannableStringBuilder edit = new SpannableStringBuilder(in);
+ while (i<edit.length()) {
+ if (edit.charAt(i) == ch) {
+ edit.replace(i, i+1, sub);
+ i += sub.length();
+ } else {
+ i ++;
+ }
+ }
+ return edit;
+ }
+
private Notification buildNotification(int id) {
Notification.Builder b = new Notification.Builder(this);
@@ -223,19 +238,25 @@ public class NotificationBuilderTest extends Activity
}
// title
- final String title = getRadioTag(R.id.group_title);
+ final CharSequence title = getRadioTag(R.id.group_title);
if (!TextUtils.isEmpty(title)) {
b.setContentTitle(title);
}
// text
- final String text = getRadioTag(R.id.group_text);
+ final CharSequence text = getRadioTag(R.id.group_text);
if (!TextUtils.isEmpty(text)) {
- b.setContentText(text);
+ if (getRadioChecked(R.id.group_text) == R.id.text_emoji) {
+ // UTF-16 for +1F335
+ b.setContentText(subst(text,
+ '_', "\ud83c\udf35"));
+ } else {
+ b.setContentText(text);
+ }
}
// info
- final String info = getRadioTag(R.id.group_info);
+ final CharSequence info = getRadioTag(R.id.group_info);
if (!TextUtils.isEmpty(info)) {
b.setContentInfo(info);
}
@@ -272,6 +293,11 @@ public class NotificationBuilderTest extends Activity
case R.id.ticker_haiku:
b.setTicker(getRadioTag(R.id.group_ticker));
break;
+ case R.id.ticker_emoji:
+ // UTF-16 for +1F335
+ b.setTicker(subst(getRadioTag(R.id.group_ticker),
+ '_', "\ud83c\udf35"));
+ break;
case R.id.ticker_custom:
// TODO
break;
@@ -370,19 +396,19 @@ public class NotificationBuilderTest extends Activity
return g.getCheckedRadioButtonId();
}
- private String getRadioTag(int id) {
+ private CharSequence getRadioTag(int id) {
final RadioGroup g = (RadioGroup)findViewById(id);
final View v = findViewById(g.getCheckedRadioButtonId());
- return (String)v.getTag();
+ return (CharSequence) v.getTag();
}
private int getRadioInt(int id, int def) {
- String str = getRadioTag(id);
+ CharSequence str = getRadioTag(id);
if (TextUtils.isEmpty(str)) {
return def;
} else {
try {
- return Integer.parseInt(str);
+ return Integer.parseInt(str.toString());
} catch (NumberFormatException ex) {
return def;
}