diff options
author | Svet Ganov <svetoslavganov@google.com> | 2015-02-06 19:23:31 -0800 |
---|---|---|
committer | Svet Ganov <svetoslavganov@google.com> | 2015-02-07 10:36:59 -0800 |
commit | f33fe1f4860d4cbc49633162cf6441d315550cc9 (patch) | |
tree | 4e8d035f572f9df4153f7f069e883a1374d30f01 | |
parent | 5ac30e10ab484fdb7ba3c56b8c162a9061601f8e (diff) | |
download | frameworks_base-f33fe1f4860d4cbc49633162cf6441d315550cc9.zip frameworks_base-f33fe1f4860d4cbc49633162cf6441d315550cc9.tar.gz frameworks_base-f33fe1f4860d4cbc49633162cf6441d315550cc9.tar.bz2 |
Accessibility: Handle a missed case when clicking focused views.
The special logic for clicking on views in accessibility mode should not
prevent event interception and if a view interceptes the gesture we must
clear the special flag and do normal event dispatch. Also once we have a
view handling the touch gesture we do not need the special flag as we
know what will handle the event. This tightly follows standard event
dispatching.
bug:19252492
Change-Id: I0c9764c5050ec73f5f7980f3f0340dd9509a725a
-rw-r--r-- | core/java/android/view/ViewGroup.java | 39 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 7 |
2 files changed, 25 insertions, 21 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 7a36eb6..2182127 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -1931,12 +1931,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager mInputEventConsistencyVerifier.onTouchEvent(ev, 1); } - // Whether this event should be handled by the accessibility focus first. - final boolean targetAccessibilityFocus = ev.isTargetAccessibilityFocus(); - // If the event targets the accessibility focused view and this is it, start // normal event dispatch. Maybe a descendant is what will handle the click. - if (targetAccessibilityFocus && isAccessibilityFocusedViewOrHost()) { + if (ev.isTargetAccessibilityFocus() && isAccessibilityFocusedViewOrHost()) { ev.setTargetAccessibilityFocus(false); } @@ -1956,24 +1953,25 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Check for interception. final boolean intercepted; - if (!targetAccessibilityFocus) { - if (actionMasked == MotionEvent.ACTION_DOWN - || mFirstTouchTarget != null) { - final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0; - if (!disallowIntercept) { - intercepted = onInterceptTouchEvent(ev); - ev.setAction(action); // restore action in case it was changed - } else { - intercepted = false; - } + if (actionMasked == MotionEvent.ACTION_DOWN + || mFirstTouchTarget != null) { + final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0; + if (!disallowIntercept) { + intercepted = onInterceptTouchEvent(ev); + ev.setAction(action); // restore action in case it was changed } else { - // There are no touch targets and this action is not an initial down - // so this view group continues to intercept touches. - intercepted = true; + intercepted = false; } } else { - // If event should reach the accessibility focus first, do not intercept it. - intercepted = false; + // There are no touch targets and this action is not an initial down + // so this view group continues to intercept touches. + intercepted = true; + } + + // If intercepted, start normal event dispatch. Also if there is already + // a view that is handling the gesture, do normal event dispatch. + if (intercepted || mFirstTouchTarget != null) { + ev.setTargetAccessibilityFocus(false); } // Check for cancelation. @@ -1987,8 +1985,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (!canceled && !intercepted) { if (actionMasked == MotionEvent.ACTION_DOWN || (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN) - || actionMasked == MotionEvent.ACTION_HOVER_MOVE - || targetAccessibilityFocus) { + || actionMasked == MotionEvent.ACTION_HOVER_MOVE) { final int actionIndex = ev.getActionIndex(); // always 0 for down final int idBitsToAssign = split ? 1 << ev.getPointerId(actionIndex) : TouchTarget.ALL_POINTER_IDS; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index e4d82b1..15d47ba 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -4121,6 +4121,13 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mUnbufferedDispatchRequested = false; 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) { mUnbufferedInputDispatch = true; if (mConsumeBatchedInputScheduled) { |