When dragging make the content of the drag layer not accessible but keep the drag View accessible

Continuation of change I842415f689c992f64d863743f019455701da22e9

Fix: 392872410
Bug: 374642145
Bug: 374656225
Bug: 374658319
Test: manual
Flag: EXEMPT bugfix
Change-Id: I282f1f6ca30e10c5aef6947feee9b10514e286a6
This commit is contained in:
Sebastian Franco
2025-04-10 17:15:40 -07:00
parent af3be84616
commit 2ff9ebce8e
@@ -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