Enabling accessibility drag and drop in folder
> Moving DragAndDropAccessibilityDelegate to a separate class
> Using getFocusedVirtualView() instead of using DownX and downY
> Updating various accessibility strings
Bug: 19776741
Change-Id: I85c2551d4d6172c30702e68f41b114bb999655b6
diff --git a/src/com/android/launcher3/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/LauncherAccessibilityDelegate.java
index a60e160..4255fa4 100644
--- a/src/com/android/launcher3/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/LauncherAccessibilityDelegate.java
@@ -25,24 +25,25 @@
public static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace;
public static final int MOVE = R.id.action_move;
- enum DragType {
+ public enum DragType {
ICON,
FOLDER,
WIDGET
}
public static class DragInfo {
- DragType dragType;
- ItemInfo info;
- View item;
+ public DragType dragType;
+ public ItemInfo info;
+ public View item;
}
- private DragInfo mDragInfo = null;
-
private final SparseArray<AccessibilityAction> mActions =
new SparseArray<AccessibilityAction>();
@Thunk final Launcher mLauncher;
+ private DragInfo mDragInfo = null;
+ private AccessibilityDragSource mDragSource = null;
+
public LauncherAccessibilityDelegate(Launcher launcher) {
mLauncher = launcher;
@@ -197,10 +198,23 @@
Rect pos = new Rect();
mLauncher.getDragLayer().getDescendantRectRelativeToSelf(item, pos);
-
mLauncher.getDragController().prepareAccessibleDrag(pos.centerX(), pos.centerY());
- mLauncher.getWorkspace().enableAccessibleDrag(true);
- mLauncher.getWorkspace().startDrag(cellInfo, true);
+
+ Workspace workspace = mLauncher.getWorkspace();
+
+ Folder folder = workspace.getOpenFolder();
+ if (folder != null) {
+ if (folder.getItemsInReadingOrder().contains(item)) {
+ mDragSource = folder;
+ } else {
+ mLauncher.closeFolder();
+ }
+ }
+ if (mDragSource == null) {
+ mDragSource = workspace;
+ }
+ mDragSource.enableAccessibleDrag(true);
+ mDragSource.startDrag(cellInfo, true);
}
public boolean onBackPressed() {
@@ -218,6 +232,15 @@
private void endAccessibleDrag() {
mDragInfo = null;
- mLauncher.getWorkspace().enableAccessibleDrag(false);
+ if (mDragSource != null) {
+ mDragSource.enableAccessibleDrag(false);
+ mDragSource = null;
+ }
+ }
+
+ public static interface AccessibilityDragSource {
+ void startDrag(CellLayout.CellInfo cellInfo, boolean accessible);
+
+ void enableAccessibleDrag(boolean enable);
}
}