diff options
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java')
-rw-r--r-- | java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java index 7cae9861c..398a933df 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java @@ -39,7 +39,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> protected final KeyDetector mKeyDetector; private Keyboard mKeyboard; private KeyboardAccessibilityNodeProvider mAccessibilityNodeProvider; - private Key mCurrentHoverKey; + private Key mLastHoverKey; public KeyboardAccessibilityDelegate(final KV keyboardView, final KeyDetector keyDetector) { super(); @@ -71,12 +71,12 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> return mKeyboard; } - protected final void setCurrentHoverKey(final Key key) { - mCurrentHoverKey = key; + protected final void setLastHoverKey(final Key key) { + mLastHoverKey = key; } - protected final Key getCurrentHoverKey() { - return mCurrentHoverKey; + protected final Key getLastHoverKey() { + return mLastHoverKey; } /** @@ -142,7 +142,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * @param event The hover event. * @return key The key that the <code>event</code> is on. */ - protected final Key getHoverKey(final MotionEvent event) { + protected final Key getHoverKeyOf(final MotionEvent event) { final int actionIndex = event.getActionIndex(); final int x = (int)event.getX(actionIndex); final int y = (int)event.getY(actionIndex); @@ -179,11 +179,11 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * @param event A hover enter event. */ protected void onHoverEnter(final MotionEvent event) { - final Key key = getHoverKey(event); + final Key key = getHoverKeyOf(event); if (key != null) { - onHoverEnterKey(key); + onHoverEnterKey(key, event); } - setCurrentHoverKey(key); + setLastHoverKey(key); } /** @@ -192,20 +192,20 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * @param event A hover move event. */ protected void onHoverMove(final MotionEvent event) { - final Key previousKey = getCurrentHoverKey(); - final Key key = getHoverKey(event); - if (key != previousKey) { - if (previousKey != null) { - onHoverExitKey(previousKey); + final Key lastKey = getLastHoverKey(); + final Key key = getHoverKeyOf(event); + if (key != lastKey) { + if (lastKey != null) { + onHoverExitKey(lastKey, event); } if (key != null) { - onHoverEnterKey(key); + onHoverEnterKey(key, event); } } if (key != null) { - onHoverMoveKey(key); + onHoverMoveKey(key, event); } - setCurrentHoverKey(key); + setLastHoverKey(key); } /** @@ -214,15 +214,19 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * @param event A hover exit event. */ protected void onHoverExit(final MotionEvent event) { - final Key key = getHoverKey(event); + final Key lastKey = getLastHoverKey(); + if (lastKey != null) { + onHoverExitKey(lastKey, event); + } + final Key key = getHoverKeyOf(event); // Make sure we're not getting an EXIT event because the user slid // off the keyboard area, then force a key press. if (key != null) { simulateTouchEvent(MotionEvent.ACTION_DOWN, event); simulateTouchEvent(MotionEvent.ACTION_UP, event); - onHoverExitKey(key); + onHoverExitKey(key, event); } - setCurrentHoverKey(null); + setLastHoverKey(null); } /** @@ -263,8 +267,9 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * Handles a hover enter event on a key. * * @param key The currently hovered key. + * @param event The hover event that triggers a call to this method. */ - protected void onHoverEnterKey(final Key key) { + protected void onHoverEnterKey(final Key key, final MotionEvent event) { key.onPressed(); mKeyboardView.invalidateKey(key); final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider(); @@ -276,15 +281,17 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView> * Handles a hover move event on a key. * * @param key The currently hovered key. + * @param event The hover event that triggers a call to this method. */ - protected void onHoverMoveKey(final Key key) { } + protected void onHoverMoveKey(final Key key, final MotionEvent event) { } /** * Handles a hover exit event on a key. * * @param key The currently hovered key. + * @param event The hover event that triggers a call to this method. */ - protected void onHoverExitKey(final Key key) { + protected void onHoverExitKey(final Key key, final MotionEvent event) { key.onReleased(); mKeyboardView.invalidateKey(key); final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider(); |