Merge "Dragging app from workspace to App Info doesn't consume the app." into ub-launcher3-master
This commit is contained in:
@@ -20,7 +20,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class InfoDropTarget extends ButtonDropTarget {
|
||||
public class InfoDropTarget extends UninstallDropTarget {
|
||||
|
||||
public InfoDropTarget(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
@@ -39,7 +39,10 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
setDrawable(R.drawable.ic_info_launcher);
|
||||
}
|
||||
|
||||
public static void startDetailsActivityForInfo(ItemInfo info, Launcher launcher) {
|
||||
/**
|
||||
* @return Whether the activity was started.
|
||||
*/
|
||||
public static boolean startDetailsActivityForInfo(ItemInfo info, Launcher launcher) {
|
||||
ComponentName componentName = null;
|
||||
if (info instanceof AppInfo) {
|
||||
componentName = ((AppInfo) info).componentName;
|
||||
@@ -50,7 +53,14 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
}
|
||||
if (componentName != null) {
|
||||
launcher.startApplicationDetailsActivity(componentName, info.user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean startActivityWithUninstallAffordance(DragObject d) {
|
||||
return startDetailsActivityForInfo(d.dragInfo, mLauncher);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,9 +72,4 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
return info instanceof AppInfo || info instanceof ShortcutInfo
|
||||
|| info instanceof PendingAddItemInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
void completeDrop(DragObject d) {
|
||||
startDetailsActivityForInfo(d.dragInfo, mLauncher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
|
||||
void completeDrop(final DragObject d) {
|
||||
final Pair<ComponentName, Integer> componentInfo = getAppInfoFlags(d.dragInfo);
|
||||
final UserHandleCompat user = d.dragInfo.user;
|
||||
if (startUninstallActivity(mLauncher, d.dragInfo)) {
|
||||
if (startActivityWithUninstallAffordance(d)) {
|
||||
|
||||
final Runnable checkIfUninstallWasSuccess = new Runnable() {
|
||||
@Override
|
||||
@@ -99,6 +99,10 @@ public class UninstallDropTarget extends ButtonDropTarget {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean startActivityWithUninstallAffordance(DragObject d) {
|
||||
return startUninstallActivity(mLauncher, d.dragInfo);
|
||||
}
|
||||
|
||||
public static boolean startUninstallActivity(Launcher launcher, ItemInfo info) {
|
||||
final Pair<ComponentName, Integer> componentInfo = getAppInfoFlags(info);
|
||||
final UserHandleCompat user = info.user;
|
||||
@@ -115,7 +119,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
|
||||
/**
|
||||
* Interface defining an object that can provide uninstallable drag objects.
|
||||
*/
|
||||
public static interface UninstallSource {
|
||||
public interface UninstallSource {
|
||||
|
||||
/**
|
||||
* A pending uninstall operation was complete.
|
||||
|
||||
Reference in New Issue
Block a user