1ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler// dummy notifications for demos
2ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler// for anandx@google.com by dsandler@google.com
3ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler
4ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandlerpackage com.android.example.notificationshowcase;
5ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler
6ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandlerimport android.app.Activity;
720f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wrenimport android.app.NotificationManager;
866401a2cc8bfe9b8605d8383f8970947840c4de2Chris Wrenimport android.content.ComponentName;
920f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wrenimport android.content.Context;
10c407ce98db6f05b619c2fe4d0b7f85964cc9ba93Daniel Sandlerimport android.content.Intent;
117e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wrenimport android.net.Uri;
12ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandlerimport android.os.Bundle;
137e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wrenimport android.support.v4.app.NotificationManagerCompat;
1420f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wrenimport android.view.View;
157e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wrenimport android.widget.Button;
16ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler
17ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandlerpublic class NotificationShowcaseActivity extends Activity {
182c223ee3c280612fcf4d9536b94ad08c9f5f7431Daniel Sandler    private static final String TAG = "NotificationShowcase";
19ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler    @Override
20ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler    public void onCreate(Bundle savedInstanceState) {
21ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler        super.onCreate(savedInstanceState);
22ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler        setContentView(R.layout.main);
2320f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    }
2420f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren
257e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren    @Override
267e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren    protected void onResume() {
277e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        super.onResume();
287e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        Button disableBtn = (Button) findViewById(R.id.disable);
297e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        NotificationManagerCompat noMa = NotificationManagerCompat.from(this);
307e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        if(noMa.areNotificationsEnabled()) {
317e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren            disableBtn.setText(R.string.disable_button_label);
327e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        } else {
337e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren            disableBtn.setText(R.string.enable_button_label);
347e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        }
357e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren    }
367e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren
3720f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    public void doPost(View v) {
3856e1b4d8207e9ae177111bc824877a780723287bChris Wren        Intent intent = new Intent(NotificationService.ACTION_CREATE);
3956e1b4d8207e9ae177111bc824877a780723287bChris Wren        intent.setComponent(new ComponentName(this, NotificationService.class));
4056e1b4d8207e9ae177111bc824877a780723287bChris Wren        startService(intent);
4120f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    }
4220f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren
4320f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    public void doRemove(View v) {
4420f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        Intent intent = new Intent(NotificationService.ACTION_DESTROY);
4520f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        intent.setComponent(new ComponentName(this, NotificationService.class));
4620f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        startService(intent);
4720f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    }
4820f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren
4920f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren    public void doPrefs(View v) {
5020f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        Intent intent = new Intent();
5120f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        intent.setComponent(new ComponentName(this, SettingsActivity.class));
5220f6c51ab018c45347bc99ccccb17f45cbfb9fc0Chris Wren        startActivity(intent);
53ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler    }
547e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren
557e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren    public void doDisable(View v) {
567e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren        startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
577e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren                Uri.parse("package:com.android.example.notificationshowcase")));
587e3e666f243586c0dc97853ce92bee9e4f4d1d3bChris Wren    }
59ff467b19db77e65f7e4014a9b6a7c3bfb55b71ddDaniel Sandler}
60