am 0719c4ca: Merge "Ignore other finger while showing more keys keyboard"

* commit '0719c4ca7283946c99b9291a7ba31c41fd3ff391':
  Ignore other finger while showing more keys keyboard
main
Tadashi G. Takaoka 2013-12-11 01:44:05 -08:00 committed by Android Git Automerger
commit 176dd05934
2 changed files with 16 additions and 3 deletions

View File

@ -1008,6 +1008,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int index = me.getActionIndex();
final int id = me.getPointerId(index);
final PointerTracker tracker = PointerTracker.getPointerTracker(id);
// When a more keys panel is showing, we should ignore other fingers' single touch events
// other than the finger that is showing the more keys panel.
if (isShowingMoreKeysPanel() && !tracker.isShowingMoreKeysPanel()
&& PointerTracker.getActivePointerTrackerCount() == 1) {
return true;
}
tracker.processMotionEvent(me, mKeyDetector);
return true;
}

View File

@ -715,7 +715,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
return newKey;
}
private static int getActivePointerTrackerCount() {
/* package */ static int getActivePointerTrackerCount() {
return sPointerTrackerQueue.size();
}
@ -827,12 +827,19 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final int action = me.getActionMasked();
final long eventTime = me.getEventTime();
if (action == MotionEvent.ACTION_MOVE) {
// When this pointer is the only active pointer and is showing a more keys panel,
// we should ignore other pointers' motion event.
final boolean shouldIgnoreOtherPointers =
isShowingMoreKeysPanel() && getActivePointerTrackerCount() == 1;
final int pointerCount = me.getPointerCount();
for (int index = 0; index < pointerCount; index++) {
final int id = me.getPointerId(index);
final PointerTracker tracker = getPointerTracker(id);
if (shouldIgnoreOtherPointers && id != mPointerId) {
continue;
}
final int x = (int)me.getX(index);
final int y = (int)me.getY(index);
final PointerTracker tracker = getPointerTracker(id);
tracker.onMoveEvent(x, y, eventTime, me);
}
return;
@ -903,7 +910,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
}
private boolean isShowingMoreKeysPanel() {
/* package */ boolean isShowingMoreKeysPanel() {
return (mMoreKeysPanel != null);
}