Narrower KeyboardView reference
This change also rename static inner class to more readable name and get rid of unnecessary object reference from PointerTracker. Bug: 4768084 Change-Id: Ie4e2b940d66b47d41efcae7eeac853cdae2e4d38main
parent
bd02fa8495
commit
f60d09ac30
|
@ -29,7 +29,7 @@ import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
|
||||||
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.KeyDetector;
|
import com.android.inputmethod.keyboard.KeyDetector;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
import com.android.inputmethod.keyboard.PointerTracker;
|
||||||
|
|
||||||
public class AccessibleKeyboardViewProxy {
|
public class AccessibleKeyboardViewProxy {
|
||||||
|
@ -40,7 +40,7 @@ public class AccessibleKeyboardViewProxy {
|
||||||
private static final long DELAY_KEY_PRESS = 10;
|
private static final long DELAY_KEY_PRESS = 10;
|
||||||
|
|
||||||
private int mScaledEdgeSlop;
|
private int mScaledEdgeSlop;
|
||||||
private LatinKeyboardBaseView mView;
|
private KeyboardView mView;
|
||||||
private AccessibleKeyboardActionListener mListener;
|
private AccessibleKeyboardActionListener mListener;
|
||||||
private FlickGestureDetector mGestureDetector;
|
private FlickGestureDetector mGestureDetector;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class AccessibleKeyboardViewProxy {
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setView(LatinKeyboardBaseView view) {
|
public static void setView(KeyboardView view) {
|
||||||
sInstance.mView = view;
|
sInstance.mView = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ import java.util.HashMap;
|
||||||
* @attr ref R.styleable#KeyboardView_shadowColor
|
* @attr ref R.styleable#KeyboardView_shadowColor
|
||||||
* @attr ref R.styleable#KeyboardView_shadowRadius
|
* @attr ref R.styleable#KeyboardView_shadowRadius
|
||||||
*/
|
*/
|
||||||
public class KeyboardView extends View implements PointerTracker.UIProxy {
|
public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
private static final boolean DEBUG_KEYBOARD_GRID = false;
|
private static final boolean DEBUG_KEYBOARD_GRID = false;
|
||||||
|
|
||||||
// Miscellaneous constants
|
// Miscellaneous constants
|
||||||
|
@ -123,13 +123,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
|
private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
|
||||||
0, MeasureSpec.UNSPECIFIED);
|
0, MeasureSpec.UNSPECIFIED);
|
||||||
|
|
||||||
private final UIHandler mHandler = new UIHandler(this);
|
private final DrawingHandler mDrawingHandler = new DrawingHandler(this);
|
||||||
|
|
||||||
public static class UIHandler extends StaticInnerHandlerWrapper<KeyboardView> {
|
public static class DrawingHandler extends StaticInnerHandlerWrapper<KeyboardView> {
|
||||||
private static final int MSG_SHOW_KEY_PREVIEW = 1;
|
private static final int MSG_SHOW_KEY_PREVIEW = 1;
|
||||||
private static final int MSG_DISMISS_KEY_PREVIEW = 2;
|
private static final int MSG_DISMISS_KEY_PREVIEW = 2;
|
||||||
|
|
||||||
public UIHandler(KeyboardView outerInstance) {
|
public DrawingHandler(KeyboardView outerInstance) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
*/
|
*/
|
||||||
public void setKeyboard(Keyboard keyboard) {
|
public void setKeyboard(Keyboard keyboard) {
|
||||||
// Remove any pending messages, except dismissing preview
|
// Remove any pending messages, except dismissing preview
|
||||||
mHandler.cancelAllShowKeyPreviews();
|
mDrawingHandler.cancelAllShowKeyPreviews();
|
||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
LatinImeLogger.onSetKeyboard(keyboard);
|
LatinImeLogger.onSetKeyboard(keyboard);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
@ -766,13 +766,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelAllMessages() {
|
public void cancelAllMessages() {
|
||||||
mHandler.cancelAllMessages();
|
mDrawingHandler.cancelAllMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
|
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
|
||||||
if (mShowKeyPreviewPopup) {
|
if (mShowKeyPreviewPopup) {
|
||||||
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
|
mDrawingHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
|
||||||
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
|
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
|
||||||
// Show key preview (in this case, slide language switcher) without any delay.
|
// Show key preview (in this case, slide language switcher) without any delay.
|
||||||
showKey(keyIndex, tracker);
|
showKey(keyIndex, tracker);
|
||||||
|
@ -781,14 +781,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelShowKeyPreview(PointerTracker tracker) {
|
public void cancelShowKeyPreview(PointerTracker tracker) {
|
||||||
mHandler.cancelShowKeyPreview(tracker);
|
mDrawingHandler.cancelShowKeyPreview(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismissKeyPreview(PointerTracker tracker) {
|
public void dismissKeyPreview(PointerTracker tracker) {
|
||||||
if (mShowKeyPreviewPopup) {
|
if (mShowKeyPreviewPopup) {
|
||||||
mHandler.cancelShowKeyPreview(tracker);
|
mDrawingHandler.cancelShowKeyPreview(tracker);
|
||||||
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
|
mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
|
||||||
} else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
|
} else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
|
||||||
// Dismiss key preview (in this case, slide language switcher) without any delay.
|
// Dismiss key preview (in this case, slide language switcher) without any delay.
|
||||||
mPreviewText.setVisibility(View.INVISIBLE);
|
mPreviewText.setVisibility(View.INVISIBLE);
|
||||||
|
@ -821,7 +821,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
if (key == null)
|
if (key == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mHandler.cancelAllDismissKeyPreviews();
|
mDrawingHandler.cancelAllDismissKeyPreviews();
|
||||||
final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
|
final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
|
||||||
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
|
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
|
||||||
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
|
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
|
||||||
|
|
|
@ -88,17 +88,17 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
private final int mSwipeThreshold;
|
private final int mSwipeThreshold;
|
||||||
private final boolean mDisambiguateSwipe;
|
private final boolean mDisambiguateSwipe;
|
||||||
|
|
||||||
private final UIHandler mHandler = new UIHandler(this);
|
private final KeyTimerHandler mKeyTimerHandler = new KeyTimerHandler(this);
|
||||||
|
|
||||||
public static class UIHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
|
public static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
|
||||||
private static final int MSG_REPEAT_KEY = 3;
|
private static final int MSG_REPEAT_KEY = 1;
|
||||||
private static final int MSG_LONGPRESS_KEY = 4;
|
private static final int MSG_LONGPRESS_KEY = 2;
|
||||||
private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
|
private static final int MSG_LONGPRESS_SHIFT_KEY = 3;
|
||||||
private static final int MSG_IGNORE_DOUBLE_TAP = 6;
|
private static final int MSG_IGNORE_DOUBLE_TAP = 4;
|
||||||
|
|
||||||
private boolean mInKeyRepeat;
|
private boolean mInKeyRepeat;
|
||||||
|
|
||||||
public UIHandler(LatinKeyboardBaseView outerInstance) {
|
public KeyTimerHandler(LatinKeyboardBaseView outerInstance) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
// Detected a double tap on shift key. If we are in the ignoring double tap
|
// Detected a double tap on shift key. If we are in the ignoring double tap
|
||||||
// mode, it means we have already turned off caps lock in
|
// mode, it means we have already turned off caps lock in
|
||||||
// {@link KeyboardSwitcher#onReleaseShift} .
|
// {@link KeyboardSwitcher#onReleaseShift} .
|
||||||
final boolean ignoringDoubleTap = mHandler.isIgnoringDoubleTap();
|
final boolean ignoringDoubleTap = mKeyTimerHandler.isIgnoringDoubleTap();
|
||||||
if (!ignoringDoubleTap)
|
if (!ignoringDoubleTap)
|
||||||
onDoubleTapShiftKey(tracker);
|
onDoubleTapShiftKey(tracker);
|
||||||
return true;
|
return true;
|
||||||
|
@ -272,7 +272,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
|
|
||||||
public void startIgnoringDoubleTap() {
|
public void startIgnoringDoubleTap() {
|
||||||
if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
|
if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
|
||||||
mHandler.startIgnoringDoubleTap();
|
mKeyTimerHandler.startIgnoringDoubleTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
|
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
|
||||||
|
@ -303,7 +303,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
dismissAllKeyPreviews();
|
dismissAllKeyPreviews();
|
||||||
}
|
}
|
||||||
// Remove any pending messages, except dismissing preview
|
// Remove any pending messages, except dismissing preview
|
||||||
mHandler.cancelKeyTimers();
|
mKeyTimerHandler.cancelKeyTimers();
|
||||||
super.setKeyboard(keyboard);
|
super.setKeyboard(keyboard);
|
||||||
mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
|
mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
|
||||||
-getPaddingTop() + mVerticalCorrection);
|
-getPaddingTop() + mVerticalCorrection);
|
||||||
|
@ -349,7 +349,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelAllMessages() {
|
public void cancelAllMessages() {
|
||||||
mHandler.cancelAllMessages();
|
mKeyTimerHandler.cancelAllMessages();
|
||||||
super.cancelAllMessages();
|
super.cancelAllMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +481,8 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
||||||
for (int i = pointers.size(); i <= id; i++) {
|
for (int i = pointers.size(); i <= id; i++) {
|
||||||
final PointerTracker tracker =
|
final PointerTracker tracker =
|
||||||
new PointerTracker(i, this, mHandler, mKeyDetector, this);
|
new PointerTracker(i, getContext(), mKeyTimerHandler, mKeyDetector, this,
|
||||||
|
mHasDistinctMultitouch);
|
||||||
if (keyboard != null)
|
if (keyboard != null)
|
||||||
tracker.setKeyboard(keyboard, mKeyDetector);
|
tracker.setKeyboard(keyboard, mKeyDetector);
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
|
@ -506,6 +507,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent me) {
|
public boolean onTouchEvent(MotionEvent me) {
|
||||||
|
final boolean nonDistinctMultitouch = !mHasDistinctMultitouch;
|
||||||
final int action = me.getActionMasked();
|
final int action = me.getActionMasked();
|
||||||
final int pointerCount = me.getPointerCount();
|
final int pointerCount = me.getPointerCount();
|
||||||
final int oldPointerCount = mOldPointerCount;
|
final int oldPointerCount = mOldPointerCount;
|
||||||
|
@ -514,7 +516,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
// 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
|
||||||
// events except a transition from/to single-touch.
|
// events except a transition from/to single-touch.
|
||||||
if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
|
if (nonDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +527,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
if (mPopupMiniKeyboardPanel == null && mGestureDetector != null
|
if (mPopupMiniKeyboardPanel == null && mGestureDetector != null
|
||||||
&& mGestureDetector.onTouchEvent(me)) {
|
&& mGestureDetector.onTouchEvent(me)) {
|
||||||
dismissAllKeyPreviews();
|
dismissAllKeyPreviews();
|
||||||
mHandler.cancelKeyTimers();
|
mKeyTimerHandler.cancelKeyTimers();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,12 +543,12 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
return mPopupMiniKeyboardPanel.onTouchEvent(me);
|
return mPopupMiniKeyboardPanel.onTouchEvent(me);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHandler.isInKeyRepeat()) {
|
if (mKeyTimerHandler.isInKeyRepeat()) {
|
||||||
final PointerTracker tracker = getPointerTracker(id);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
// Key repeating timer will be canceled if 2 or more keys are in action, and current
|
// Key repeating timer will be canceled if 2 or more keys are in action, and current
|
||||||
// event (UP or DOWN) is non-modifier key.
|
// event (UP or DOWN) is non-modifier key.
|
||||||
if (pointerCount > 1 && !tracker.isModifier()) {
|
if (pointerCount > 1 && !tracker.isModifier()) {
|
||||||
mHandler.cancelKeyRepeatTimer();
|
mKeyTimerHandler.cancelKeyRepeatTimer();
|
||||||
}
|
}
|
||||||
// Up event will pass through.
|
// Up event will pass through.
|
||||||
}
|
}
|
||||||
|
@ -554,7 +556,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
||||||
// 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?
|
||||||
// Translate mutli-touch event to single-touch events on the device that has no distinct
|
// Translate mutli-touch event to single-touch events on the device that has no distinct
|
||||||
// multi-touch panel.
|
// multi-touch panel.
|
||||||
if (!mHasDistinctMultitouch) {
|
if (nonDistinctMultitouch) {
|
||||||
// Use only main (id=0) pointer tracker.
|
// Use only main (id=0) pointer tracker.
|
||||||
PointerTracker tracker = getPointerTracker(0);
|
PointerTracker tracker = getPointerTracker(0);
|
||||||
if (pointerCount == 1 && oldPointerCount == 2) {
|
if (pointerCount == 1 && oldPointerCount == 2) {
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.SystemClock;
|
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.UIHandler;
|
import com.android.inputmethod.keyboard.LatinKeyboardBaseView.KeyTimerHandler;
|
||||||
import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
|
import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
|
||||||
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;
|
||||||
|
@ -39,7 +40,7 @@ public class PointerTracker {
|
||||||
private static final boolean DEBUG_LISTENER = false;
|
private static final boolean DEBUG_LISTENER = false;
|
||||||
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
|
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
public interface UIProxy {
|
public interface DrawingProxy {
|
||||||
public void invalidateKey(Key key);
|
public void invalidateKey(Key key);
|
||||||
public void showKeyPreview(int keyIndex, PointerTracker tracker);
|
public void showKeyPreview(int keyIndex, PointerTracker tracker);
|
||||||
public void cancelShowKeyPreview(PointerTracker tracker);
|
public void cancelShowKeyPreview(PointerTracker tracker);
|
||||||
|
@ -53,9 +54,8 @@ public class PointerTracker {
|
||||||
private final int mLongPressKeyTimeout;
|
private final int mLongPressKeyTimeout;
|
||||||
private final int mLongPressShiftKeyTimeout;
|
private final int mLongPressShiftKeyTimeout;
|
||||||
|
|
||||||
private final LatinKeyboardBaseView mKeyboardView;
|
private final DrawingProxy mDrawingProxy;
|
||||||
private final UIProxy mProxy;
|
private final KeyTimerHandler mKeyTimerHandler;
|
||||||
private final UIHandler mHandler;
|
|
||||||
private KeyDetector mKeyDetector;
|
private KeyDetector mKeyDetector;
|
||||||
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
||||||
private final KeyboardSwitcher mKeyboardSwitcher;
|
private final KeyboardSwitcher mKeyboardSwitcher;
|
||||||
|
@ -111,19 +111,18 @@ public class PointerTracker {
|
||||||
public void onSwipeDown() {}
|
public void onSwipeDown() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
public PointerTracker(int id, LatinKeyboardBaseView keyboardView, UIHandler handler,
|
public PointerTracker(int id, Context context, KeyTimerHandler keyTimerHandler,
|
||||||
KeyDetector keyDetector, UIProxy proxy) {
|
KeyDetector keyDetector, DrawingProxy drawingProxy, boolean hasDistinctMultitouch) {
|
||||||
if (proxy == null || handler == null || keyDetector == null)
|
if (drawingProxy == null || keyTimerHandler == null || keyDetector == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
mPointerId = id;
|
mPointerId = id;
|
||||||
mKeyboardView = keyboardView;
|
mDrawingProxy = drawingProxy;
|
||||||
mProxy = proxy;
|
mKeyTimerHandler = keyTimerHandler;
|
||||||
mHandler = handler;
|
|
||||||
mKeyDetector = keyDetector;
|
mKeyDetector = keyDetector;
|
||||||
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
||||||
mKeyState = new PointerTrackerKeyState(keyDetector);
|
mKeyState = new PointerTrackerKeyState(keyDetector);
|
||||||
mHasDistinctMultitouch = keyboardView.hasDistinctMultitouch();
|
mHasDistinctMultitouch = hasDistinctMultitouch;
|
||||||
final Resources res = mKeyboardView.getResources();
|
final Resources res = context.getResources();
|
||||||
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
|
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
|
||||||
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
||||||
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
||||||
|
@ -262,7 +261,7 @@ public class PointerTracker {
|
||||||
final Key key = getKey(keyIndex);
|
final Key key = getKey(keyIndex);
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
key.onReleased();
|
key.onReleased();
|
||||||
mProxy.invalidateKey(key);
|
mDrawingProxy.invalidateKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +269,7 @@ public class PointerTracker {
|
||||||
final Key key = getKey(keyIndex);
|
final Key key = getKey(keyIndex);
|
||||||
if (key != null && key.isEnabled()) {
|
if (key != null && key.isEnabled()) {
|
||||||
key.onPressed();
|
key.onPressed();
|
||||||
mProxy.invalidateKey(key);
|
mDrawingProxy.invalidateKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +403,7 @@ public class PointerTracker {
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
||||||
startSlidingKeyInput(oldKey);
|
startSlidingKeyInput(oldKey);
|
||||||
mHandler.cancelKeyTimers();
|
mKeyTimerHandler.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
|
||||||
|
@ -462,7 +461,7 @@ public class PointerTracker {
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
||||||
startSlidingKeyInput(oldKey);
|
startSlidingKeyInput(oldKey);
|
||||||
mHandler.cancelLongPressTimers();
|
mKeyTimerHandler.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -503,8 +502,8 @@ 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) {
|
||||||
mHandler.cancelKeyTimers();
|
mKeyTimerHandler.cancelKeyTimers();
|
||||||
mProxy.cancelShowKeyPreview(this);
|
mDrawingProxy.cancelShowKeyPreview(this);
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
final PointerTrackerKeyState keyState = mKeyState;
|
final PointerTrackerKeyState keyState = mKeyState;
|
||||||
final int keyX, keyY;
|
final int keyX, keyY;
|
||||||
|
@ -563,8 +562,8 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCancelEventInternal() {
|
private void onCancelEventInternal() {
|
||||||
mHandler.cancelKeyTimers();
|
mKeyTimerHandler.cancelKeyTimers();
|
||||||
mProxy.cancelShowKeyPreview(this);
|
mDrawingProxy.cancelShowKeyPreview(this);
|
||||||
dismissKeyPreview();
|
dismissKeyPreview();
|
||||||
setReleasedKeyGraphics(mKeyState.getKeyIndex());
|
setReleasedKeyGraphics(mKeyState.getKeyIndex());
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
|
@ -575,7 +574,7 @@ public class PointerTracker {
|
||||||
if (key != null && key.mRepeatable) {
|
if (key != null && key.mRepeatable) {
|
||||||
dismissKeyPreview();
|
dismissKeyPreview();
|
||||||
onRepeatKey(keyIndex);
|
onRepeatKey(keyIndex);
|
||||||
mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
|
mKeyTimerHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
|
||||||
mIsRepeatableKey = true;
|
mIsRepeatableKey = true;
|
||||||
} else {
|
} else {
|
||||||
mIsRepeatableKey = false;
|
mIsRepeatableKey = false;
|
||||||
|
@ -631,26 +630,26 @@ public class PointerTracker {
|
||||||
private void showKeyPreview(int keyIndex) {
|
private void showKeyPreview(int keyIndex) {
|
||||||
if (isKeyPreviewNotRequired(keyIndex))
|
if (isKeyPreviewNotRequired(keyIndex))
|
||||||
return;
|
return;
|
||||||
mProxy.showKeyPreview(keyIndex, this);
|
mDrawingProxy.showKeyPreview(keyIndex, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismissKeyPreview() {
|
private void dismissKeyPreview() {
|
||||||
mProxy.dismissKeyPreview(this);
|
mDrawingProxy.dismissKeyPreview(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
|
mKeyTimerHandler.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.
|
||||||
mHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
|
mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
|
||||||
} else {
|
} else {
|
||||||
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.graphics.Rect;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.MiniKeyboard;
|
import com.android.inputmethod.keyboard.MiniKeyboard;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ public class MiniKeyboardBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiniKeyboardBuilder(LatinKeyboardBaseView view, int layoutTemplateResId, Key parentKey,
|
public MiniKeyboardBuilder(KeyboardView view, int layoutTemplateResId, Key parentKey,
|
||||||
Keyboard parentKeyboard) {
|
Keyboard parentKeyboard) {
|
||||||
final Context context = view.getContext();
|
final Context context = view.getContext();
|
||||||
mRes = context.getResources();
|
mRes = context.getResources();
|
||||||
|
@ -223,7 +223,7 @@ public class MiniKeyboardBuilder {
|
||||||
keyboard.setDefaultCoordX(params.getDefaultKeyCoordX() + params.mKeyWidth / 2);
|
keyboard.setDefaultCoordX(params.getDefaultKeyCoordX() + params.mKeyWidth / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMaxKeyWidth(LatinKeyboardBaseView view, CharSequence[] popupCharacters,
|
private static int getMaxKeyWidth(KeyboardView view, CharSequence[] popupCharacters,
|
||||||
int minKeyWidth) {
|
int minKeyWidth) {
|
||||||
Paint paint = null;
|
Paint paint = null;
|
||||||
Rect bounds = null;
|
Rect bounds = null;
|
||||||
|
|
|
@ -66,7 +66,7 @@ import com.android.inputmethod.deprecated.recorrection.Recorrection;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
import com.android.inputmethod.keyboard.LatinKeyboard;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
@Override
|
@Override
|
||||||
public void onWindowHidden() {
|
public void onWindowHidden() {
|
||||||
super.onWindowHidden();
|
super.onWindowHidden();
|
||||||
LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
|
KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView != null) inputView.closing();
|
if (inputView != null) inputView.closing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
|
mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
|
||||||
|
|
||||||
LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
|
KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView != null) inputView.closing();
|
if (inputView != null) inputView.closing();
|
||||||
if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
|
if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
|
||||||
if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
|
if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
|
||||||
|
@ -677,7 +677,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
@Override
|
@Override
|
||||||
public void onFinishInputView(boolean finishingInput) {
|
public void onFinishInputView(boolean finishingInput) {
|
||||||
super.onFinishInputView(finishingInput);
|
super.onFinishInputView(finishingInput);
|
||||||
LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
|
KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView != null) inputView.cancelAllMessages();
|
if (inputView != null) inputView.cancelAllMessages();
|
||||||
// Remove pending messages related to update suggestions
|
// Remove pending messages related to update suggestions
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestions();
|
||||||
|
@ -866,7 +866,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
@Override
|
@Override
|
||||||
public void onComputeInsets(InputMethodService.Insets outInsets) {
|
public void onComputeInsets(InputMethodService.Insets outInsets) {
|
||||||
super.onComputeInsets(outInsets);
|
super.onComputeInsets(outInsets);
|
||||||
final LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
|
final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView == null || mCandidateViewContainer == null)
|
if (inputView == null || mCandidateViewContainer == null)
|
||||||
return;
|
return;
|
||||||
final int containerHeight = mCandidateViewContainer.getHeight();
|
final int containerHeight = mCandidateViewContainer.getHeight();
|
||||||
|
|
Loading…
Reference in New Issue