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

Commit 82daa6cf authored by ryanlwlin's avatar ryanlwlin Committed by Automerger Merge Worker
Browse files

[DO NOT MERGE] Fix incorrect order of Accessibility events am: 443b8fb8

Change-Id: If85944de2f7ac747b10e8867361d6eddff3d7856
parents 4245e14f 443b8fb8
Loading
Loading
Loading
Loading
+21 −6
Original line number Original line Diff line number Diff line
@@ -274,10 +274,27 @@ public class TouchExplorer extends BaseEventStreamTransformation
    public void onAccessibilityEvent(AccessibilityEvent event) {
    public void onAccessibilityEvent(AccessibilityEvent event) {
        final int eventType = event.getEventType();
        final int eventType = event.getEventType();


        if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
            sendsPendingA11yEventsIfNeed();
        }
        super.onAccessibilityEvent(event);
    }

    /*
     * Sends pending {@link AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END} or {@{@link
     * AccessibilityEvent#TYPE_TOUCH_EXPLORATION_GESTURE_END}} after receiving last hover exit
     * event.
     */
    private void sendsPendingA11yEventsIfNeed() {
        // The last hover exit A11y event should be sent by view after receiving hover exit motion
        // event. In some view hierarchy, the ViewGroup transforms hover move motion event to hover
        // exit motion event and than dispatch to itself. It causes unexpected A11y exit events.
        if (mSendHoverExitDelayed.isPending()) {
            return;
        }
        // The event for gesture end should be strictly after the
        // The event for gesture end should be strictly after the
        // last hover exit event.
        // last hover exit event.
        if (mSendTouchExplorationEndDelayed.isPending()
        if (mSendTouchExplorationEndDelayed.isPending()) {
                && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
            mSendTouchExplorationEndDelayed.cancel();
            mSendTouchExplorationEndDelayed.cancel();
            mDispatcher.sendAccessibilityEvent(
            mDispatcher.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END);
                    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END);
@@ -285,12 +302,10 @@ public class TouchExplorer extends BaseEventStreamTransformation


        // The event for touch interaction end should be strictly after the
        // The event for touch interaction end should be strictly after the
        // last hover exit and the touch exploration gesture end events.
        // last hover exit and the touch exploration gesture end events.
        if (mSendTouchInteractionEndDelayed.isPending()
        if (mSendTouchInteractionEndDelayed.isPending()) {
                && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
            mSendTouchInteractionEndDelayed.cancel();
            mSendTouchInteractionEndDelayed.cancel();
            mDispatcher.sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
            mDispatcher.sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
        }
        }
        super.onAccessibilityEvent(event);
    }
    }


    @Override
    @Override