Adding support for keyboard based drag and drop

For keyboard DnD, we use Accessible DnD implementation.
A placeholder FloatingView draws the focus indicator
for the virtual views

Test: Visible
Bug: 178781566
Change-Id: I632fc7377dffa1e05e3f0a9c3ad18641deb5a1a4
This commit is contained in:
Sunny Goyal
2021-02-02 13:45:34 -08:00
parent d462965698
commit a4647b681f
18 changed files with 723 additions and 288 deletions
@@ -17,17 +17,12 @@
package com.android.launcher3.accessibility;
import android.content.Context;
import android.graphics.Rect;
import android.text.TextUtils;
import android.view.View;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.android.launcher3.CellLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DragType;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -38,9 +33,6 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
*/
public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelegate {
private final Rect mTempRect = new Rect();
private final int[] mTempCords = new int[2];
public WorkspaceAccessibilityHelper(CellLayout layout) {
super(layout);
}
@@ -134,26 +126,6 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega
}
return "";
}
@Override
protected void onPopulateNodeForVirtualView(int id, AccessibilityNodeInfoCompat node) {
super.onPopulateNodeForVirtualView(id, node);
// ExploreByTouchHelper does not currently handle view scale.
// Update BoundsInScreen to appropriate value.
DragLayer dragLayer = Launcher.getLauncher(mView.getContext()).getDragLayer();
mTempCords[0] = mTempCords[1] = 0;
float scale = dragLayer.getDescendantCoordRelativeToSelf(mView, mTempCords);
node.getBoundsInParent(mTempRect);
mTempRect.left = mTempCords[0] + (int) (mTempRect.left * scale);
mTempRect.right = mTempCords[0] + (int) (mTempRect.right * scale);
mTempRect.top = mTempCords[1] + (int) (mTempRect.top * scale);
mTempRect.bottom = mTempCords[1] + (int) (mTempRect.bottom * scale);
node.setBoundsInScreen(mTempRect);
}
@Override
protected String getLocationDescriptionForIconDrop(int id) {
int x = id % mView.getCountX();