summaryrefslogtreecommitdiffstats
path: root/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java')
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java85
1 files changed, 73 insertions, 12 deletions
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
index 2f0c173..5d0b155 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
@@ -30,6 +30,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
+import android.os.Handler;
import android.os.Vibrator;
import android.os.Handler;
import android.text.SpannableStringBuilder;
@@ -49,11 +50,14 @@ public class NotificationBuilderTest extends Activity
private final static String TAG = "NotificationTestList";
NotificationManager mNM;
+ Handler mHandler;
+ int mStartDelay;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
+ mHandler = new Handler();
setContentView(R.layout.notification_builder_test);
if (icicle == null) {
setDefaults();
@@ -100,8 +104,13 @@ public class NotificationBuilderTest extends Activity
setChecked(R.id.large_icon_none);
setChecked(R.id.sound_none);
setChecked(R.id.vibrate_none);
+ setChecked(R.id.pri_default);
setChecked(R.id.lights_red);
setChecked(R.id.lights_off);
+ setChecked(R.id.delay_none);
+// setChecked(R.id.default_vibrate);
+// setChecked(R.id.default_sound);
+// setChecked(R.id.default_lights);
}
private View.OnClickListener mClickListener = new View.OnClickListener() {
@@ -183,9 +192,13 @@ public class NotificationBuilderTest extends Activity
}
};
- private void sendNotification(int id) {
+ private void sendNotification(final int id) {
final Notification n = buildNotification(id);
- mNM.notify(id, n);
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ mNM.notify(id, n);
+ }
+ }, mStartDelay);
}
private static CharSequence subst(CharSequence in, char ch, CharSequence sub) {
@@ -323,23 +336,26 @@ public class NotificationBuilderTest extends Activity
// vibrate
switch (getRadioChecked(R.id.group_vibrate)) {
case R.id.vibrate_none:
+ b.setVibrate(null);
break;
- case R.id.vibrate_short:
- b.setVibrate(new long[] { 0, 200 });
+ case R.id.vibrate_zero:
+ b.setVibrate(new long[] { 0 });
break;
- case R.id.vibrate_medium:
- b.setVibrate(new long[] { 0, 500 });
+ case R.id.vibrate_short:
+ b.setVibrate(new long[] { 0, 100 });
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 });
+ b.setVibrate(new long[] { 0, 50, 200, 50, 200, 50, 500,
+ 500, 200, 500, 200, 500, 500,
+ 50, 200, 50, 200, 50 });
break;
}
// lights
- final int color = getRadioInt(R.id.group_lights_color, 0xff0000);
+ final int color = getRadioHex(R.id.group_lights_color, 0xff0000);
int onMs;
int offMs;
switch (getRadioChecked(R.id.group_lights_blink)) {
@@ -365,6 +381,35 @@ public class NotificationBuilderTest extends Activity
b.setLights(color, onMs, offMs);
}
+ // priority
+ switch (getRadioChecked(R.id.group_priority)) {
+ case R.id.pri_min:
+ b.setPriority(Notification.PRIORITY_MIN);
+ break;
+ case R.id.pri_low:
+ b.setPriority(Notification.PRIORITY_LOW);
+ break;
+ case R.id.pri_default:
+ b.setPriority(Notification.PRIORITY_DEFAULT);
+ break;
+ case R.id.pri_high:
+ b.setPriority(Notification.PRIORITY_HIGH);
+ break;
+ case R.id.pri_max:
+ b.setPriority(Notification.PRIORITY_MAX);
+ break;
+ }
+
+ // start delay
+ switch (getRadioChecked(R.id.group_delay)) {
+ case R.id.delay_none:
+ mStartDelay = 0;
+ break;
+ case R.id.delay_5:
+ mStartDelay = 5000;
+ break;
+ }
+
// flags
b.setOngoing(getChecked(R.id.flag_ongoing));
b.setOnlyAlertOnce(getChecked(R.id.flag_once));
@@ -383,7 +428,7 @@ public class NotificationBuilderTest extends Activity
}
b.setDefaults(defaults);
- return b.getNotification();
+ return b.build();
}
private void setChecked(int id) {
@@ -396,14 +441,14 @@ public class NotificationBuilderTest extends Activity
return g.getCheckedRadioButtonId();
}
- private CharSequence getRadioTag(int id) {
+ private String getRadioTag(int id) {
final RadioGroup g = (RadioGroup)findViewById(id);
final View v = findViewById(g.getCheckedRadioButtonId());
- return (CharSequence) v.getTag();
+ return (String) v.getTag();
}
private int getRadioInt(int id, int def) {
- CharSequence str = getRadioTag(id);
+ String str = getRadioTag(id);
if (TextUtils.isEmpty(str)) {
return def;
} else {
@@ -415,6 +460,22 @@ public class NotificationBuilderTest extends Activity
}
}
+ private int getRadioHex(int id, int def) {
+ String str = getRadioTag(id);
+ if (TextUtils.isEmpty(str)) {
+ return def;
+ } else {
+ if (str.startsWith("0x")) {
+ str = str.substring(2);
+ }
+ try {
+ return Integer.parseInt(str.toString(), 16);
+ } catch (NumberFormatException ex) {
+ return def;
+ }
+ }
+ }
+
private boolean getChecked(int id) {
final CompoundButton b = (CompoundButton)findViewById(id);
return b.isChecked();