Fix to clear on hover visual cue

Bug: 12491371
Change-Id: Ib7ca91ae73aa40e45ea5f6d4e53348a261a4b823
main
Tadashi G. Takaoka 2014-06-02 14:49:24 +09:00
parent fa9b9578d4
commit 82674ca81c
1 changed files with 17 additions and 13 deletions

View File

@ -39,7 +39,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
protected final KeyDetector mKeyDetector; protected final KeyDetector mKeyDetector;
private Keyboard mKeyboard; private Keyboard mKeyboard;
private KeyboardAccessibilityNodeProvider mAccessibilityNodeProvider; private KeyboardAccessibilityNodeProvider mAccessibilityNodeProvider;
private Key mCurrentHoverKey; private Key mLastHoverKey;
public KeyboardAccessibilityDelegate(final KV keyboardView, final KeyDetector keyDetector) { public KeyboardAccessibilityDelegate(final KV keyboardView, final KeyDetector keyDetector) {
super(); super();
@ -71,12 +71,12 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
return mKeyboard; return mKeyboard;
} }
protected final void setCurrentHoverKey(final Key key) { protected final void setLastHoverKey(final Key key) {
mCurrentHoverKey = key; mLastHoverKey = key;
} }
protected final Key getCurrentHoverKey() { protected final Key getLastHoverKey() {
return mCurrentHoverKey; return mLastHoverKey;
} }
/** /**
@ -142,7 +142,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* @param event The hover event. * @param event The hover event.
* @return key The key that the <code>event</code> is on. * @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 actionIndex = event.getActionIndex();
final int x = (int)event.getX(actionIndex); final int x = (int)event.getX(actionIndex);
final int y = (int)event.getY(actionIndex); final int y = (int)event.getY(actionIndex);
@ -179,11 +179,11 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* @param event A hover enter event. * @param event A hover enter event.
*/ */
protected void onHoverEnter(final MotionEvent event) { protected void onHoverEnter(final MotionEvent event) {
final Key key = getHoverKey(event); final Key key = getHoverKeyOf(event);
if (key != null) { if (key != null) {
onHoverEnterKey(key); onHoverEnterKey(key);
} }
setCurrentHoverKey(key); setLastHoverKey(key);
} }
/** /**
@ -192,8 +192,8 @@ 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 = getCurrentHoverKey(); final Key previousKey = getLastHoverKey();
final Key key = getHoverKey(event); final Key key = getHoverKeyOf(event);
if (key != previousKey) { if (key != previousKey) {
if (previousKey != null) { if (previousKey != null) {
onHoverExitKey(previousKey); onHoverExitKey(previousKey);
@ -205,7 +205,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
if (key != null) { if (key != null) {
onHoverMoveKey(key); onHoverMoveKey(key);
} }
setCurrentHoverKey(key); setLastHoverKey(key);
} }
/** /**
@ -214,7 +214,11 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* @param event A hover exit event. * @param event A hover exit event.
*/ */
protected void onHoverExit(final MotionEvent event) { protected void onHoverExit(final MotionEvent event) {
final Key key = getHoverKey(event); final Key lastKey = getLastHoverKey();
if (lastKey != null) {
onHoverExitKey(lastKey);
}
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
// off the keyboard area, then force a key press. // off the keyboard area, then force a key press.
if (key != null) { if (key != null) {
@ -222,7 +226,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
simulateTouchEvent(MotionEvent.ACTION_UP, event); simulateTouchEvent(MotionEvent.ACTION_UP, event);
onHoverExitKey(key); onHoverExitKey(key);
} }
setCurrentHoverKey(null); setLastHoverKey(null);
} }
/** /**