summaryrefslogtreecommitdiffstats
path: root/tests/StatusBar
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2010-11-22 16:09:29 -0800
committerJoe Onorato <joeo@google.com>2010-11-22 16:19:40 -0800
commit8d0b655c496e9125fc8d289c4e5bc9a78297ba3d (patch)
tree49ad9d96824e62cf44451de6f20d870e8941e0f5 /tests/StatusBar
parent83d97c8c7ddff9374f876bef48758414a7775cb1 (diff)
downloadframeworks_base-8d0b655c496e9125fc8d289c4e5bc9a78297ba3d.zip
frameworks_base-8d0b655c496e9125fc8d289c4e5bc9a78297ba3d.tar.gz
frameworks_base-8d0b655c496e9125fc8d289c4e5bc9a78297ba3d.tar.bz2
Add a better notification test and clean up the flag handling in the notification builder.
Change-Id: I9354ed2c2cda690f53e5f43ad60943b63b02e7d4
Diffstat (limited to 'tests/StatusBar')
-rw-r--r--tests/StatusBar/AndroidManifest.xml6
-rw-r--r--tests/StatusBar/res/drawable-mdpi/emo_im_kissing.pngbin0 -> 3492 bytes
-rw-r--r--tests/StatusBar/res/layout/notification_builder_test.xml819
-rw-r--r--tests/StatusBar/res/values/styles.xml63
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java392
5 files changed, 1216 insertions, 64 deletions
diff --git a/tests/StatusBar/AndroidManifest.xml b/tests/StatusBar/AndroidManifest.xml
index b1734bb..ddb756b 100644
--- a/tests/StatusBar/AndroidManifest.xml
+++ b/tests/StatusBar/AndroidManifest.xml
@@ -21,7 +21,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name="NotificationBuilderTest" android:label="_Notify Builder">
+ <activity android:name="NotificationBuilderTest"
+ android:label="_Notify Builder"
+ android:theme="@android:style/Theme.Holo"
+ android:hardwareAccelerated="true"
+ >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/tests/StatusBar/res/drawable-mdpi/emo_im_kissing.png b/tests/StatusBar/res/drawable-mdpi/emo_im_kissing.png
new file mode 100644
index 0000000..56378f6
--- /dev/null
+++ b/tests/StatusBar/res/drawable-mdpi/emo_im_kissing.png
Binary files differ
diff --git a/tests/StatusBar/res/layout/notification_builder_test.xml b/tests/StatusBar/res/layout/notification_builder_test.xml
new file mode 100644
index 0000000..58c4fbb
--- /dev/null
+++ b/tests/StatusBar/res/layout/notification_builder_test.xml
@@ -0,0 +1,819 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:paddingLeft="40dp"
+ android:paddingTop="12dp"
+ android:paddingRight="24dp"
+ android:paddingBottom="12dp"
+ >
+
+ <LinearLayout
+ android:layout_width="220sp"
+ android:layout_height="match_parent"
+ android:layout_marginRight="24dp"
+ android:orientation="vertical"
+ >
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_1"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="1"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_1"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_2"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="2"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_2"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_3"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="3"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_3"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_4"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="4"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_4"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_5"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="5"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_5"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_6"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="6"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_6"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_7"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="7"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_7"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_8"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="8"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_8"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_9"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="9"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_9"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <Button
+ style="@style/IdButton.Minus"
+ android:id="@+id/clear_10"
+ />
+ <TextView
+ style="@style/IdTitle"
+ android:text="10"
+ />
+ <Button
+ style="@style/IdButton.Plus"
+ android:id="@+id/notify_10"
+ />
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/clear_all"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dp"
+ android:layout_marginBottom="12dp"
+ android:text="Clear All"
+ />
+ <Button
+ android:id="@+id/ten"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Ten notifications"
+ />
+
+ </LinearLayout>
+
+ <ScrollView
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ >
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ >
+
+ <!-- setWhen -->
+ <RadioGroup
+ android:id="@+id/group_when"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setWhen"
+ />
+ <RadioButton
+ android:id="@+id/when_midnight"
+ style="@style/FieldContents.Disabled"
+ android:text="midnight"
+ />
+ <RadioButton
+ android:id="@+id/when_now"
+ style="@style/FieldContents"
+ android:text="now"
+ />
+ <RadioButton
+ android:id="@+id/when_now_plus_1h"
+ style="@style/FieldContents.Disabled"
+ android:text="now + 1h"
+ />
+ <RadioButton
+ android:id="@+id/when_tomorrow"
+ style="@style/FieldContents.Disabled"
+ android:text="tomorrow"
+ />
+ </RadioGroup>
+
+ <!-- icon -->
+ <RadioGroup
+ android:id="@+id/group_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setSmallIcon"
+ />
+ <RadioButton
+ android:id="@+id/icon_im"
+ style="@style/FieldContents"
+ android:text="IM"
+ />
+ <RadioButton
+ android:id="@+id/icon_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ <RadioButton
+ android:id="@+id/icon_surprise"
+ style="@style/FieldContents"
+ android:text="surprise"
+ />
+ <RadioButton
+ android:id="@+id/icon_level0"
+ style="@style/FieldContents.Disabled"
+ android:text="level 0"
+ />
+ <RadioButton
+ android:id="@+id/icon_level50"
+ style="@style/FieldContents.Disabled"
+ android:text="level 50"
+ />
+ <RadioButton
+ android:id="@+id/icon_level100"
+ style="@style/FieldContents.Disabled"
+ android:text="level 100"
+ />
+ <!-- todo setSmallIcon(int icon, int level) -->
+ </RadioGroup>
+
+ <!-- setContentTitle -->
+ <RadioGroup
+ android:id="@+id/group_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setContentTitle"
+ />
+ <RadioButton
+ android:id="@+id/title_short"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/title_short"
+ style="@style/FieldContents"
+ android:text="cwshort"
+ android:tag="Title"
+ />
+ <RadioButton
+ android:id="@+id/title_medium"
+ style="@style/FieldContents"
+ android:text="medium"
+ android:tag="Notification Test"
+ />
+ <RadioButton
+ android:id="@+id/title_long"
+ style="@style/FieldContents"
+ android:text="long"
+ android:tag="This is one heckuva long title for a notification"
+ />
+ </RadioGroup>
+
+ <!-- setContentText -->
+ <RadioGroup
+ android:id="@+id/group_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setContentText"
+ />
+ <RadioButton
+ android:id="@+id/text_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/text_short"
+ style="@style/FieldContents"
+ android:tag="short"
+ android:text="text"
+ />
+ <RadioButton
+ android:id="@+id/text_medium"
+ style="@style/FieldContents"
+ android:text="medium"
+ android:tag="Something happened"
+ />
+ <RadioButton
+ android:id="@+id/text_long"
+ style="@style/FieldContents"
+ android:text="long"
+ android:tag="Oh my goodness. SOMETHING HAPPENED!!!!"
+ />
+ <RadioButton
+ android:id="@+id/text_haiku"
+ style="@style/FieldContents"
+ android:text="haiku"
+ android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
+ />
+ </RadioGroup>
+
+ <!-- setContentInfo -->
+ <RadioGroup
+ android:id="@+id/group_info"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setContentInfo"
+ />
+ <RadioButton
+ android:id="@+id/info_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/info_number"
+ style="@style/FieldContents"
+ android:text="snoozed"
+ android:tag="snoozed"
+ />
+ <RadioButton
+ android:id="@+id/info_long"
+ style="@style/FieldContents"
+ android:text="longer"
+ android:tag="this content info is way too long"
+ />
+ </RadioGroup>
+
+ <!-- setNumber -->
+ <RadioGroup
+ android:id="@+id/group_number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setNumber"
+ />
+ <RadioButton
+ android:id="@+id/number_0"
+ style="@style/FieldContents"
+ android:text="0"
+ android:tag="0"
+ />
+ <RadioButton
+ android:id="@+id/number_1"
+ style="@style/FieldContents"
+ android:text="1"
+ android:tag="1"
+ />
+ <RadioButton
+ android:id="@+id/number_42"
+ style="@style/FieldContents"
+ android:text="42"
+ android:tag="42"
+ />
+ <RadioButton
+ android:id="@+id/number_334"
+ style="@style/FieldContents"
+ android:text="334"
+ android:tag="334"
+ />
+ <RadioButton
+ android:id="@+id/number_999"
+ style="@style/FieldContents"
+ android:text="999"
+ android:tag="999"
+ />
+ <RadioButton
+ android:id="@+id/number_9876"
+ style="@style/FieldContents"
+ android:text="9,876"
+ android:tag="9876"
+ />
+ <RadioButton
+ android:id="@+id/number_12345"
+ style="@style/FieldContents"
+ android:text="12,345"
+ android:tag="12345"
+ />
+ </RadioGroup>
+
+ <!-- setContentIntent -->
+ <RadioGroup
+ android:id="@+id/group_intent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setContentIntent"
+ />
+ <RadioButton
+ android:id="@+id/intent_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/intent_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ </RadioGroup>
+
+ <!-- setDeleteIntent -->
+ <RadioGroup
+ android:id="@+id/group_delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setDeleteIntent"
+ />
+ <RadioButton
+ android:id="@+id/delete_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/delete_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ </RadioGroup>
+
+
+ <!-- setFullScreenIntent -->
+ <RadioGroup
+ android:id="@+id/group_full_screen"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:visibility="gone"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setFullScreenIntent"
+ />
+ <RadioButton
+ android:id="@+id/full_screen_none"
+ style="@style/FieldContents.Disabled"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/full_screen_activity"
+ style="@style/FieldContents.Disabled"
+ android:text="full screen"
+ />
+ </RadioGroup>
+
+
+ <!-- setTicker -->
+ <RadioGroup
+ android:id="@+id/group_ticker"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setTicker"
+ />
+ <RadioButton
+ android:id="@+id/ticker_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/ticker_short"
+ style="@style/FieldContents"
+ android:text="short"
+ android:tag="tick"
+ />
+ <RadioButton
+ android:id="@+id/ticker_wrap"
+ style="@style/FieldContents"
+ android:text="wrap"
+ android:tag="tick tick tick tock tock tock something fun has happened but i don't know what it is just yet"
+ />
+ <RadioButton
+ android:id="@+id/ticker_haiku"
+ style="@style/FieldContents"
+ android:text="haiku"
+ android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
+ />
+ <RadioButton
+ android:id="@+id/ticker_custom"
+ style="@style/FieldContents.Disabled"
+ android:text="custom view"
+ />
+ </RadioGroup>
+
+
+ <!-- setLargeIcon -->
+ <RadioGroup
+ android:id="@+id/group_large_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setLargeIcon"
+ />
+ <RadioButton
+ android:id="@+id/large_icon_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/large_icon_pineapple"
+ style="@style/FieldContents"
+ android:text="pineapple"
+ />
+ </RadioGroup>
+
+
+ <!-- setSound -->
+ <RadioGroup
+ android:id="@+id/group_sound"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:visibility="gone"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setSound"
+ />
+ <RadioButton
+ android:id="@+id/sound_none"
+ style="@style/FieldContents.Disabled"
+ android:text="none"
+ />
+ </RadioGroup>
+
+
+ <!-- setVibrate -->
+ <RadioGroup
+ android:id="@+id/group_vibrate"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setVibrate"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_short"
+ style="@style/FieldContents"
+ android:text="short"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_medium"
+ style="@style/FieldContents"
+ android:text="long"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_long"
+ style="@style/FieldContents"
+ android:text="long"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_pattern"
+ style="@style/FieldContents"
+ android:text="longer"
+ />
+ </RadioGroup>
+
+
+ <!-- setLights -->
+ <RadioGroup
+ android:id="@+id/group_lights_color"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setLights (color)"
+ />
+ <RadioButton
+ android:id="@+id/lights_red"
+ style="@style/FieldContents"
+ android:text="red"
+ android:tag="0xff0000"
+ />
+ <RadioButton
+ android:id="@+id/lights_green"
+ style="@style/FieldContents"
+ android:text="green"
+ android:tag="0x00ff00"
+ />
+ <RadioButton
+ android:id="@+id/lights_blue"
+ style="@style/FieldContents"
+ android:text="blue"
+ android:tag="0x0000ff"
+ />
+ <RadioButton
+ android:id="@+id/lights_cyan"
+ style="@style/FieldContents"
+ android:text="cyan"
+ android:tag="0x00ffff"
+ />
+ <RadioButton
+ android:id="@+id/lights_magenta"
+ style="@style/FieldContents"
+ android:text="magenta"
+ android:tag="0xff00ff"
+ />
+ <RadioButton
+ android:id="@+id/lights_yellow"
+ style="@style/FieldContents"
+ android:text="yellow"
+ android:tag="0xffff00"
+ />
+ <RadioButton
+ android:id="@+id/lights_white"
+ style="@style/FieldContents"
+ android:text="white"
+ android:tag="0xffffff"
+ />
+ </RadioGroup>
+
+ <!-- setLights -->
+ <RadioGroup
+ android:id="@+id/group_lights_blink"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setLights (blink)"
+ />
+ <RadioButton
+ android:id="@+id/lights_off"
+ style="@style/FieldContents"
+ android:text="off"
+ />
+ <RadioButton
+ android:id="@+id/lights_slow"
+ style="@style/FieldContents"
+ android:text="slow"
+ />
+ <RadioButton
+ android:id="@+id/lights_fast"
+ style="@style/FieldContents"
+ android:text="fast"
+ />
+ <RadioButton
+ android:id="@+id/lights_on"
+ style="@style/FieldContents"
+ android:text="on"
+ />
+ </RadioGroup>
+
+ <!-- flags -->
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginTop="12dp"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="flags"
+ />
+ <CheckBox
+ android:id="@+id/flag_ongoing"
+ style="@style/FieldContents"
+ android:text="setOngoing"
+ />
+ <CheckBox
+ android:id="@+id/flag_once"
+ style="@style/FieldContents"
+ android:text="setOnlyAlertOnce"
+ />
+ <CheckBox
+ android:id="@+id/flag_auto_cancel"
+ style="@style/FieldContents"
+ android:text="setAutoCancel"
+ />
+ </LinearLayout>
+
+ <!-- defaults -->
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="defaults"
+ />
+ <CheckBox
+ android:id="@+id/default_sound"
+ style="@style/FieldContents"
+ android:text="sound"
+ />
+ <CheckBox
+ android:id="@+id/default_vibrate"
+ style="@style/FieldContents"
+ android:text="vibrate"
+ />
+ <CheckBox
+ android:id="@+id/default_lights"
+ style="@style/FieldContents"
+ android:text="lights"
+ />
+ </LinearLayout>
+
+
+
+
+ </LinearLayout>
+ </ScrollView>
+
+
+</LinearLayout>
diff --git a/tests/StatusBar/res/values/styles.xml b/tests/StatusBar/res/values/styles.xml
new file mode 100644
index 0000000..e051efd
--- /dev/null
+++ b/tests/StatusBar/res/values/styles.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <style name="IdTitle">
+ <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+ <item name="android:layout_width">30sp</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+
+ <style name="IdButton">
+ <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+ <item name="android:layout_width">0dp</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_weight">1</item>
+ <item name="android:layout_marginRight">8dp</item>
+ <item name="android:layout_marginLeft">8dp</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+
+ <style name="IdButton.Minus">
+ <item name="android:text">-</item>
+ </style>
+
+ <style name="IdButton.Plus">
+ <item name="android:text">+</item>
+ </style>
+
+ <style name="FieldTitle">
+ <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+ <item name="android:layout_width">208sp</item>
+ <item name="android:layout_height">wrap_content</item>
+ </style>
+
+ <style name="FieldContents">
+ <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginRight">20dp</item>
+ </style>
+
+ <style name="FieldContents.Disabled">
+ <item name="android:clickable">false</item>
+ <item name="android:visibility">gone</item>
+ </style>
+
+</resources>
+
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
index 3c26212..e9a3513 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
@@ -16,6 +16,7 @@
package com.android.statusbartest;
+import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -25,106 +26,363 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.os.Handler;
+import android.text.TextUtils;
import android.util.Log;
import android.net.Uri;
import android.os.SystemClock;
+import android.view.View;
+import android.widget.CompoundButton;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
import android.widget.RemoteViews;
import android.os.PowerManager;
-public class NotificationBuilderTest extends TestActivity
+public class NotificationBuilderTest extends Activity
{
private final static String TAG = "NotificationTestList";
NotificationManager mNM;
@Override
- protected String tag() {
- return TAG;
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
+ setContentView(R.layout.notification_builder_test);
+ if (icicle == null) {
+ setDefaults();
+ }
+ for (int id: new int[] {
+ R.id.clear_1,
+ R.id.clear_2,
+ R.id.clear_3,
+ R.id.clear_4,
+ R.id.clear_5,
+ R.id.clear_6,
+ R.id.clear_7,
+ R.id.clear_8,
+ R.id.clear_9,
+ R.id.clear_10,
+ R.id.notify_1,
+ R.id.notify_2,
+ R.id.notify_3,
+ R.id.notify_4,
+ R.id.notify_5,
+ R.id.notify_6,
+ R.id.notify_7,
+ R.id.notify_8,
+ R.id.notify_9,
+ R.id.notify_10,
+ R.id.ten,
+ R.id.clear_all,
+ }) {
+ findViewById(id).setOnClickListener(mClickListener);
+ }
}
- @Override
- protected Test[] tests() {
- mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
-
- return mTests;
+ private void setDefaults() {
+ setChecked(R.id.when_now);
+ setChecked(R.id.icon_surprise);
+ setChecked(R.id.title_medium);
+ setChecked(R.id.text_medium);
+ setChecked(R.id.info_none);
+ setChecked(R.id.number_0);
+ setChecked(R.id.intent_alert);
+ setChecked(R.id.delete_none);
+ setChecked(R.id.full_screen_none);
+ setChecked(R.id.ticker_none);
+ setChecked(R.id.large_icon_none);
+ setChecked(R.id.sound_none);
+ setChecked(R.id.vibrate_none);
+ setChecked(R.id.lights_red);
+ setChecked(R.id.lights_off);
}
- private Test[] mTests = new Test[] {
- new Test("Cancel (1)") {
- public void run() {
- mNM.cancel(1);
+ private View.OnClickListener mClickListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.clear_1:
+ mNM.cancel(1);
+ break;
+ case R.id.clear_2:
+ mNM.cancel(2);
+ break;
+ case R.id.clear_3:
+ mNM.cancel(3);
+ break;
+ case R.id.clear_4:
+ mNM.cancel(4);
+ break;
+ case R.id.clear_5:
+ mNM.cancel(5);
+ break;
+ case R.id.clear_6:
+ mNM.cancel(6);
+ break;
+ case R.id.clear_7:
+ mNM.cancel(7);
+ break;
+ case R.id.clear_8:
+ mNM.cancel(8);
+ break;
+ case R.id.clear_9:
+ mNM.cancel(9);
+ break;
+ case R.id.clear_10:
+ mNM.cancel(10);
+ break;
+ case R.id.notify_1:
+ sendNotification(1);
+ break;
+ case R.id.notify_2:
+ sendNotification(2);
+ break;
+ case R.id.notify_3:
+ sendNotification(3);
+ break;
+ case R.id.notify_4:
+ sendNotification(4);
+ break;
+ case R.id.notify_5:
+ sendNotification(5);
+ break;
+ case R.id.notify_6:
+ sendNotification(6);
+ break;
+ case R.id.notify_7:
+ sendNotification(7);
+ break;
+ case R.id.notify_8:
+ sendNotification(8);
+ break;
+ case R.id.notify_9:
+ sendNotification(9);
+ break;
+ case R.id.notify_10:
+ sendNotification(10);
+ break;
+ case R.id.ten: {
+ for (int id=1; id<=10; id++) {
+ sendNotification(id);
+ }
+ break;
+ }
+ case R.id.clear_all: {
+ for (int id=1; id<=10; id++) {
+ mNM.cancel(id);
+ }
+ break;
+ }
}
- },
+ }
+ };
- new Test("Basic Content (1)") {
- public void run() {
- int id = 1;
- final Notification.Builder b = makeBasicBuilder(this, id);
+ private void sendNotification(int id) {
+ final Notification n = buildNotification(id);
+ mNM.notify(id, n);
+ }
- mNM.notify(id, b.getNotification());
- }
- },
+ private Notification buildNotification(int id) {
+ Notification.Builder b = new Notification.Builder(this);
- new Test("Content w/ Info (1)") {
- public void run() {
- int id = 1;
- final Notification.Builder b = makeBasicBuilder(this, id);
+ // when
+ switch (getRadioChecked(R.id.group_when)) {
+ case R.id.when_midnight:
+ break;
+ case R.id.when_now:
+ b.setWhen(System.currentTimeMillis());
+ break;
+ case R.id.when_now_plus_1h:
+ break;
+ case R.id.when_tomorrow:
+ break;
+ }
- b.setContentInfo("Snoozed");
+ // icon
+ switch (getRadioChecked(R.id.group_icon)) {
+ case R.id.icon_im:
+ b.setSmallIcon(R.drawable.icon1);
+ break;
+ case R.id.icon_alert:
+ b.setSmallIcon(R.drawable.icon2);
+ break;
+ case R.id.icon_surprise:
+ b.setSmallIcon(R.drawable.emo_im_kissing);
+ break;
+ }
- mNM.notify(id, b.getNotification());
- }
- },
+ // title
+ final String title = getRadioTag(R.id.group_title);
+ if (!TextUtils.isEmpty(title)) {
+ b.setContentTitle(title);
+ }
- new Test("w/ Number (1)") {
- public void run() {
- int id = 1;
- final Notification.Builder b = makeBasicBuilder(this, id);
+ // text
+ final String text = getRadioTag(R.id.group_text);
+ if (!TextUtils.isEmpty(text)) {
+ b.setContentText(text);
+ }
- b.setNumber(12345);
+ // info
+ final String info = getRadioTag(R.id.group_info);
+ if (!TextUtils.isEmpty(info)) {
+ b.setContentInfo(info);
+ }
- mNM.notify(id, b.getNotification());
- }
- },
+ // number
+ b.setNumber(getRadioInt(R.id.group_number, 0));
- new Test("w/ Number and Large Icon (1)") {
- public void run() {
- int id = 1;
- final Notification.Builder b = makeBasicBuilder(this, id);
+ // contentIntent
+ switch (getRadioChecked(R.id.group_intent)) {
+ case R.id.intent_none:
+ break;
+ case R.id.intent_alert:
+ b.setContentIntent(makeContentIntent(id));
+ break;
+ }
- b.setNumber(42);
+ // deleteIntent
+ switch (getRadioChecked(R.id.group_delete)) {
+ case R.id.delete_none:
+ break;
+ case R.id.delete_alert:
+ b.setDeleteIntent(makeDeleteIntent(id));
+ break;
+ }
- final BitmapDrawable bd = (BitmapDrawable)getResources().getDrawable(
- R.drawable.pineapple);
- b.setLargeIcon(Bitmap.createBitmap(bd.getBitmap()));
+ // fullScreenIntent TODO
- mNM.notify(id, b.getNotification());
- }
- },
- };
+ // ticker
+ switch (getRadioChecked(R.id.group_ticker)) {
+ case R.id.ticker_none:
+ break;
+ case R.id.ticker_short:
+ case R.id.ticker_wrap:
+ case R.id.ticker_haiku:
+ b.setTicker(getRadioTag(R.id.group_ticker));
+ break;
+ case R.id.ticker_custom:
+ // TODO
+ break;
+ }
- private Notification.Builder makeBasicBuilder(Test t, int id) {
- final Notification.Builder b = new Notification.Builder(this);
+ // largeIcon
+ switch (getRadioChecked(R.id.group_large_icon)) {
+ case R.id.large_icon_none:
+ break;
+ case R.id.large_icon_pineapple:
+ b.setLargeIcon(loadBitmap(R.drawable.pineapple));
+ break;
+ }
- b.setWhen(System.currentTimeMillis());
- b.setSmallIcon(R.drawable.ic_statusbar_chat);
- b.setContentTitle("Notification builder Test");
- b.setContentText(t.name + "\nhappy notifying");
- b.setContentIntent(makeContentIntent(id));
- b.setDeleteIntent(makeDeleteIntent(id));
+ // sound TODO
- return b;
+ // vibrate
+ switch (getRadioChecked(R.id.group_vibrate)) {
+ case R.id.vibrate_none:
+ break;
+ case R.id.vibrate_short:
+ b.setVibrate(new long[] { 0, 200 });
+ break;
+ case R.id.vibrate_medium:
+ b.setVibrate(new long[] { 0, 500 });
+ break;
+ case R.id.vibrate_long:
+ b.setVibrate(new long[] { 0, 1000 });
+ break;
+ case R.id.vibrate_pattern:
+ b.setVibrate(new long[] { 0, 250, 250, 250, 250, 250, 250, 250 });
+ break;
+ }
+
+ // lights
+ final int color = getRadioInt(R.id.group_lights_color, 0xff0000);
+ int onMs;
+ int offMs;
+ switch (getRadioChecked(R.id.group_lights_blink)) {
+ case R.id.lights_slow:
+ onMs = 1300;
+ offMs = 1300;
+ break;
+ case R.id.lights_fast:
+ onMs = 300;
+ offMs = 300;
+ break;
+ case R.id.lights_on:
+ onMs = 1;
+ offMs = 0;
+ break;
+ case R.id.lights_off:
+ default:
+ onMs = 0;
+ offMs = 0;
+ break;
+ }
+ if (onMs != 0 && offMs != 0) {
+ b.setLights(color, onMs, offMs);
+ }
+
+ // flags
+ b.setOngoing(getChecked(R.id.flag_ongoing));
+ b.setOnlyAlertOnce(getChecked(R.id.flag_once));
+ b.setAutoCancel(getChecked(R.id.flag_auto_cancel));
+
+ // defaults
+ int defaults = 0;
+ if (getChecked(R.id.default_sound)) {
+ defaults |= Notification.DEFAULT_SOUND;
+ }
+ if (getChecked(R.id.default_vibrate)) {
+ defaults |= Notification.DEFAULT_VIBRATE;
+ }
+ if (getChecked(R.id.default_lights)) {
+ defaults |= Notification.DEFAULT_LIGHTS;
+ }
+ b.setDefaults(defaults);
+
+ return b.getNotification();
}
- private PendingIntent makeContentIntent(int id) {
- Intent intent = new Intent(this, ConfirmationActivity.class);
- intent.setData(Uri.fromParts("content", "//status_bar_test/content/" + id, null));
- intent.putExtra(ConfirmationActivity.EXTRA_TITLE, "Content intent");
- intent.putExtra(ConfirmationActivity.EXTRA_TEXT, "id: " + id);
- return PendingIntent.getActivity(this, 0, intent, 0);
+ private void setChecked(int id) {
+ final CompoundButton b = (CompoundButton)findViewById(id);
+ b.setChecked(true);
+ }
+
+ private int getRadioChecked(int id) {
+ final RadioGroup g = (RadioGroup)findViewById(id);
+ return g.getCheckedRadioButtonId();
+ }
+
+ private String getRadioTag(int id) {
+ final RadioGroup g = (RadioGroup)findViewById(id);
+ final View v = findViewById(g.getCheckedRadioButtonId());
+ return (String)v.getTag();
+ }
+
+ private int getRadioInt(int id, int def) {
+ String str = getRadioTag(id);
+ if (TextUtils.isEmpty(str)) {
+ return def;
+ } else {
+ try {
+ return Integer.parseInt(str);
+ } catch (NumberFormatException ex) {
+ return def;
+ }
+ }
+ }
+
+ private boolean getChecked(int id) {
+ final CompoundButton b = (CompoundButton)findViewById(id);
+ return b.isChecked();
+ }
+
+ private Bitmap loadBitmap(int id) {
+ final BitmapDrawable bd = (BitmapDrawable)getResources().getDrawable(id);
+ return Bitmap.createBitmap(bd.getBitmap());
}
private PendingIntent makeDeleteIntent(int id) {
@@ -134,5 +392,13 @@ public class NotificationBuilderTest extends TestActivity
intent.putExtra(ConfirmationActivity.EXTRA_TEXT, "id: " + id);
return PendingIntent.getActivity(this, 0, intent, 0);
}
+
+ private PendingIntent makeContentIntent(int id) {
+ Intent intent = new Intent(this, ConfirmationActivity.class);
+ intent.setData(Uri.fromParts("content", "//status_bar_test/content/" + id, null));
+ intent.putExtra(ConfirmationActivity.EXTRA_TITLE, "Content intent");
+ intent.putExtra(ConfirmationActivity.EXTRA_TEXT, "id: " + id);
+ return PendingIntent.getActivity(this, 0, intent, 0);
+ }
}