Debian Codegraph @

tests/StatusBar/src/com/android/statusbartest/TestActivity.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 }