From 2ff9ebce8eccfe98712c2167c3cb53167ddded14 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Thu, 10 Apr 2025 17:15:40 -0700 Subject: [PATCH] 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 --- .../dragndrop/LauncherDragController.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/dragndrop/LauncherDragController.java b/src/com/android/launcher3/dragndrop/LauncherDragController.java index dd433c02d3..ed07542f31 100644 --- a/src/com/android/launcher3/dragndrop/LauncherDragController.java +++ b/src/com/android/launcher3/dragndrop/LauncherDragController.java @@ -151,9 +151,7 @@ public class LauncherDragController extends DragController { 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 { 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 { 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