Added 'Cancel' drop target from all apps and widget picker.

- Reuse DeleteDropTarget since it's the same effect, but with "Cancel"
  instead of "Remove" if supportsDeleteDropTarget() returns false.
- Rename related strings (but not their values)

Bug: 24104015
Bug: 24099531
Change-Id: Ia9fbcaa17bb17f7aa31df1f830298da01544c178
diff --git a/src/com/android/launcher3/AppInfoDropTargetBar.java b/src/com/android/launcher3/AppInfoDropTargetBar.java
index 31ff42a..99a1f41 100644
--- a/src/com/android/launcher3/AppInfoDropTargetBar.java
+++ b/src/com/android/launcher3/AppInfoDropTargetBar.java
@@ -54,12 +54,12 @@
     }
 
     @Override
-    public void showDropTarget() {
+    public void showDropTargets() {
         animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION);
     }
 
     @Override
-    public void hideDropTarget() {
+    public void hideDropTargets() {
         animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION);
     }
 
diff --git a/src/com/android/launcher3/BaseDropTargetBar.java b/src/com/android/launcher3/BaseDropTargetBar.java
index f478a35..303acd7 100644
--- a/src/com/android/launcher3/BaseDropTargetBar.java
+++ b/src/com/android/launcher3/BaseDropTargetBar.java
@@ -101,7 +101,7 @@
      */
     @Override
     public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
-        showDropTarget();
+        showDropTargets();
     }
 
     /**
@@ -115,15 +115,15 @@
     @Override
     public void onDragEnd() {
         if (!mDeferOnDragEnd) {
-            hideDropTarget();
+            hideDropTargets();
         } else {
             mDeferOnDragEnd = false;
         }
     }
 
-    public abstract void showDropTarget();
+    public abstract void showDropTargets();
 
-    public abstract void hideDropTarget();
+    public abstract void hideDropTargets();
 
     public abstract void enableAccessibleDrag(boolean enable);
 
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index a19f00d..4b94a1a 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -65,6 +65,8 @@
     protected ColorStateList mOriginalTextColor;
     protected Drawable mDrawable;
 
+    protected DeviceProfile mDeviceProfile;
+
     private AnimatorSet mCurrentColorAnim;
     @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
 
@@ -84,8 +86,8 @@
         mOriginalTextColor = getTextColors();
 
         // Remove the text in the Phone UI in landscape
-        DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile();
-        if (grid.isVerticalBarLayout()) {
+        mDeviceProfile = ((Launcher) getContext()).getDeviceProfile();
+        if (mDeviceProfile.isVerticalBarLayout()) {
             setText("");
         }
     }
@@ -193,7 +195,7 @@
     }
 
     @Override
-    public final void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+    public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
         mActive = supportsDrop(source, info);
         mDrawable.setColorFilter(null);
         if (mCurrentColorAnim != null) {
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index b792edd..173e6ab 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -46,7 +46,14 @@
         setDrawable(R.drawable.ic_remove_launcher);
     }
 
-    public static boolean supportsDrop(ItemInfo info) {
+    @Override
+    public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+        super.onDragStart(source, info, dragAction);
+        setTextBasedOnDragSource(source);
+    }
+
+    /** @return true for items that should have a "Remove" action in accessibility. */
+    public static boolean supportsAccessibleDrop(ItemInfo info) {
         return (info instanceof ShortcutInfo)
                 || (info instanceof LauncherAppWidgetInfo)
                 || (info instanceof FolderInfo);
@@ -54,7 +61,17 @@
 
     @Override
     protected boolean supportsDrop(DragSource source, ItemInfo info) {
-        return source.supportsDeleteDropTarget() && supportsDrop(info);
+        return true;
+    }
+
+    /**
+     * Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
+     */
+    public void setTextBasedOnDragSource(DragSource dragSource) {
+        if (!mDeviceProfile.isVerticalBarLayout()) {
+            setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label
+                    : android.R.string.cancel);
+        }
     }
 
     @Override
diff --git a/src/com/android/launcher3/DragSource.java b/src/com/android/launcher3/DragSource.java
index 2a1346e..da32d82 100644
--- a/src/com/android/launcher3/DragSource.java
+++ b/src/com/android/launcher3/DragSource.java
@@ -37,7 +37,7 @@
 
     /**
      * @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove
-     * a shortcut.
+     * a shortcut.) If this returns false, the drop target will say "Cancel" instead of "Remove."
      */
     boolean supportsDeleteDropTarget();
 
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
index 878a474..9bda8b8 100644
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ b/src/com/android/launcher3/SearchDropTargetBar.java
@@ -103,12 +103,12 @@
     }
 
     @Override
-    public void showDropTarget() {
+    public void showDropTargets() {
         animateToState(State.DROP_TARGET, DEFAULT_DRAG_FADE_DURATION);
     }
 
     @Override
-    public void hideDropTarget() {
+    public void hideDropTargets() {
         animateToState(State.SEARCH_BAR, DEFAULT_DRAG_FADE_DURATION);
     }
 
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index f8bf5a8..f5db6c0 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -75,11 +75,11 @@
         mLauncher = launcher;
 
         mActions.put(REMOVE, new AccessibilityAction(REMOVE,
-                launcher.getText(R.string.delete_target_label)));
+                launcher.getText(R.string.remove_drop_target_label)));
         mActions.put(INFO, new AccessibilityAction(INFO,
-                launcher.getText(R.string.info_target_label)));
+                launcher.getText(R.string.app_info_drop_target_label)));
         mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL,
-                launcher.getText(R.string.delete_target_uninstall_label)));
+                launcher.getText(R.string.uninstall_drop_target_label)));
         mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE,
                 launcher.getText(R.string.action_add_to_workspace)));
         mActions.put(MOVE, new AccessibilityAction(MOVE,
@@ -96,7 +96,7 @@
         if (!(host.getTag() instanceof ItemInfo)) return;
         ItemInfo item = (ItemInfo) host.getTag();
 
-        if (DeleteDropTarget.supportsDrop(item)) {
+        if (DeleteDropTarget.supportsAccessibleDrop(item)) {
             info.addAction(mActions.get(REMOVE));
         }
         if (UninstallDropTarget.supportsDrop(host.getContext(), item)) {
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 3aed4b6..a4bd753 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -455,9 +455,6 @@
             dropTarget = dropTargetOverride;
         } else {
             vec = isFlingingToDelete(mDragObject.dragSource);
-            if (!DeleteDropTarget.supportsDrop(mDragObject.dragInfo)) {
-                vec = null;
-            }
             if (vec != null) {
                 dropTarget = mFlingToDeleteDropTarget;
             } else {
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 0f5ca15..143f989 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -271,7 +271,7 @@
 
     @Override
     public boolean supportsFlingToDelete() {
-        return false;
+        return true;
     }
 
     @Override