diff --git a/res/layout/installed_app_details.xml b/res/layout/installed_app_details.xml
index 099df64484c..c41bdb611c7 100644
--- a/res/layout/installed_app_details.xml
+++ b/res/layout/installed_app_details.xml
@@ -50,35 +50,12 @@
android:id="@+id/control_buttons_panel"/>
-
-
-
-
-
+ android:layout_marginLeft="12dip"
+ android:layout_gravity="left"
+ android:text="@string/app_notifications_switch_label" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3dff4c87894..df10d978db1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2508,6 +2508,12 @@
If you disable a built-in app, other apps
may misbehave.
+
+ Turn off notifications?
+
+
+ If you turn off notifications for this app, you may miss important alerts and updates.
+
Storage use
@@ -4025,13 +4031,8 @@
Are you sure you want to remove the user and all associated data from the device?
-
- Notifications
-
- Enabled
-
- Disabled
-
+
+ Show notifications
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index bd771188dec..c2e358c2a7a 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -125,7 +125,7 @@ public class InstalledAppDetails extends Fragment
private Button mForceStopButton;
private Button mClearDataButton;
private Button mMoveAppButton;
- private Switch mNotificationSwitch;
+ private CompoundButton mNotificationSwitch;
private PackageMoveObserver mPackageMoveObserver;
@@ -161,6 +161,7 @@ public class InstalledAppDetails extends Fragment
private static final int DLG_FORCE_STOP = DLG_BASE + 5;
private static final int DLG_MOVE_FAILED = DLG_BASE + 6;
private static final int DLG_DISABLE = DLG_BASE + 7;
+ private static final int DLG_DISABLE_NOTIFICATIONS = DLG_BASE + 8;
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
@@ -279,6 +280,16 @@ public class InstalledAppDetails extends Fragment
}
}
+ private boolean isThisASystemPackage() {
+ try {
+ PackageInfo sys = mPm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
+ return (mPackageInfo != null && mPackageInfo.signatures != null &&
+ sys.signatures[0].equals(mPackageInfo.signatures[0]));
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
private void initUninstallButtons() {
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
boolean enabled = true;
@@ -298,9 +309,7 @@ public class InstalledAppDetails extends Fragment
intent.addCategory(Intent.CATEGORY_HOME);
intent.setPackage(mAppEntry.info.packageName);
List homes = mPm.queryIntentActivities(intent, 0);
- if ((homes != null && homes.size() > 0) ||
- (mPackageInfo != null && mPackageInfo.signatures != null &&
- sys.signatures[0].equals(mPackageInfo.signatures[0]))) {
+ if ((homes != null && homes.size() > 0) || isThisASystemPackage()) {
// Disable button for core system applications.
mUninstallButton.setText(R.string.disable_text);
} else if (mAppEntry.info.enabled) {
@@ -340,7 +349,12 @@ public class InstalledAppDetails extends Fragment
// this does not bode well
}
mNotificationSwitch.setChecked(enabled);
- mNotificationSwitch.setOnCheckedChangeListener(this);
+ if (isThisASystemPackage()) {
+ mNotificationSwitch.setEnabled(false);
+ } else {
+ mNotificationSwitch.setEnabled(true);
+ mNotificationSwitch.setOnCheckedChangeListener(this);
+ }
}
/** Called when the activity is first created. */
@@ -395,7 +409,7 @@ public class InstalledAppDetails extends Fragment
mAskCompatibilityCB = (CheckBox)view.findViewById(R.id.ask_compatibility_cb);
mEnableCompatibilityCB = (CheckBox)view.findViewById(R.id.enable_compatibility_cb);
- mNotificationSwitch = (Switch) view.findViewById(R.id.notification_switch);
+ mNotificationSwitch = (CompoundButton) view.findViewById(R.id.notification_switch);
return view;
}
@@ -851,6 +865,26 @@ public class InstalledAppDetails extends Fragment
})
.setNegativeButton(R.string.dlg_cancel, null)
.create();
+ case DLG_DISABLE_NOTIFICATIONS:
+ return new AlertDialog.Builder(getActivity())
+ .setTitle(getActivity().getText(R.string.app_disable_notifications_dlg_title))
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(getActivity().getText(R.string.app_disable_notifications_dlg_text))
+ .setPositiveButton(R.string.dlg_ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ // Disable the package's notifications
+ getOwner().setNotificationsEnabled(false);
+ }
+ })
+ .setNegativeButton(R.string.dlg_cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ // Re-enable the checkbox
+ getOwner().mNotificationSwitch.setChecked(true);
+ }
+ })
+ .create();
}
throw new IllegalArgumentException("unknown id " + id);
}
@@ -905,7 +939,7 @@ public class InstalledAppDetails extends Fragment
Activity.RESULT_CANCELED, null, null);
}
}
-
+
static class DisableChanger extends AsyncTask