Narrower key timer handler static inner class to TimerProxy interface
Bug: 4768084 Change-Id: I8fdff864d09321b44d56a6a32e10aec3f0f5a4d1main
parent
ab41391cb4
commit
2321caa1f9
|
@ -33,6 +33,7 @@ import android.widget.PopupWindow;
|
||||||
|
|
||||||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
|
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
||||||
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
|
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
|
||||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -86,7 +87,8 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
|
|
||||||
private final KeyTimerHandler mKeyTimerHandler = new KeyTimerHandler(this);
|
private final KeyTimerHandler mKeyTimerHandler = new KeyTimerHandler(this);
|
||||||
|
|
||||||
public static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
|
private static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView>
|
||||||
|
implements TimerProxy {
|
||||||
private static final int MSG_REPEAT_KEY = 1;
|
private static final int MSG_REPEAT_KEY = 1;
|
||||||
private static final int MSG_LONGPRESS_KEY = 2;
|
private static final int MSG_LONGPRESS_KEY = 2;
|
||||||
private static final int MSG_LONGPRESS_SHIFT_KEY = 3;
|
private static final int MSG_LONGPRESS_SHIFT_KEY = 3;
|
||||||
|
@ -116,6 +118,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
mInKeyRepeat = true;
|
mInKeyRepeat = true;
|
||||||
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, keyIndex, 0, tracker), delay);
|
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, keyIndex, 0, tracker), delay);
|
||||||
|
@ -130,11 +133,13 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
return mInKeyRepeat;
|
return mInKeyRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimers();
|
||||||
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay);
|
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimers();
|
||||||
if (ENABLE_CAPSLOCK_BY_LONGPRESS) {
|
if (ENABLE_CAPSLOCK_BY_LONGPRESS) {
|
||||||
|
@ -143,11 +148,13 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void cancelLongPressTimers() {
|
public void cancelLongPressTimers() {
|
||||||
removeMessages(MSG_LONGPRESS_KEY);
|
removeMessages(MSG_LONGPRESS_KEY);
|
||||||
removeMessages(MSG_LONGPRESS_SHIFT_KEY);
|
removeMessages(MSG_LONGPRESS_SHIFT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void cancelKeyTimers() {
|
public void cancelKeyTimers() {
|
||||||
cancelKeyRepeatTimer();
|
cancelKeyRepeatTimer();
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimers();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardBaseView.KeyTimerHandler;
|
|
||||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -45,6 +44,14 @@ public class PointerTracker {
|
||||||
public void dismissKeyPreview(PointerTracker tracker);
|
public void dismissKeyPreview(PointerTracker tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface TimerProxy {
|
||||||
|
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker);
|
||||||
|
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker);
|
||||||
|
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker);
|
||||||
|
public void cancelLongPressTimers();
|
||||||
|
public void cancelKeyTimers();
|
||||||
|
}
|
||||||
|
|
||||||
public final int mPointerId;
|
public final int mPointerId;
|
||||||
|
|
||||||
// Timing constants
|
// Timing constants
|
||||||
|
@ -53,7 +60,7 @@ public class PointerTracker {
|
||||||
private final int mLongPressShiftKeyTimeout;
|
private final int mLongPressShiftKeyTimeout;
|
||||||
|
|
||||||
private final DrawingProxy mDrawingProxy;
|
private final DrawingProxy mDrawingProxy;
|
||||||
private final KeyTimerHandler mKeyTimerHandler;
|
private final TimerProxy mTimerProxy;
|
||||||
private final PointerTrackerQueue mPointerTrackerQueue;
|
private final PointerTrackerQueue mPointerTrackerQueue;
|
||||||
private KeyDetector mKeyDetector;
|
private KeyDetector mKeyDetector;
|
||||||
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
||||||
|
@ -119,13 +126,13 @@ public class PointerTracker {
|
||||||
public void onCancelInput() {}
|
public void onCancelInput() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
public PointerTracker(int id, Context context, KeyTimerHandler keyTimerHandler,
|
public PointerTracker(int id, Context context, TimerProxy timerProxy, KeyDetector keyDetector,
|
||||||
KeyDetector keyDetector, DrawingProxy drawingProxy, PointerTrackerQueue queue) {
|
DrawingProxy drawingProxy, PointerTrackerQueue queue) {
|
||||||
if (drawingProxy == null || keyTimerHandler == null || keyDetector == null)
|
if (drawingProxy == null || timerProxy == null || keyDetector == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
mPointerId = id;
|
mPointerId = id;
|
||||||
mDrawingProxy = drawingProxy;
|
mDrawingProxy = drawingProxy;
|
||||||
mKeyTimerHandler = keyTimerHandler;
|
mTimerProxy = timerProxy;
|
||||||
mPointerTrackerQueue = queue; // This is null for non-distinct multi-touch device.
|
mPointerTrackerQueue = queue; // This is null for non-distinct multi-touch device.
|
||||||
setKeyDetectorInner(keyDetector);
|
setKeyDetectorInner(keyDetector);
|
||||||
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
||||||
|
@ -442,7 +449,7 @@ public class PointerTracker {
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
||||||
startSlidingKeyInput(oldKey);
|
startSlidingKeyInput(oldKey);
|
||||||
mKeyTimerHandler.cancelKeyTimers();
|
mTimerProxy.cancelKeyTimers();
|
||||||
startRepeatKey(keyIndex);
|
startRepeatKey(keyIndex);
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
// This onPress call may have changed keyboard layout. Those cases are detected
|
// This onPress call may have changed keyboard layout. Those cases are detected
|
||||||
|
@ -501,7 +508,7 @@ public class PointerTracker {
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
||||||
startSlidingKeyInput(oldKey);
|
startSlidingKeyInput(oldKey);
|
||||||
mKeyTimerHandler.cancelLongPressTimers();
|
mTimerProxy.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
onMoveToNewKey(keyIndex, x, y);
|
onMoveToNewKey(keyIndex, x, y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -542,7 +549,7 @@ public class PointerTracker {
|
||||||
|
|
||||||
private void onUpEventInternal(int x, int y, long eventTime,
|
private void onUpEventInternal(int x, int y, long eventTime,
|
||||||
boolean updateReleasedKeyGraphics) {
|
boolean updateReleasedKeyGraphics) {
|
||||||
mKeyTimerHandler.cancelKeyTimers();
|
mTimerProxy.cancelKeyTimers();
|
||||||
mDrawingProxy.cancelShowKeyPreview(this);
|
mDrawingProxy.cancelShowKeyPreview(this);
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
final int keyX, keyY;
|
final int keyX, keyY;
|
||||||
|
@ -602,7 +609,7 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCancelEventInternal() {
|
private void onCancelEventInternal() {
|
||||||
mKeyTimerHandler.cancelKeyTimers();
|
mTimerProxy.cancelKeyTimers();
|
||||||
mDrawingProxy.cancelShowKeyPreview(this);
|
mDrawingProxy.cancelShowKeyPreview(this);
|
||||||
dismissKeyPreview();
|
dismissKeyPreview();
|
||||||
setReleasedKeyGraphics(mKeyIndex);
|
setReleasedKeyGraphics(mKeyIndex);
|
||||||
|
@ -614,7 +621,7 @@ public class PointerTracker {
|
||||||
if (key != null && key.mRepeatable) {
|
if (key != null && key.mRepeatable) {
|
||||||
dismissKeyPreview();
|
dismissKeyPreview();
|
||||||
onRepeatKey(keyIndex);
|
onRepeatKey(keyIndex);
|
||||||
mKeyTimerHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
|
mTimerProxy.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
|
||||||
mIsRepeatableKey = true;
|
mIsRepeatableKey = true;
|
||||||
} else {
|
} else {
|
||||||
mIsRepeatableKey = false;
|
mIsRepeatableKey = false;
|
||||||
|
@ -668,16 +675,16 @@ public class PointerTracker {
|
||||||
private void startLongPressTimer(int keyIndex) {
|
private void startLongPressTimer(int keyIndex) {
|
||||||
Key key = getKey(keyIndex);
|
Key key = getKey(keyIndex);
|
||||||
if (key.mCode == Keyboard.CODE_SHIFT) {
|
if (key.mCode == Keyboard.CODE_SHIFT) {
|
||||||
mKeyTimerHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
|
mTimerProxy.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
|
||||||
} else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
|
} else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
|
||||||
// We need not start long press timer on the key which has manual temporary upper case
|
// We need not start long press timer on the key which has manual temporary upper case
|
||||||
// code defined and the keyboard is in manual temporary upper case mode.
|
// code defined and the keyboard is in manual temporary upper case mode.
|
||||||
return;
|
return;
|
||||||
} else if (mKeyboardSwitcher.isInMomentarySwitchState()) {
|
} else if (mKeyboardSwitcher.isInMomentarySwitchState()) {
|
||||||
// We use longer timeout for sliding finger input started from the symbols mode key.
|
// We use longer timeout for sliding finger input started from the symbols mode key.
|
||||||
mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
|
mTimerProxy.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
|
||||||
} else {
|
} else {
|
||||||
mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
mTimerProxy.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue