Support uninstalling an app by dragging from all apps to trash can.
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index 737d198..b053fa0 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -16,6 +16,7 @@
package com.android.launcher2;
+import android.content.ComponentName;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.PorterDuff;
@@ -65,13 +66,13 @@
// in onDrop, because it allows us to reject the drop (by returning false)
// so that the object being dragged isn't removed from the home screen.
- String packageName = null;
+ ComponentName componentName = null;
if (dragInfo instanceof ApplicationInfo) {
- packageName = ((ApplicationInfo)dragInfo).componentName.getPackageName();
+ componentName = ((ApplicationInfo)dragInfo).componentName;
} else if (dragInfo instanceof ShortcutInfo) {
- packageName = ((ShortcutInfo)dragInfo).intent.getComponent().getPackageName();
+ componentName = ((ShortcutInfo)dragInfo).intent.getComponent();
}
- mLauncher.startApplicationDetailsActivity(packageName);
+ mLauncher.startApplicationDetailsActivity(componentName);
return false;
}
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index b11b1dd..91ff56f 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -16,24 +16,25 @@
package com.android.launcher2;
-import android.widget.ImageView;
+import com.android.launcher.R;
+
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.animation.TranslateAnimation;
-import android.view.animation.Animation;
-import android.view.animation.AnimationSet;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.AlphaAnimation;
import android.graphics.RectF;
import android.graphics.drawable.TransitionDrawable;
-
-import com.android.launcher.R;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Animation;
+import android.view.animation.AnimationSet;
+import android.view.animation.TranslateAnimation;
+import android.widget.ImageView;
public class DeleteZone extends ImageView implements DropTarget, DragController.DragListener {
private static final int ORIENTATION_HORIZONTAL = 1;
@@ -93,21 +94,26 @@
DragView dragView, Object dragInfo) {
final ItemInfo item = (ItemInfo) dragInfo;
+ // On x-large screens, you can uninstall an app by dragging from all apps
+ if (item instanceof ApplicationInfo && LauncherApplication.isScreenXLarge()) {
+ ApplicationInfo appInfo = (ApplicationInfo)item;
+ mLauncher.startApplicationUninstallActivity(appInfo.componentName);
+ }
+
if (item.container == -1) return;
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
if (item instanceof LauncherAppWidgetInfo) {
mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
}
- } else {
- if (source instanceof UserFolder) {
- final UserFolder userFolder = (UserFolder) source;
- final UserFolderInfo userFolderInfo = (UserFolderInfo) userFolder.getInfo();
- // Item must be a ShortcutInfo otherwise it couldn't have been in the folder
- // in the first place.
- userFolderInfo.remove((ShortcutInfo)item);
- }
+ } else if (source instanceof UserFolder) {
+ final UserFolder userFolder = (UserFolder) source;
+ final UserFolderInfo userFolderInfo = (UserFolderInfo) userFolder.getInfo();
+ // Item must be a ShortcutInfo otherwise it couldn't have been in the folder
+ // in the first place.
+ userFolderInfo.remove((ShortcutInfo)item);
}
+
if (item instanceof UserFolderInfo) {
final UserFolderInfo userFolderInfo = (UserFolderInfo)item;
LauncherModel.deleteUserFolderContentsFromDatabase(mLauncher, userFolderInfo);
@@ -119,6 +125,7 @@
appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
}
}
+
LauncherModel.deleteItemFromDatabase(mLauncher, item);
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 4e33985..bee69b9 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1765,12 +1765,21 @@
}
}
- void startApplicationDetailsActivity(String packageName) {
+ void startApplicationDetailsActivity(ComponentName componentName) {
+ String packageName = componentName.getPackageName();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null));
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 startActivitySafely(Intent intent, Object tag) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
@@ -2277,18 +2286,21 @@
hideOrShowToolbarButton(true, allAppsButton, showSeq);
hideOrShowToolbarButton(true, configureButton, showSeq);
hideOrShowToolbarButton(false, marketButton, hideSeq);
+ mDeleteZone.setHandle(allAppsButton);
break;
case ALL_APPS:
hideOrShowToolbarButton(true, configureButton, showSeq);
hideOrShowToolbarButton(true, marketButton, showSeq);
hideOrShowToolbarButton(false, searchButton, hideSeq);
hideOrShowToolbarButton(false, allAppsButton, hideSeq);
+ mDeleteZone.setHandle(marketButton);
break;
case CUSTOMIZE:
hideOrShowToolbarButton(true, allAppsButton, showSeq);
hideOrShowToolbarButton(false, searchButton, hideSeq);
hideOrShowToolbarButton(false, marketButton, hideSeq);
hideOrShowToolbarButton(false, configureButton, hideSeq);
+ mDeleteZone.setHandle(allAppsButton);
break;
}
}