Merge "test out the new disconnect api" into nyc-dev
diff --git a/NotificationShowcase/res/layout/main.xml b/NotificationShowcase/res/layout/main.xml
index ddad922..d082544 100644
--- a/NotificationShowcase/res/layout/main.xml
+++ b/NotificationShowcase/res/layout/main.xml
@@ -8,5 +8,6 @@
         <Button android:id="@+id/button1" android:text="@string/post_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doPost"></Button>
         <Button android:id="@+id/button2" android:text="@string/remove_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doRemove"></Button>
         <Button android:id="@+id/button3" android:text="@string/prefs_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doPrefs"></Button>
+        <Button android:id="@+id/disable" android:text="@string/no_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doDisable"></Button>
     </LinearLayout>
 </FrameLayout>
diff --git a/NotificationShowcase/res/values/strings.xml b/NotificationShowcase/res/values/strings.xml
index ca534c9..cd7239e 100644
--- a/NotificationShowcase/res/values/strings.xml
+++ b/NotificationShowcase/res/values/strings.xml
@@ -5,6 +5,9 @@
     <string name="post_button_label">Post Notifications</string>
     <string name="remove_button_label">Remove Notifications</string>
     <string name="prefs_button_label">Preferences</string>
+    <string name="disable_button_label">Disable Notifications</string>
+    <string name="enable_button_label">Enable Notifications</string>
+    <string name="no_button_label">No Idea Dog</string>
     <string name="answered">call answered</string>
     <string name="ignored">call ignored</string>
     <string name="full_screen_name">Full Screen Activity</string>
diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationService.java b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationService.java
index 2c21a7e..5fb2a2b 100644
--- a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationService.java
+++ b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationService.java
@@ -19,7 +19,6 @@
 import android.app.AlarmManager;
 import android.app.IntentService;
 import android.app.Notification;
-import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -36,6 +35,7 @@
 import android.os.SystemClock;
 import android.provider.ContactsContract;
 import android.support.v4.app.NotificationCompat;
+import android.support.v4.app.NotificationManagerCompat;
 import android.support.v7.preference.PreferenceManager;
 import android.text.SpannableString;
 import android.text.TextUtils;
@@ -185,8 +185,7 @@
 
     @Override
     protected void onHandleIntent(Intent intent) {
-        NotificationManager noMa =
-                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+        NotificationManagerCompat noMa = NotificationManagerCompat.from(this);
         if (ACTION_DESTROY.equals(intent.getAction())) {
             noMa.cancelAll();
             return;
diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
index 8d1a2fc..2d0d09b 100644
--- a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
+++ b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
@@ -8,8 +8,11 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
+import android.support.v4.app.NotificationManagerCompat;
 import android.view.View;
+import android.widget.Button;
 
 public class NotificationShowcaseActivity extends Activity {
     private static final String TAG = "NotificationShowcase";
@@ -19,6 +22,18 @@
         setContentView(R.layout.main);
     }
 
+    @Override
+    protected void onResume() {
+        super.onResume();
+        Button disableBtn = (Button) findViewById(R.id.disable);
+        NotificationManagerCompat noMa = NotificationManagerCompat.from(this);
+        if(noMa.areNotificationsEnabled()) {
+            disableBtn.setText(R.string.disable_button_label);
+        } else {
+            disableBtn.setText(R.string.enable_button_label);
+        }
+    }
+
     public void doPost(View v) {
         Intent intent = new Intent(NotificationService.ACTION_CREATE);
         intent.setComponent(new ComponentName(this, NotificationService.class));
@@ -36,4 +51,9 @@
         intent.setComponent(new ComponentName(this, SettingsActivity.class));
         startActivity(intent);
     }
+
+    public void doDisable(View v) {
+        startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
+                Uri.parse("package:com.android.example.notificationshowcase")));
+    }
 }
diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/ProgressService.java b/NotificationShowcase/src/com/android/example/notificationshowcase/ProgressService.java
index 799708d..cbc3476 100644
--- a/NotificationShowcase/src/com/android/example/notificationshowcase/ProgressService.java
+++ b/NotificationShowcase/src/com/android/example/notificationshowcase/ProgressService.java
@@ -59,7 +59,7 @@
                 noMa.notify(NotificationService.NOTIFICATION_ID + mId,
                         NotificationService.makeUploadNotification(
                                 ProgressService.this, mProgress, mWhen));
-                mProgress += 10;
+                mProgress += 2;
             if (mProgress <= 100) {
                 handler.postDelayed(this, 1000);
             }