Fixed extra periods when chording with shift and space

Actually it was caused by canceling repeat key (space and delete) when
multiple pointer are touching.

Bug: 2975041
Change-Id: If82183b9225efdace7b5418860b9664f1705b7ec
main
Tadashi G. Takaoka 2010-09-07 12:20:03 +09:00
parent 8d7ffcb2ac
commit 6252f468bc
2 changed files with 25 additions and 25 deletions

View File

@ -1120,7 +1120,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
public boolean onTouchEvent(MotionEvent me) { public boolean onTouchEvent(MotionEvent me) {
final int pointerCount = me.getPointerCount(); final int pointerCount = me.getPointerCount();
final int action = me.getActionMasked(); final int action = me.getActionMasked();
final long eventTime = me.getEventTime();
// TODO: cleanup this code into a multi-touch to single-touch event converter class? // TODO: cleanup this code into a multi-touch to single-touch event converter class?
// If the device does not have distinct multi-touch support panel, ignore all multi-touch // If the device does not have distinct multi-touch support panel, ignore all multi-touch
@ -1139,24 +1138,32 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
return true; return true;
} }
final long eventTime = me.getEventTime();
final int index = me.getActionIndex();
final int id = me.getPointerId(index);
final int x = (int)me.getX(index);
final int y = (int)me.getY(index);
// Needs to be called after the gesture detector gets a turn, as it may have // Needs to be called after the gesture detector gets a turn, as it may have
// displayed the mini keyboard // displayed the mini keyboard
if (mMiniKeyboard != null) { if (mMiniKeyboard != null) {
MotionEvent translated = generateMiniKeyboardMotionEvent(action, (int)me.getX(), MotionEvent translated = generateMiniKeyboardMotionEvent(action, x, y, eventTime);
(int)me.getY(), eventTime);
mMiniKeyboard.onTouchEvent(translated); mMiniKeyboard.onTouchEvent(translated);
translated.recycle(); translated.recycle();
return true; return true;
} }
if (mHandler.isInKeyRepeat()) { if (mHandler.isInKeyRepeat()) {
// It'll be canceled if 2 or more keys are in action. Otherwise it will keep being in // It will keep being in the key repeating mode while the key is being pressed.
// the key repeating mode while the key is being pressed. if (action == MotionEvent.ACTION_MOVE) {
if (pointerCount > 1) {
mHandler.cancelKeyRepeatTimer();
} else if (action == MotionEvent.ACTION_MOVE) {
return true; return true;
} }
final PointerTracker tracker = getPointerTracker(id);
// Key repeating timer will be canceled if 2 or more keys are in action, and current
// event (UP or DOWN) is non-modifier key.
if (pointerCount > 1 && !tracker.isModifier()) {
mHandler.cancelKeyRepeatTimer();
}
// Up event will pass through. // Up event will pass through.
} }
@ -1166,9 +1173,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
if (!mHasDistinctMultitouch) { if (!mHasDistinctMultitouch) {
// Use only main (id=0) pointer tracker. // Use only main (id=0) pointer tracker.
PointerTracker tracker = getPointerTracker(0); PointerTracker tracker = getPointerTracker(0);
int index = me.getActionIndex();
int x = (int)me.getX(index);
int y = (int)me.getY(index);
int oldPointerCount = mOldPointerCount; int oldPointerCount = mOldPointerCount;
if (pointerCount == 1 && oldPointerCount == 2) { if (pointerCount == 1 && oldPointerCount == 2) {
// Multi-touch to single touch transition. // Multi-touch to single touch transition.
@ -1189,18 +1193,11 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
} }
if (action == MotionEvent.ACTION_MOVE) { if (action == MotionEvent.ACTION_MOVE) {
for (int index = 0; index < pointerCount; index++) { for (int i = 0; i < pointerCount; i++) {
int x = (int)me.getX(index); PointerTracker tracker = getPointerTracker(me.getPointerId(i));
int y = (int)me.getY(index); tracker.onMoveEvent((int)me.getX(i), (int)me.getY(i), eventTime);
int id = me.getPointerId(index);
PointerTracker tracker = getPointerTracker(id);
tracker.onMoveEvent(x, y, eventTime);
} }
} else { } else {
int index = me.getActionIndex();
int x = (int)me.getX(index);
int y = (int)me.getY(index);
int id = me.getPointerId(index);
PointerTracker tracker = getPointerTracker(id); PointerTracker tracker = getPointerTracker(id);
switch (action) { switch (action) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:

View File

@ -65,6 +65,9 @@ public class PointerTracker {
// true if event is already translated to a key action (long press or mini-keyboard) // true if event is already translated to a key action (long press or mini-keyboard)
private boolean mKeyAlreadyProcessed; private boolean mKeyAlreadyProcessed;
// true if this pointer is repeatable key
private boolean mIsRepeatableKey;
// for move de-bouncing // for move de-bouncing
private int mLastCodeX; private int mLastCodeX;
private int mLastCodeY; private int mLastCodeY;
@ -176,6 +179,7 @@ public class PointerTracker {
mStartY = y; mStartY = y;
mDownTime = eventTime; mDownTime = eventTime;
mKeyAlreadyProcessed = false; mKeyAlreadyProcessed = false;
mIsRepeatableKey = false;
startMoveDebouncing(x, y); startMoveDebouncing(x, y);
startTimeDebouncing(eventTime); startTimeDebouncing(eventTime);
checkMultiTap(eventTime, keyIndex); checkMultiTap(eventTime, keyIndex);
@ -187,6 +191,7 @@ public class PointerTracker {
if (mKeys[keyIndex].repeatable) { if (mKeys[keyIndex].repeatable) {
repeatKey(keyIndex); repeatKey(keyIndex);
mHandler.startKeyRepeatTimer(REPEAT_START_DELAY, keyIndex, this); mHandler.startKeyRepeatTimer(REPEAT_START_DELAY, keyIndex, this);
mIsRepeatableKey = true;
} }
mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this); mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
} }
@ -246,10 +251,9 @@ public class PointerTracker {
return; return;
if (DEBUG) if (DEBUG)
debugLog("onUpEvent :", x, y); debugLog("onUpEvent :", x, y);
int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
boolean wasInKeyRepeat = mHandler.isInKeyRepeat();
mHandler.cancelKeyTimers(); mHandler.cancelKeyTimers();
mHandler.cancelPopupPreview(); mHandler.cancelPopupPreview();
int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
if (isMinorMoveBounce(x, y, keyIndex, mCurrentKey)) { if (isMinorMoveBounce(x, y, keyIndex, mCurrentKey)) {
updateTimeDebouncing(eventTime); updateTimeDebouncing(eventTime);
} else { } else {
@ -263,8 +267,7 @@ public class PointerTracker {
y = mLastCodeY; y = mLastCodeY;
} }
showKeyPreviewAndUpdateKey(NOT_A_KEY); showKeyPreviewAndUpdateKey(NOT_A_KEY);
// If we're not on a repeating key (which sends on a DOWN event) if (!mIsRepeatableKey) {
if (!wasInKeyRepeat) {
detectAndSendKey(mCurrentKey, x, y, eventTime); detectAndSendKey(mCurrentKey, x, y, eventTime);
} }
if (isValidKeyIndex(keyIndex)) if (isValidKeyIndex(keyIndex))