From 3d8848e5cb709fb47b450e7ede5a2926d99c957d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 24 Jun 2014 15:35:10 -0700 Subject: [PATCH] Refactor keyboard accessibility delegate classes Bug: 15727335 Change-Id: I1aa79a6f7f8cf14bacec391c016a5d1c553eea24 --- .../KeyboardAccessibilityDelegate.java | 25 +++---------------- .../KeyboardAccessibilityNodeProvider.java | 2 +- .../MoreSuggestionsAccessibilityDelegate.java | 4 ++- .../keyboard/emoji/EmojiPageKeyboardView.java | 4 ++- .../suggestions/MoreSuggestionsView.java | 1 + 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java index 3925fc652..7a945e369 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java @@ -19,7 +19,6 @@ package com.android.inputmethod.accessibility; import android.content.Context; import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.ViewCompat; -import android.support.v4.view.accessibility.AccessibilityEventCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.util.Log; import android.view.MotionEvent; @@ -31,7 +30,6 @@ import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardView; -import com.android.inputmethod.keyboard.PointerTracker; /** * This class represents a delegate that can be registered in a class that extends @@ -264,33 +262,16 @@ public class KeyboardAccessibilityDelegate } /** - * Simulating a touch event by injecting a synthesized touch event into {@link PointerTracker}. + * Simulating a touch event by injecting a synthesized touch event into {@link KeyboardView}. * * @param touchAction The action of the synthesizing touch event. * @param hoverEvent The base hover event from that the touch event is synthesized. */ protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { - final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent); - final int actionIndex = touchEvent.getActionIndex(); - final int pointerId = touchEvent.getPointerId(actionIndex); - final PointerTracker tracker = PointerTracker.getPointerTracker(pointerId); - tracker.processMotionEvent(touchEvent, mKeyDetector); - touchEvent.recycle(); - } - - /** - * Synthesize a touch event from a hover event. - * - * @param touchAction The action of the synthesizing touch event. - * @param hoverEvent The base hover event from that the touch event is synthesized. - * @return The synthesized touch event of touchAction that has pointer information - * of event. - */ - protected static MotionEvent synthesizeTouchEvent(final int touchAction, - final MotionEvent hoverEvent) { final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); touchEvent.setAction(touchAction); - return touchEvent; + mKeyboardView.onTouchEvent(touchEvent); + touchEvent.recycle(); } /** diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java index 61d066af5..328d9ec0d 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java +++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java @@ -68,7 +68,7 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC /** The virtual view identifier for the hovering node. */ private int mHoveringNodeId = UNDEFINED; - /** The current keyboard view. */ + /** The keyboard view to provide an accessibility node info. */ private final KeyboardView mKeyboardView; /** The current keyboard. */ diff --git a/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java index dfc866113..941bac14c 100644 --- a/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java @@ -28,9 +28,11 @@ public final class MoreSuggestionsAccessibilityDelegate super(moreKeysKeyboardView, keyDetector); } + // TODO: Remove redundant override method. @Override protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { - final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent); + final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); + touchEvent.setAction(touchAction); mKeyboardView.onTouchEvent(touchEvent); touchEvent.recycle(); } diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java index 8010a3e7e..063404028 100644 --- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java @@ -65,9 +65,11 @@ final class EmojiPageKeyboardView extends KeyboardView implements super(keyboardView, keyDetector); } + // TODO: Remove redundant override method. @Override protected void simulateTouchEvent(int touchAction, MotionEvent hoverEvent) { - final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent); + final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); + touchEvent.setAction(touchAction); mKeyboardView.onTouchEvent(touchEvent); touchEvent.recycle(); } diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 528d500d2..9f9bff5bd 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -51,6 +51,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { super(context, attrs, defStyle); } + // TODO: Remove redundant override method. @Override public void setKeyboard(final Keyboard keyboard) { super.setKeyboard(keyboard);