summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/InfoDropTarget.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/InfoDropTarget.java')
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index d444640e6..191becf13 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -16,12 +16,19 @@
package com.android.launcher3;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.util.AttributeSet;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.android.launcher3.compat.LauncherAppsCompat;
public class InfoDropTarget extends UninstallDropTarget {
+ private static final String TAG = "InfoDropTarget";
+
public InfoDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -39,10 +46,19 @@ public class InfoDropTarget extends UninstallDropTarget {
setDrawable(R.drawable.ic_info_launcher);
}
+ @Override
+ void completeDrop(DragObject d) {
+ DropTargetResultCallback callback = d.dragSource instanceof DropTargetResultCallback
+ ? (DropTargetResultCallback) d.dragSource : null;
+ startDetailsActivityForInfo(d.dragInfo, mLauncher, callback);
+ }
+
/**
* @return Whether the activity was started.
*/
- public static boolean startDetailsActivityForInfo(ItemInfo info, Launcher launcher) {
+ public static boolean startDetailsActivityForInfo(
+ ItemInfo info, Launcher launcher, DropTargetResultCallback callback) {
+ boolean result = false;
ComponentName componentName = null;
if (info instanceof AppInfo) {
componentName = ((AppInfo) info).componentName;
@@ -54,23 +70,28 @@ public class InfoDropTarget extends UninstallDropTarget {
componentName = ((LauncherAppWidgetInfo) info).providerName;
}
if (componentName != null) {
- launcher.startApplicationDetailsActivity(componentName, info.user);
- return true;
+ try {
+ LauncherAppsCompat.getInstance(launcher)
+ .showAppDetailsForProfile(componentName, info.user);
+ result = true;
+ } catch (SecurityException | ActivityNotFoundException e) {
+ Toast.makeText(launcher, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+ Log.e(TAG, "Unable to launch settings", e);
+ }
}
- return false;
- }
- @Override
- protected boolean startActivityWithUninstallAffordance(DragObject d) {
- return startDetailsActivityForInfo(d.dragInfo, mLauncher);
+ if (callback != null) {
+ sendUninstallResult(launcher, result, componentName, info.user, callback);
+ }
+ return result;
}
@Override
protected boolean supportsDrop(DragSource source, ItemInfo info) {
- return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info);
+ return source.supportsAppInfoDropTarget() && supportsDrop(info);
}
- public static boolean supportsDrop(Context context, ItemInfo info) {
+ public static boolean supportsDrop(ItemInfo info) {
return info instanceof AppInfo || info instanceof ShortcutInfo
|| info instanceof PendingAddItemInfo || info instanceof LauncherAppWidgetInfo;
}