@@ -6027,8 +6027,7 @@ public void addFocusables(ArrayList<View> views, int direction, int focusableMod
60276027 return;
60286028 }
60296029 if ((focusableMode & FOCUSABLES_ACCESSIBILITY) == FOCUSABLES_ACCESSIBILITY) {
6030- if (AccessibilityManager.getInstance(mContext).isEnabled()
6031- && includeForAccessibility()) {
6030+ if (canTakeAccessibilityFocusFromHover()) {
60326031 views.add(this);
60336032 return;
60346033 }
@@ -6181,57 +6180,28 @@ public void clearAccessibilityFocus() {
61816180 }
61826181 }
61836182
6184- /**
6185- * Find the best view to take accessibility focus from a hover.
6186- * This function finds the deepest actionable view and if that
6187- * fails ask the parent to take accessibility focus from hover.
6188- *
6189- * @param x The X hovered location in this view coorditantes.
6190- * @param y The Y hovered location in this view coorditantes.
6191- * @return Whether the request was handled.
6192- *
6193- * @hide
6194- */
6195- public boolean requestAccessibilityFocusFromHover(float x, float y) {
6196- if (onRequestAccessibilityFocusFromHover(x, y)) {
6197- return true;
6198- }
6199- ViewParent parent = mParent;
6200- if (parent instanceof View) {
6201- View parentView = (View) parent;
6202-
6203- float[] position = mAttachInfo.mTmpTransformLocation;
6204- position[0] = x;
6205- position[1] = y;
6206-
6207- // Compensate for the transformation of the current matrix.
6208- if (!hasIdentityMatrix()) {
6209- getMatrix().mapPoints(position);
6183+ private void requestAccessibilityFocusFromHover() {
6184+ if (includeForAccessibility() && isActionableForAccessibility()) {
6185+ requestAccessibilityFocus();
6186+ } else {
6187+ if (mParent != null) {
6188+ View nextFocus = mParent.findViewToTakeAccessibilityFocusFromHover(this, this);
6189+ if (nextFocus != null) {
6190+ nextFocus.requestAccessibilityFocus();
6191+ }
62106192 }
6211-
6212- // Compensate for the parent scroll and the offset
6213- // of this view stop from the parent top.
6214- position[0] += mLeft - parentView.mScrollX;
6215- position[1] += mTop - parentView.mScrollY;
6216-
6217- return parentView.requestAccessibilityFocusFromHover(position[0], position[1]);
62186193 }
6219- return false;
62206194 }
62216195
62226196 /**
6223- * Requests to give this View focus from hover.
6224- *
6225- * @param x The X hovered location in this view coorditantes.
6226- * @param y The Y hovered location in this view coorditantes.
6227- * @return Whether the request was handled.
6228- *
62296197 * @hide
62306198 */
6231- public boolean onRequestAccessibilityFocusFromHover(float x, float y) {
6232- if (includeForAccessibility()
6233- && (isActionableForAccessibility() || hasListenersForAccessibility())) {
6234- return requestAccessibilityFocus();
6199+ public boolean canTakeAccessibilityFocusFromHover() {
6200+ if (includeForAccessibility() && isActionableForAccessibility()) {
6201+ return true;
6202+ }
6203+ if (mParent != null) {
6204+ return (mParent.findViewToTakeAccessibilityFocusFromHover(this, this) == this);
62356205 }
62366206 return false;
62376207 }
@@ -6493,14 +6463,15 @@ public void addChildrenForAccessibility(ArrayList<View> children) {
64936463 * important for accessibility are regarded.
64946464 *
64956465 * @return Whether to regard the view for accessibility.
6466+ *
6467+ * @hide
64966468 */
6497- boolean includeForAccessibility() {
6469+ public boolean includeForAccessibility() {
64986470 if (mAttachInfo != null) {
64996471 if (!mAttachInfo.mIncludeNotImportantViews) {
65006472 return isImportantForAccessibility();
6501- } else {
6502- return true;
65036473 }
6474+ return true;
65046475 }
65056476 return false;
65066477 }
@@ -6511,8 +6482,10 @@ boolean includeForAccessibility() {
65116482 * accessiiblity.
65126483 *
65136484 * @return True if the view is actionable for accessibility.
6485+ *
6486+ * @hide
65146487 */
6515- private boolean isActionableForAccessibility() {
6488+ public boolean isActionableForAccessibility() {
65166489 return (isClickable() || isLongClickable() || isFocusable());
65176490 }
65186491
@@ -7688,7 +7661,7 @@ public boolean onHoverEvent(MotionEvent event) {
76887661 && pointInView(event.getX(), event.getY())) {
76897662 sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
76907663 mSendingHoverAccessibilityEvents = true;
7691- requestAccessibilityFocusFromHover((int) event.getX(), (int) event.getY() );
7664+ requestAccessibilityFocusFromHover();
76927665 }
76937666 } else {
76947667 if (action == MotionEvent.ACTION_HOVER_EXIT
0 commit comments