diff options
author | Mathew Inwood <mathewi@google.com> | 2013-11-25 17:01:34 +0000 |
---|---|---|
committer | Mathew Inwood <mathewi@google.com> | 2013-11-28 10:17:07 +0000 |
commit | 1eeb3fc9d874d98dfb43883d17efb4202d83d88a (patch) | |
tree | 86e1bc78a3fb98957bc3a3a61b4b60f2b020cf99 /src/com/android/launcher3 | |
parent | 0a23daaca14ab7fd107ee3e4043b5793760e02c1 (diff) | |
download | android_packages_apps_Trebuchet-1eeb3fc9d874d98dfb43883d17efb4202d83d88a.tar.gz android_packages_apps_Trebuchet-1eeb3fc9d874d98dfb43883d17efb4202d83d88a.tar.bz2 android_packages_apps_Trebuchet-1eeb3fc9d874d98dfb43883d17efb4202d83d88a.zip |
Generalize support for 'App Info', 'Uninstall' and 'Delete'
This allows other DragSource's to allow this behaviour, instead of it being
tied to specific source types.
Change-Id: I06b7c39b1b34a0ae141245bcc13b6a0873a4c0fd
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/AppsCustomizePagedView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/DeleteDropTarget.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher3/DragSource.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/Folder.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/InfoDropTarget.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 10 |
6 files changed, 48 insertions, 8 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 688ff82aa..2865bc5d5 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -916,6 +916,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } @Override + public boolean supportsAppInfoDropTarget() { + return true; + } + + @Override + public boolean supportsDeleteDropTarget() { + return false; + } + + @Override public float getIntrinsicIconScaleFactor() { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index 4023dafb6..7e0e5ebd7 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -95,7 +95,7 @@ public class DeleteDropTarget extends ButtonDropTarget { } private boolean isAllAppsApplication(DragSource source, Object info) { - return (source instanceof AppsCustomizePagedView) && (info instanceof AppInfo); + return source.supportsAppInfoDropTarget() && (info instanceof AppInfo); } private boolean isAllAppsWidget(DragSource source, Object info) { if (source instanceof AppsCustomizePagedView) { @@ -175,6 +175,7 @@ public class DeleteDropTarget extends ButtonDropTarget { boolean isVisible = true; boolean useUninstallLabel = !AppsCustomizePagedView.DISABLE_ALL_APPS && isAllAppsApplication(source, info); + boolean useDeleteLabel = !useUninstallLabel && source.supportsDeleteDropTarget(); // If we are dragging an application from AppsCustomize, only show the control if we can // delete the app (it was downloaded), and rename the string to "uninstall" in such a case. @@ -185,15 +186,17 @@ public class DeleteDropTarget extends ButtonDropTarget { if (useUninstallLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null); - } else { + } else if (useDeleteLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null); + } else { + isVisible = false; } mCurrentDrawable = (TransitionDrawable) getCurrentDrawable(); mActive = isVisible; resetHoverColor(); ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE); - if (getText().length() > 0) { + if (isVisible && getText().length() > 0) { setText(useUninstallLabel ? R.string.delete_target_uninstall_label : R.string.delete_target_label); } diff --git a/src/com/android/launcher3/DragSource.java b/src/com/android/launcher3/DragSource.java index cca9ab1a4..7369eeac2 100644 --- a/src/com/android/launcher3/DragSource.java +++ b/src/com/android/launcher3/DragSource.java @@ -30,6 +30,17 @@ public interface DragSource { */ boolean supportsFlingToDelete(); + /** + * @return whether items dragged from this source supports 'App Info' + */ + boolean supportsAppInfoDropTarget(); + + /** + * @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove + * a shortcut. + */ + boolean supportsDeleteDropTarget(); + /* * @return the scale of the icons over the workspace icon size */ diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 1d234ff8a..50e200092 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -801,6 +801,16 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return true; } + @Override + public boolean supportsAppInfoDropTarget() { + return false; + } + + @Override + public boolean supportsDeleteDropTarget() { + return true; + } + public void onFlingToDelete(DragObject d, int x, int y, PointF vec) { // Do nothing } diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java index 2ad43b6ff..374238c49 100644 --- a/src/com/android/launcher3/InfoDropTarget.java +++ b/src/com/android/launcher3/InfoDropTarget.java @@ -62,10 +62,6 @@ public class InfoDropTarget extends ButtonDropTarget { } } - private boolean isFromAllApps(DragSource source) { - return (source instanceof AppsCustomizePagedView); - } - @Override public boolean acceptDrop(DragObject d) { // acceptDrop is called just before onDrop. We do the work here, rather than @@ -93,7 +89,7 @@ public class InfoDropTarget extends ButtonDropTarget { boolean isVisible = true; // Hide this button unless we are dragging something from AllApps - if (!isFromAllApps(source)) { + if (!source.supportsAppInfoDropTarget()) { isVisible = false; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 02949e7dd..4fd57c1b8 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -4213,6 +4213,16 @@ public class Workspace extends SmoothPagedView } @Override + public boolean supportsAppInfoDropTarget() { + return false; + } + + @Override + public boolean supportsDeleteDropTarget() { + return true; + } + + @Override public void onFlingToDelete(DragObject d, int x, int y, PointF vec) { // Do nothing } |