Merge "Should cancel both normal and shift long press timers"

main
Tadashi G. Takaoka 2010-11-10 15:31:24 -08:00 committed by Android (Google) Code Review
commit 02d7bdead6
2 changed files with 7 additions and 11 deletions

View File

@ -332,28 +332,24 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
} }
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) { public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {
removeMessages(MSG_LONGPRESS_KEY); cancelLongPressTimers();
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay);
} }
public void cancelLongPressTimer() {
removeMessages(MSG_LONGPRESS_KEY);
}
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) { public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) {
removeMessages(MSG_LONGPRESS_SHIFT_KEY); cancelLongPressTimers();
sendMessageDelayed( sendMessageDelayed(
obtainMessage(MSG_LONGPRESS_SHIFT_KEY, keyIndex, 0, tracker), delay); obtainMessage(MSG_LONGPRESS_SHIFT_KEY, keyIndex, 0, tracker), delay);
} }
public void cancelLongPressShiftTimer() { public void cancelLongPressTimers() {
removeMessages(MSG_LONGPRESS_KEY);
removeMessages(MSG_LONGPRESS_SHIFT_KEY); removeMessages(MSG_LONGPRESS_SHIFT_KEY);
} }
public void cancelKeyTimers() { public void cancelKeyTimers() {
cancelKeyRepeatTimer(); cancelKeyRepeatTimer();
cancelLongPressTimer(); cancelLongPressTimers();
cancelLongPressShiftTimer();
} }
public void cancelAllMessages() { public void cancelAllMessages() {

View File

@ -315,11 +315,11 @@ public class PointerTracker {
} else { } else {
if (keyState.getKeyIndex() != NOT_A_KEY) { if (keyState.getKeyIndex() != NOT_A_KEY) {
keyState.onMoveToNewKey(keyIndex, x ,y); keyState.onMoveToNewKey(keyIndex, x ,y);
mHandler.cancelLongPressTimer(); mHandler.cancelLongPressTimers();
} else if (!isMinorMoveBounce(x, y, keyIndex)) { } else if (!isMinorMoveBounce(x, y, keyIndex)) {
resetMultiTap(); resetMultiTap();
keyState.onMoveToNewKey(keyIndex, x ,y); keyState.onMoveToNewKey(keyIndex, x ,y);
mHandler.cancelLongPressTimer(); mHandler.cancelLongPressTimers();
} }
} }
showKeyPreviewAndUpdateKeyGraphics(mKeyState.getKeyIndex()); showKeyPreviewAndUpdateKeyGraphics(mKeyState.getKeyIndex());