From 26b424b6448fbaddc86d11377ca44ff3169a5d7e Mon Sep 17 00:00:00 2001 From: alanv Date: Wed, 29 Aug 2012 13:07:37 -0700 Subject: Fix key info reported by keyboard accessibility node provider. Bug: 6704529 Change-Id: I519881a96767a8858c11da7c0abac3e276a45cf5 --- .../accessibility/AccessibleKeyboardViewProxy.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java') diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 2fff73154..ed3468afb 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -105,8 +105,21 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat { } /** - * Receives hover events when accessibility is turned on in SDK versions ICS - * and higher. + * Receives motion events when touch exploration is turned on in SDK + * versions ICS and higher. + * + * @param event The motion event. + * @return {@code true} if the event is handled + */ + public boolean onTouchEvent(MotionEvent event) { + // To avoid accidental key presses during touch exploration, always drop + // non-hover touch events. + return false; + } + + /** + * Receives hover events when touch exploration is turned on in SDK versions + * ICS and higher. * * @param event The hover event. * @return {@code true} if the event is handled -- cgit v1.2.3-83-g751a From dc2ee7772402633817702e95c2a5b17f6dec03eb Mon Sep 17 00:00:00 2001 From: alanv Date: Mon, 10 Sep 2012 15:47:24 -0700 Subject: When Accessibility is on, intercept touch events during dispatch. This allows Accessibility code to safely inject events into onTouchEvent() without accidentally intercepting them. Bug: 7137557 Change-Id: Ie4fa8e3be5b1bb84f57c6254feab1129cb89998f --- .../accessibility/AccessibleKeyboardViewProxy.java | 10 +++++----- .../com/android/inputmethod/keyboard/MainKeyboardView.java | 11 ++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java') diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 77940c086..01220a58a 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -105,15 +105,15 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat { } /** - * Receives motion events when touch exploration is turned on in SDK - * versions ICS and higher. + * Intercepts touch events before dispatch when touch exploration is turned + * on in ICS and higher. * - * @param event The motion event. + * @param event The motion event being dispatched. * @return {@code true} if the event is handled */ - public boolean onTouchEvent(MotionEvent event) { + public boolean dispatchTouchEvent(MotionEvent event) { // To avoid accidental key presses during touch exploration, always drop - // non-hover touch events. + // touch events generated by the user. return false; } diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index f6b66a79e..4ed0f58e1 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -660,14 +660,19 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key return mOldPointerCount; } + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { + return AccessibleKeyboardViewProxy.getInstance().dispatchTouchEvent(event); + } + return super.dispatchTouchEvent(event); + } + @Override public boolean onTouchEvent(final MotionEvent me) { if (getKeyboard() == null) { return false; } - if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { - return AccessibleKeyboardViewProxy.getInstance().onTouchEvent(me); - } return mTouchScreenRegulator.onTouchEvent(me); } -- cgit v1.2.3-83-g751a