Pass hover event to accessibility key handling methods

Bug: 12491371
Change-Id: I1f7feef707b95e8862db71cbc4f6f5585a2441dd
main
Tadashi G. Takaoka 2014-06-02 17:05:04 +09:00
parent d0b79cc12a
commit a021395e84
1 changed files with 15 additions and 12 deletions

View File

@ -181,7 +181,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
protected void onHoverEnter(final MotionEvent event) { protected void onHoverEnter(final MotionEvent event) {
final Key key = getHoverKeyOf(event); final Key key = getHoverKeyOf(event);
if (key != null) { if (key != null) {
onHoverEnterKey(key); onHoverEnterKey(key, event);
} }
setLastHoverKey(key); setLastHoverKey(key);
} }
@ -192,18 +192,18 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* @param event A hover move event. * @param event A hover move event.
*/ */
protected void onHoverMove(final MotionEvent event) { protected void onHoverMove(final MotionEvent event) {
final Key previousKey = getLastHoverKey(); final Key lastKey = getLastHoverKey();
final Key key = getHoverKeyOf(event); final Key key = getHoverKeyOf(event);
if (key != previousKey) { if (key != lastKey) {
if (previousKey != null) { if (lastKey != null) {
onHoverExitKey(previousKey); onHoverExitKey(lastKey, event);
} }
if (key != null) { if (key != null) {
onHoverEnterKey(key); onHoverEnterKey(key, event);
} }
} }
if (key != null) { if (key != null) {
onHoverMoveKey(key); onHoverMoveKey(key, event);
} }
setLastHoverKey(key); setLastHoverKey(key);
} }
@ -216,7 +216,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
protected void onHoverExit(final MotionEvent event) { protected void onHoverExit(final MotionEvent event) {
final Key lastKey = getLastHoverKey(); final Key lastKey = getLastHoverKey();
if (lastKey != null) { if (lastKey != null) {
onHoverExitKey(lastKey); onHoverExitKey(lastKey, event);
} }
final Key key = getHoverKeyOf(event); final Key key = getHoverKeyOf(event);
// Make sure we're not getting an EXIT event because the user slid // Make sure we're not getting an EXIT event because the user slid
@ -224,7 +224,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
if (key != null) { if (key != null) {
simulateTouchEvent(MotionEvent.ACTION_DOWN, event); simulateTouchEvent(MotionEvent.ACTION_DOWN, event);
simulateTouchEvent(MotionEvent.ACTION_UP, event); simulateTouchEvent(MotionEvent.ACTION_UP, event);
onHoverExitKey(key); onHoverExitKey(key, event);
} }
setLastHoverKey(null); setLastHoverKey(null);
} }
@ -267,8 +267,9 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* Handles a hover enter event on a key. * Handles a hover enter event on a key.
* *
* @param key The currently hovered 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(); key.onPressed();
mKeyboardView.invalidateKey(key); mKeyboardView.invalidateKey(key);
final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider(); final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider();
@ -280,15 +281,17 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* Handles a hover move event on a key. * Handles a hover move event on a key.
* *
* @param key The currently hovered 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. * Handles a hover exit event on a key.
* *
* @param key The currently hovered 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(); key.onReleased();
mKeyboardView.invalidateKey(key); mKeyboardView.invalidateKey(key);
final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider(); final KeyboardAccessibilityNodeProvider provider = getAccessibilityNodeProvider();