diff options
author | Mathew Inwood <mathewi@google.com> | 2013-11-25 17:01:34 +0000 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-06-06 22:54:20 -0700 |
commit | fd5427342d2bdd10bb45e9c54665bed9ec5424e8 (patch) | |
tree | bcf8444dbc909deebc485f9dd5735a2fe9d5a3d4 /src/com/android/launcher3 | |
parent | 88eb58f2f75c42451b565876d29f23a61db983ce (diff) | |
download | android_packages_apps_Trebuchet-fd5427342d2bdd10bb45e9c54665bed9ec5424e8.tar.gz android_packages_apps_Trebuchet-fd5427342d2bdd10bb45e9c54665bed9ec5424e8.tar.bz2 android_packages_apps_Trebuchet-fd5427342d2bdd10bb45e9c54665bed9ec5424e8.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/Workspace.java | 10 |
5 files changed, 47 insertions, 3 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 11e85f8c0..39f5a2184 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -996,6 +996,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 73daf3131..e40647b6f 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -96,7 +96,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) { @@ -182,6 +182,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. @@ -192,15 +193,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 566568deb..f454b7d44 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -810,6 +810,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/Workspace.java b/src/com/android/launcher3/Workspace.java index 8c628e72c..2605121e7 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -4370,6 +4370,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 } |