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
This commit is contained in:
Tony Wickham
2015-10-01 13:04:22 -07:00
parent b99d74bb05
commit 9aae47f8a6
12 changed files with 46 additions and 30 deletions

View File

@@ -46,7 +46,14 @@ public class DeleteDropTarget extends ButtonDropTarget {
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 @@ public class DeleteDropTarget extends ButtonDropTarget {
@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