Merge "When dragging make the content of the drag layer not accessible but keep the drag View accessible" into main

This commit is contained in:
Sebastián Franco
2025-04-11 14:55:08 -07:00
committed by Android (Google) Code Review
@@ -151,9 +151,7 @@ public class LauncherDragController extends DragController<Launcher> {
initialDragViewScale,
dragViewScaleOnDrop,
scalePx);
// During a drag, we don't want to expose the descendendants of drag view to a11y users,
// since those decendents are not a valid position in the workspace.
dragView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
dragView.setItemInfo(dragInfo);
mDragObject.dragComplete = false;
@@ -161,6 +159,7 @@ public class LauncherDragController extends DragController<Launcher> {
mDragObject.yOffset = mMotionDown.y - (dragLayerY + dragRegionTop);
mDragDriver = DragDriver.create(this, mOptions, mFlingToDeleteHelper::recordMotionEvent);
prepareViewForAccessibility(dragView);
if (!mOptions.isAccessibleDrag) {
mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
}
@@ -198,6 +197,21 @@ public class LauncherDragController extends DragController<Launcher> {
return dragView;
}
/**
* During a drag, we don't want to expose the descendants of drag view to a11y users,
* since those descendants are not a valid position in the workspace.
* We need to go through the children because the view itself is important for
* accessibility, basically we are implementing:
* IMPORTANT_FOR_ACCESSIBILITY_YES_HIDE_DESCENDANTS
*/
void prepareViewForAccessibility(DragView dragView) {
for (int i = 0; i < dragView.getChildCount(); i++) {
dragView.getChildAt(i).setImportantForAccessibility(
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
);
}
}
/**
* Returns the scale in terms of pixels (to be applied on width) to scale the preview