| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.statusbartest; |
| 18 |
|
| 19 |
import android.app.ListActivity; |
| 20 |
import android.app.Notification; |
| 21 |
import android.app.NotificationManager; |
| 22 |
import android.widget.ArrayAdapter; |
| 23 |
import android.view.View; |
| 24 |
import android.widget.ListView; |
| 25 |
import android.content.Intent; |
| 26 |
import android.os.Vibrator; |
| 27 |
import android.os.Bundle; |
| 28 |
import android.os.Handler; |
| 29 |
import android.util.Log; |
| 30 |
import android.net.Uri; |
| 31 |
import android.os.SystemClock; |
| 32 |
import android.widget.RemoteViews; |
| 33 |
import android.widget.Toast; |
| 34 |
import android.os.PowerManager; |
| 35 |
|
| 36 |
public abstract class TestActivity extends ListActivity |
| 37 |
{ |
| 38 |
Test[] mTests; |
| 39 |
|
| 40 |
protected abstract String tag(); |
| 41 |
protected abstract Test[] tests(); |
| 42 |
|
| 43 |
abstract class Test { |
| 44 |
String name; |
| 45 |
Test(String n) { |
| 46 |
name = n; |
| 47 |
} |
| 48 |
abstract void run(); |
| 49 |
} |
| 50 |
|
| 51 |
@Override |
| 52 |
public void onCreate(Bundle icicle) { |
| 53 |
super.onCreate(icicle); |
| 54 |
|
| 55 |
mTests = tests(); |
| 56 |
|
| 57 |
String[] labels = new String[mTests.length]; |
| 58 |
for (int i=0; i<mTests.length; i++) { |
| 59 |
labels[i] = mTests[i].name; |
| 60 |
} |
| 61 |
|
| 62 |
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, labels)); |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
public void onListItemClick(ListView l, View v, int position, long id) |
| 67 |
{ |
| 68 |
Test t = mTests[position]; |
| 69 |
Log.d(tag(), "Test: " + t.name); |
| 70 |
t.run(); |
| 71 |
} |
| 72 |
|
| 73 |
} |