Skip to content

Commit ed82973

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Interaction model of KeyboarView should be same as latimIME" into jb-dev
2 parents 321a56c + b6a0b09 commit ed82973

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

core/java/android/inputmethodservice/KeyboardView.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,23 @@ private void showPreview(int keyIndex) {
855855
Key oldKey = keys[oldKeyIndex];
856856
oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY);
857857
invalidateKey(oldKeyIndex);
858+
final int keyCode = oldKey.codes[0];
858859
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
859-
oldKey.codes[0]);
860+
keyCode);
861+
// TODO: We need to implement AccessibilityNodeProvider for this view.
862+
sendAccessibilityEventForUnicodeCharacter(
863+
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode);
860864
}
861865
if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
862866
Key newKey = keys[mCurrentKeyIndex];
863867
newKey.onPressed();
864868
invalidateKey(mCurrentKeyIndex);
869+
final int keyCode = newKey.codes[0];
865870
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
866-
newKey.codes[0]);
871+
keyCode);
872+
// TODO: We need to implement AccessibilityNodeProvider for this view.
873+
sendAccessibilityEventForUnicodeCharacter(
874+
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, keyCode);
867875
}
868876
}
869877
// If key changed and preview is on ...
@@ -1154,20 +1162,17 @@ public boolean onHoverEvent(MotionEvent event) {
11541162
if (mAccessibilityManager.isTouchExplorationEnabled() && event.getPointerCount() == 1) {
11551163
final int action = event.getAction();
11561164
switch (action) {
1157-
case MotionEvent.ACTION_HOVER_ENTER:
1158-
case MotionEvent.ACTION_HOVER_MOVE:
1159-
final int touchX = (int) event.getX() - mPaddingLeft;
1160-
int touchY = (int) event.getY() - mPaddingTop;
1161-
if (touchY >= -mVerticalCorrection) {
1162-
touchY += mVerticalCorrection;
1163-
}
1164-
final int keyIndex = getKeyIndices(touchX, touchY, null);
1165-
showPreview(keyIndex);
1166-
break;
1167-
case MotionEvent.ACTION_HOVER_EXIT:
1168-
showPreview(NOT_A_KEY);
1169-
break;
1165+
case MotionEvent.ACTION_HOVER_ENTER: {
1166+
event.setAction(MotionEvent.ACTION_DOWN);
1167+
} break;
1168+
case MotionEvent.ACTION_HOVER_MOVE: {
1169+
event.setAction(MotionEvent.ACTION_MOVE);
1170+
} break;
1171+
case MotionEvent.ACTION_HOVER_EXIT: {
1172+
event.setAction(MotionEvent.ACTION_UP);
1173+
} break;
11701174
}
1175+
return onTouchEvent(event);
11711176
}
11721177
return true;
11731178
}

0 commit comments

Comments
 (0)