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 17package com.android.statusbartest; 18 19import android.app.ListActivity; 20import android.app.Notification; 21import android.app.NotificationManager; 22import android.widget.ArrayAdapter; 23import android.view.View; 24import android.widget.ListView; 25import android.content.Intent; 26import android.os.Vibrator; 27import android.os.Bundle; 28import android.os.Handler; 29import android.util.Log; 30import android.net.Uri; 31import android.os.SystemClock; 32import android.widget.RemoteViews; 33import android.widget.Toast; 34import android.os.PowerManager; 35 36public 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} 74