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/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