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

Commit 3039c1c5 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: I01ab8f00f3b91d98d11af09ac3340999a78e3097
parents cecebfae 443b8fb8
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -274,10 +274,27 @@ public class TouchExplorer extends BaseEventStreamTransformation
    public void onAccessibilityEvent(AccessibilityEvent event) {
        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
        // last hover exit event.
        if (mSendTouchExplorationEndDelayed.isPending()
                && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
        if (mSendTouchExplorationEndDelayed.isPending()) {
            mSendTouchExplorationEndDelayed.cancel();
            mDispatcher.sendAccessibilityEvent(
                    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
        // last hover exit and the touch exploration gesture end events.
        if (mSendTouchInteractionEndDelayed.isPending()
                && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
        if (mSendTouchInteractionEndDelayed.isPending()) {
            mSendTouchInteractionEndDelayed.cancel();
            mDispatcher.sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
        }
        super.onAccessibilityEvent(event);
    }

    @Override