/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.statusbartest; import java.util.GregorianCalendar; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.ContentResolver; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Vibrator; import android.os.Handler; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.util.Log; import android.net.Uri; import android.os.SystemClock; import android.view.View; import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.RemoteViews; import android.os.PowerManager; public class NotificationBuilderTest extends Activity { private final static String TAG = "NotificationTestList"; NotificationManager mNM; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); setContentView(R.layout.notification_builder_test); if (icicle == null) { setDefaults(); } for (int id: new int[] { R.id.clear_1, R.id.clear_2, R.id.clear_3, R.id.clear_4, R.id.clear_5, R.id.clear_6, R.id.clear_7, R.id.clear_8, R.id.clear_9, R.id.clear_10, R.id.notify_1, R.id.notify_2, R.id.notify_3, R.id.notify_4, R.id.notify_5, R.id.notify_6, R.id.notify_7, R.id.notify_8, R.id.notify_9, R.id.notify_10, R.id.ten, R.id.clear_all, }) { findViewById(id).setOnClickListener(mClickListener); } } private void setDefaults() { setChecked(R.id.when_now); setChecked(R.id.icon_surprise); setChecked(R.id.title_medium); setChecked(R.id.text_medium); setChecked(R.id.info_none); setChecked(R.id.number_0); setChecked(R.id.intent_alert); setChecked(R.id.delete_none); setChecked(R.id.full_screen_none); setChecked(R.id.ticker_none); setChecked(R.id.large_icon_none); setChecked(R.id.sound_none); setChecked(R.id.vibrate_none); setChecked(R.id.lights_red); setChecked(R.id.lights_off); } private View.OnClickListener mClickListener = new View.OnClickListener() { public void onClick(View v) { switch (v.getId()) { case R.id.clear_1: mNM.cancel(1); break; case R.id.clear_2: mNM.cancel(2); break; case R.id.clear_3: mNM.cancel(3); break; case R.id.clear_4: mNM.cancel(4); break; case R.id.clear_5: mNM.cancel(5); break; case R.id.clear_6: mNM.cancel(6); break; case R.id.clear_7: mNM.cancel(7); break; case R.id.clear_8: mNM.cancel(8); break; case R.id.clear_9: mNM.cancel(9); break; case R.id.clear_10: mNM.cancel(10); break; case R.id.notify_1: sendNotification(1); break; case R.id.notify_2: sendNotification(2); break; case R.id.notify_3: sendNotification(3); break; case R.id.notify_4: sendNotification(4); break; case R.id.notify_5: sendNotification(5); break; case R.id.notify_6: sendNotification(6); break; case R.id.notify_7: sendNotification(7); break; case R.id.notify_8: sendNotification(8); break; case R.id.notify_9: sendNotification(9); break; case R.id.notify_10: sendNotification(10); break; case R.id.ten: { for (int id=1; id<=10; id++) { sendNotification(id); } break; } case R.id.clear_all: { for (int id=1; id<=10; id++) { mNM.cancel(id); } break; } } } }; private void sendNotification(int id) { final Notification n = buildNotification(id); mNM.notify(id, n); } private static CharSequence subst(CharSequence in, char ch, CharSequence sub) { int i=0; SpannableStringBuilder edit = new SpannableStringBuilder(in); while (i