summaryrefslogtreecommitdiffstats
path: root/tests/StatusBar
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2010-06-23 15:29:59 -0400
committerDaniel Sandler <dsandler@android.com>2010-06-24 22:09:35 -0400
commit8896783dc1d31c5274b277c364da0ffe7cc27cca (patch)
tree1ca6a3aef94fe193b0cc4379fcc708b512af764b /tests/StatusBar
parent87160757e827e8e158d233de09d70e7128184729 (diff)
downloadframeworks_base-8896783dc1d31c5274b277c364da0ffe7cc27cca.zip
frameworks_base-8896783dc1d31c5274b277c364da0ffe7cc27cca.tar.gz
frameworks_base-8896783dc1d31c5274b277c364da0ffe7cc27cca.tar.bz2
Updated StatusBar test app for new notifications API.
New actions: - Toggle activity's immersive mode - Post a priority notification with fullScreenIntent that launches an alert-like activity Change-Id: Ie38372209985577b6db856924c19914c000e1cec
Diffstat (limited to 'tests/StatusBar')
-rw-r--r--tests/StatusBar/Android.mk2
-rw-r--r--tests/StatusBar/AndroidManifest.xml2
-rw-r--r--tests/StatusBar/res/layout/test_alert.xml57
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java50
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java37
5 files changed, 148 insertions, 0 deletions
diff --git a/tests/StatusBar/Android.mk b/tests/StatusBar/Android.mk
index 18fcad0..502657f 100644
--- a/tests/StatusBar/Android.mk
+++ b/tests/StatusBar/Android.mk
@@ -8,4 +8,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := StatusBarTest
LOCAL_CERTIFICATE := platform
+LOCAL_PROGUARD_ENABLED := disabled
+
include $(BUILD_PACKAGE)
diff --git a/tests/StatusBar/AndroidManifest.xml b/tests/StatusBar/AndroidManifest.xml
index 21fb951..c1ca618 100644
--- a/tests/StatusBar/AndroidManifest.xml
+++ b/tests/StatusBar/AndroidManifest.xml
@@ -35,5 +35,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="TestAlertActivity" android:theme="@android:style/Theme.Dialog">
+ </activity>
</application>
</manifest>
diff --git a/tests/StatusBar/res/layout/test_alert.xml b/tests/StatusBar/res/layout/test_alert.xml
new file mode 100644
index 0000000..325146c
--- /dev/null
+++ b/tests/StatusBar/res/layout/test_alert.xml
@@ -0,0 +1,57 @@
+<?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:gravity="center">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ >
+
+ <TextView android:id="@+id/alertTitle"
+ style="?android:attr/textAppearanceLarge"
+ android:padding="5dip"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/ButtonBar">
+
+ <Button
+ android:id="@+id/snooze"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="3"
+ android:onClick="dismiss"
+ android:text="Snooze" />
+
+ <!-- blank stretchable view -->
+ <View
+ android:layout_width="2dip"
+ android:layout_height="2dip"
+ android:layout_gravity="fill_horizontal"
+ android:layout_weight="1"/>
+
+ <Button
+ android:id="@+id/dismiss"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="3"
+ android:onClick="dismiss"
+ android:text="Dismiss" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index cb94e52..8c343b5 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -23,6 +23,7 @@ import android.widget.ArrayAdapter;
import android.view.View;
import android.widget.ListView;
import android.content.Intent;
+import android.app.PendingIntent;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.StatusBarManager;
@@ -35,6 +36,8 @@ import android.os.SystemClock;
import android.widget.RemoteViews;
import android.widget.Toast;
import android.os.PowerManager;
+import android.view.Window;
+import android.view.WindowManager;
public class StatusBarTest extends TestActivity
{
@@ -57,6 +60,53 @@ public class StatusBarTest extends TestActivity
}
private Test[] mTests = new Test[] {
+ new Test("Hide") {
+ public void run() {
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ win.setAttributes(winParams);
+ }
+ },
+ new Test("Show") {
+ public void run() {
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ win.setAttributes(winParams);
+ }
+ },
+ new Test("Immersive: Enter") {
+ public void run() {
+ setImmersive(true);
+ }
+ },
+ new Test("Immersive: Exit") {
+ public void run() {
+ setImmersive(false);
+ }
+ },
+ new Test("Priority notification") {
+ public void run() {
+ Notification not = new Notification(StatusBarTest.this,
+ R.drawable.ic_statusbar_missedcall,
+ "tick tick tick",
+ System.currentTimeMillis()-(1000*60*60*24),
+ "(453) 123-2328",
+ "", null
+ );
+ not.flags |= Notification.FLAG_HIGH_PRIORITY;
+ Intent fullScreenIntent = new Intent(StatusBarTest.this, TestAlertActivity.class);
+ int id = (int)System.currentTimeMillis(); // XXX HAX
+ fullScreenIntent.putExtra("id", id);
+ not.fullScreenIntent = PendingIntent.getActivity(
+ StatusBarTest.this,
+ 0,
+ fullScreenIntent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ mNotificationManager.notify(id, not);
+ }
+ },
new Test("Disable Alerts") {
public void run() {
mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ALERTS);
diff --git a/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java b/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java
new file mode 100644
index 0000000..f5876d0
--- /dev/null
+++ b/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java
@@ -0,0 +1,37 @@
+package com.android.statusbartest;
+
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class TestAlertActivity extends Activity {
+ int mId;
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d("StatusBarTest", "TestAlertActivity.onResume");
+ Intent intent = getIntent();
+ mId = intent.getIntExtra("id", -1);
+ Log.d("StatusBarTest", "Remembering notification id=" + mId);
+ setContentView(R.layout.test_alert);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ Log.d("StatusBarTest", "onPause: Canceling notification id=" + mId);
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.cancel(mId);
+ finish();
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ public void dismiss(View v) {
+ Log.d("StatusBarTest", "TestAlertActivity.dismiss");
+ finish();
+ }
+}