Don't allow system apps to be uninstalled by tapping the trash can button.
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index bdd7066..074a098 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -428,7 +428,7 @@
if (id == MENU_APP_INFO) {
mLauncher.startApplicationDetailsActivity(appInfo.componentName);
} else if (id == MENU_DELETE_APP) {
- mLauncher.startApplicationUninstallActivity(appInfo.componentName);
+ mLauncher.startApplicationUninstallActivity(appInfo);
}
return false;
}
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index 5322f6b..c36f701 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -59,8 +59,6 @@
private View mHandle;
private final Paint mTrashPaint = new Paint();
- private Context mContext = null;
-
public DeleteZone(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -68,8 +66,6 @@
public DeleteZone(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mContext = context;
-
final int srcColor = context.getResources().getColor(R.color.delete_color_filter);
mTrashPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP));
@@ -100,15 +96,7 @@
// On x-large screens, you can uninstall an app by dragging from all apps
if (item instanceof ApplicationInfo && LauncherApplication.isScreenXLarge()) {
- ApplicationInfo appInfo = (ApplicationInfo)item;
- if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
- mLauncher.startApplicationUninstallActivity(appInfo.componentName);
- } else {
- // System applications cannot be installed. For now, show a toast explaining that.
- // We may give them the option of disabling apps this way.
- int messageId = R.string.uninstall_system_app_text;
- Toast.makeText(mContext, messageId, Toast.LENGTH_SHORT).show();
- }
+ mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
}
if (item.container == -1) return;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 637f79f..b0c6b70 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1772,12 +1772,19 @@
startActivity(intent);
}
- void startApplicationUninstallActivity(ComponentName componentName) {
- String packageName = componentName.getPackageName();
- String className = componentName.getClassName();
- Intent intent = new Intent(
- Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
- startActivity(intent);
+ void startApplicationUninstallActivity(ApplicationInfo appInfo) {
+ if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) == 0) {
+ // System applications cannot be installed. For now, show a toast explaining that.
+ // We may give them the option of disabling apps this way.
+ int messageId = R.string.uninstall_system_app_text;
+ Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
+ } else {
+ String packageName = appInfo.componentName.getPackageName();
+ String className = appInfo.componentName.getClassName();
+ Intent intent = new Intent(
+ Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
+ startActivity(intent);
+ }
}
void startActivitySafely(Intent intent, Object tag) {