Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c052b0ef authored by Svetoslav's avatar Svetoslav Committed by Android Git Automerger
Browse files

am cf2c8545: am 5521f39f: am c73cfa0f: Accessibiltiy: missed update to the previous patch.

* commit 'cf2c8545':
  Accessibiltiy: missed update to the previous patch.
parents ec10f833 cf2c8545
Loading
Loading
Loading
Loading
+55 −0
Original line number Original line Diff line number Diff line
@@ -1983,6 +1983,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            TouchTarget newTouchTarget = null;
            TouchTarget newTouchTarget = null;
            boolean alreadyDispatchedToNewTouchTarget = false;
            boolean alreadyDispatchedToNewTouchTarget = false;
            if (!canceled && !intercepted) {
            if (!canceled && !intercepted) {

                // If the event is targeting accessiiblity focus we give it to the
                // view that has accessibility focus and if it does not handle it
                // we clear the flag and dispatch the event to all children as usual.
                // We are looking up the accessibility focused host to avoid keeping
                // state since these events are very rare.
                View childWithAccessibilityFocus = ev.isTargetAccessibilityFocus()
                        ? findChildWithAccessibilityFocus() : null;

                if (actionMasked == MotionEvent.ACTION_DOWN
                if (actionMasked == MotionEvent.ACTION_DOWN
                        || (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN)
                        || (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN)
                        || actionMasked == MotionEvent.ACTION_HOVER_MOVE) {
                        || actionMasked == MotionEvent.ACTION_HOVER_MOVE) {
@@ -2009,8 +2018,22 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                                    ? getChildDrawingOrder(childrenCount, i) : i;
                                    ? getChildDrawingOrder(childrenCount, i) : i;
                            final View child = (preorderedList == null)
                            final View child = (preorderedList == null)
                                    ? children[childIndex] : preorderedList.get(childIndex);
                                    ? children[childIndex] : preorderedList.get(childIndex);

                            // If there is a view that has accessibility focus we want it
                            // to get the event first and if not handled we will perform a
                            // normal dispatch. We may do a double iteration but this is
                            // safer given the timeframe.
                            if (childWithAccessibilityFocus != null) {
                                if (childWithAccessibilityFocus != child) {
                                    continue;
                                }
                                childWithAccessibilityFocus = null;
                                i = childrenCount - 1;
                            }

                            if (!canViewReceivePointerEvents(child)
                            if (!canViewReceivePointerEvents(child)
                                    || !isTransformedTouchPointInView(x, y, child, null)) {
                                    || !isTransformedTouchPointInView(x, y, child, null)) {
                                ev.setTargetAccessibilityFocus(false);
                                continue;
                                continue;
                            }
                            }


@@ -2043,6 +2066,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                                alreadyDispatchedToNewTouchTarget = true;
                                alreadyDispatchedToNewTouchTarget = true;
                                break;
                                break;
                            }
                            }

                            // The accessibility focus didn't handle the event, so clear
                            // the flag and do a normal dispatch to all children.
                            ev.setTargetAccessibilityFocus(false);
                        }
                        }
                        if (preorderedList != null) preorderedList.clear();
                        if (preorderedList != null) preorderedList.clear();
                    }
                    }
@@ -2114,6 +2141,34 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return handled;
        return handled;
    }
    }


    /**
     * Finds the child which has accessibility focus.
     *
     * @return The child that has focus.
     */
    private View findChildWithAccessibilityFocus() {
        ViewRootImpl viewRoot = getViewRootImpl();
        if (viewRoot == null) {
            return null;
        }

        View current = viewRoot.getAccessibilityFocusedHost();
        if (current == null) {
            return null;
        }

        ViewParent parent = current.getParent();
        while (parent instanceof View) {
            if (parent == this) {
                return current;
            }
            current = (View) parent;
            parent = current.getParent();
        }

        return null;
    }

    /**
    /**
     * Resets all touch state in preparation for a new cycle.
     * Resets all touch state in preparation for a new cycle.
     */
     */
+0 −7
Original line number Original line Diff line number Diff line
@@ -4121,13 +4121,6 @@ public final class ViewRootImpl implements ViewParent,


            mAttachInfo.mUnbufferedDispatchRequested = false;
            mAttachInfo.mUnbufferedDispatchRequested = false;
            boolean handled = mView.dispatchPointerEvent(event);
            boolean handled = mView.dispatchPointerEvent(event);
            if (!handled && event.isTargetAccessibilityFocus()) {
                // The event was targeting accessibility focused view and is not handled,
                // it is very rare but possible that a predecessor of the focused view handles
                // the event but didn't due to special dispatch, perform normal event dispatch.
                event.setTargetAccessibilityFocus(false);
                handled = mView.dispatchPointerEvent(event);
            }
            if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
            if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
                mUnbufferedInputDispatch = true;
                mUnbufferedInputDispatch = true;
                if (mConsumeBatchedInputScheduled) {
                if (mConsumeBatchedInputScheduled) {