aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java18
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java22
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java47
-rw-r--r--java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java72
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java6
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java10
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsActivity.java20
10 files changed, 123 insertions, 86 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 38d904a94..a87ff9891 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -29,7 +29,7 @@ import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
-import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
+import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
public class AccessibleKeyboardViewProxy {
@@ -40,7 +40,7 @@ public class AccessibleKeyboardViewProxy {
private static final long DELAY_KEY_PRESS = 10;
private int mScaledEdgeSlop;
- private LatinKeyboardBaseView mView;
+ private KeyboardView mView;
private AccessibleKeyboardActionListener mListener;
private FlickGestureDetector mGestureDetector;
@@ -57,7 +57,7 @@ public class AccessibleKeyboardViewProxy {
return sInstance;
}
- public static void setView(LatinKeyboardBaseView view) {
+ public static void setView(KeyboardView view) {
sInstance.mView = view;
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 7add43a6d..85418a61d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -28,6 +28,8 @@ public class KeyDetector {
public static final int NOT_A_CODE = -1;
public static final int NOT_A_KEY = -1;
+ private final int mKeyHysteresisDistanceSquared;
+
private Keyboard mKeyboard;
private int mCorrectionX;
private int mCorrectionY;
@@ -39,12 +41,28 @@ public class KeyDetector {
private final int[] mDistances = new int[MAX_NEARBY_KEYS];
private final int[] mIndices = new int[MAX_NEARBY_KEYS];
+ /**
+ * This class handles key detection.
+ *
+ * @param keyHysteresisDistance if the pointer movement distance is smaller than this, the
+ * movement will not been handled as meaningful movement. The unit is pixel.
+ */
+ public KeyDetector(float keyHysteresisDistance) {
+ mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance);
+ }
+
public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
if (keyboard == null)
throw new NullPointerException();
mCorrectionX = (int)correctionX;
mCorrectionY = (int)correctionY;
mKeyboard = keyboard;
+ final int threshold = keyboard.getMostCommonKeyWidth();
+ mProximityThresholdSquare = threshold * threshold;
+ }
+
+ public int getKeyHysteresisDistanceSquared() {
+ return mKeyHysteresisDistanceSquared;
}
protected int getTouchX(int x) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index f3e023d3e..d1345db9d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -72,7 +72,7 @@ import java.util.HashMap;
* @attr ref R.styleable#KeyboardView_shadowColor
* @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;
// Miscellaneous constants
@@ -123,13 +123,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
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_DISMISS_KEY_PREVIEW = 2;
- public UIHandler(KeyboardView outerInstance) {
+ public DrawingHandler(KeyboardView outerInstance) {
super(outerInstance);
}
@@ -365,7 +365,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
*/
public void setKeyboard(Keyboard keyboard) {
// Remove any pending messages, except dismissing preview
- mHandler.cancelAllShowKeyPreviews();
+ mDrawingHandler.cancelAllShowKeyPreviews();
mKeyboard = keyboard;
LatinImeLogger.onSetKeyboard(keyboard);
requestLayout();
@@ -766,13 +766,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
public void cancelAllMessages() {
- mHandler.cancelAllMessages();
+ mDrawingHandler.cancelAllMessages();
}
@Override
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
if (mShowKeyPreviewPopup) {
- mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
+ mDrawingHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
// Show key preview (in this case, slide language switcher) without any delay.
showKey(keyIndex, tracker);
@@ -781,14 +781,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
@Override
public void cancelShowKeyPreview(PointerTracker tracker) {
- mHandler.cancelShowKeyPreview(tracker);
+ mDrawingHandler.cancelShowKeyPreview(tracker);
}
@Override
public void dismissKeyPreview(PointerTracker tracker) {
if (mShowKeyPreviewPopup) {
- mHandler.cancelShowKeyPreview(tracker);
- mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
+ mDrawingHandler.cancelShowKeyPreview(tracker);
+ mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
} else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
// Dismiss key preview (in this case, slide language switcher) without any delay.
mPreviewText.setVisibility(View.INVISIBLE);
@@ -821,7 +821,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
if (key == null)
return;
- mHandler.cancelAllDismissKeyPreviews();
+ mDrawingHandler.cancelAllDismissKeyPreviews();
final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
index 0a7ba05c8..c8cfb43e3 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
@@ -59,7 +59,6 @@ public class LatinKeyboardBaseView extends KeyboardView {
private final int mKeyRepeatInterval;
// XML attribute
- private final float mKeyHysteresisDistance;
private final float mVerticalCorrection;
private final int mPopupLayout;
@@ -81,7 +80,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
private int mOldPointerCount = 1;
private int mOldKeyIndex;
- protected KeyDetector mKeyDetector = new KeyDetector();
+ protected KeyDetector mKeyDetector;
// Swipe gesture detector
protected GestureDetector mGestureDetector;
@@ -89,17 +88,17 @@ public class LatinKeyboardBaseView extends KeyboardView {
private final int mSwipeThreshold;
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> {
- private static final int MSG_REPEAT_KEY = 3;
- private static final int MSG_LONGPRESS_KEY = 4;
- private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
- private static final int MSG_IGNORE_DOUBLE_TAP = 6;
+ public static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
+ private static final int MSG_REPEAT_KEY = 1;
+ private static final int MSG_LONGPRESS_KEY = 2;
+ private static final int MSG_LONGPRESS_SHIFT_KEY = 3;
+ private static final int MSG_IGNORE_DOUBLE_TAP = 4;
private boolean mInKeyRepeat;
- public UIHandler(LatinKeyboardBaseView outerInstance) {
+ public KeyTimerHandler(LatinKeyboardBaseView outerInstance) {
super(outerInstance);
}
@@ -182,8 +181,6 @@ public class LatinKeyboardBaseView extends KeyboardView {
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
- mKeyHysteresisDistance = a.getDimensionPixelOffset(
- R.styleable.KeyboardView_keyHysteresisDistance, 0);
mVerticalCorrection = a.getDimensionPixelOffset(
R.styleable.KeyboardView_verticalCorrection, 0);
@@ -193,6 +190,8 @@ public class LatinKeyboardBaseView extends KeyboardView {
final Resources res = getResources();
+ final float keyHysteresisDistance = res.getDimension(R.dimen.key_hysteresis_distance);
+ mKeyDetector = new KeyDetector(keyHysteresisDistance);
mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density);
// TODO: Refer to frameworks/base/core/res/res/values/config.xml
mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation);
@@ -250,7 +249,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
// 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
// {@link KeyboardSwitcher#onReleaseShift} .
- final boolean ignoringDoubleTap = mHandler.isIgnoringDoubleTap();
+ final boolean ignoringDoubleTap = mKeyTimerHandler.isIgnoringDoubleTap();
if (!ignoringDoubleTap)
onDoubleTapShiftKey(tracker);
return true;
@@ -273,7 +272,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
public void startIgnoringDoubleTap() {
if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
- mHandler.startIgnoringDoubleTap();
+ mKeyTimerHandler.startIgnoringDoubleTap();
}
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
@@ -304,12 +303,12 @@ public class LatinKeyboardBaseView extends KeyboardView {
dismissAllKeyPreviews();
}
// Remove any pending messages, except dismissing preview
- mHandler.cancelKeyTimers();
+ mKeyTimerHandler.cancelKeyTimers();
super.setKeyboard(keyboard);
mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
-getPaddingTop() + mVerticalCorrection);
for (PointerTracker tracker : mPointerTrackers) {
- tracker.setKeyboard(keyboard, mKeyHysteresisDistance);
+ tracker.setKeyboard(keyboard, mKeyDetector);
}
mKeyDetector.setProximityThreshold(keyboard.getMostCommonKeyWidth());
mPopupPanelCache.clear();
@@ -350,7 +349,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
@Override
public void cancelAllMessages() {
- mHandler.cancelAllMessages();
+ mKeyTimerHandler.cancelAllMessages();
super.cancelAllMessages();
}
@@ -482,9 +481,10 @@ public class LatinKeyboardBaseView extends KeyboardView {
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
for (int i = pointers.size(); i <= id; i++) {
final PointerTracker tracker =
- new PointerTracker(i, this, mHandler, mKeyDetector, this);
+ new PointerTracker(i, getContext(), mKeyTimerHandler, mKeyDetector, this,
+ mHasDistinctMultitouch);
if (keyboard != null)
- tracker.setKeyboard(keyboard, mKeyHysteresisDistance);
+ tracker.setKeyboard(keyboard, mKeyDetector);
if (listener != null)
tracker.setOnKeyboardActionListener(listener);
pointers.add(tracker);
@@ -507,6 +507,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
@Override
public boolean onTouchEvent(MotionEvent me) {
+ final boolean nonDistinctMultitouch = !mHasDistinctMultitouch;
final int action = me.getActionMasked();
final int pointerCount = me.getPointerCount();
final int oldPointerCount = mOldPointerCount;
@@ -515,7 +516,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
// 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
// events except a transition from/to single-touch.
- if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
+ if (nonDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
return true;
}
@@ -526,7 +527,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
if (mPopupMiniKeyboardPanel == null && mGestureDetector != null
&& mGestureDetector.onTouchEvent(me)) {
dismissAllKeyPreviews();
- mHandler.cancelKeyTimers();
+ mKeyTimerHandler.cancelKeyTimers();
return true;
}
@@ -542,12 +543,12 @@ public class LatinKeyboardBaseView extends KeyboardView {
return mPopupMiniKeyboardPanel.onTouchEvent(me);
}
- if (mHandler.isInKeyRepeat()) {
+ if (mKeyTimerHandler.isInKeyRepeat()) {
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();
+ mKeyTimerHandler.cancelKeyRepeatTimer();
}
// Up event will pass through.
}
@@ -555,7 +556,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
// 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
// multi-touch panel.
- if (!mHasDistinctMultitouch) {
+ if (nonDistinctMultitouch) {
// Use only main (id=0) pointer tracker.
PointerTracker tracker = getPointerTracker(0);
if (pointerCount == 1 && oldPointerCount == 2) {
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
index cc5c3bbfe..69005db57 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
@@ -23,7 +23,7 @@ public class MiniKeyboardKeyDetector extends KeyDetector {
private final int mSlideAllowanceSquareTop;
public MiniKeyboardKeyDetector(float slideAllowance) {
- super();
+ super(/* keyHysteresisDistance */0);
mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance);
// Top slide allowance is slightly longer (sqrt(2) times) than other edges.
mSlideAllowanceSquareTop = mSlideAllowanceSquare * 2;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 68284cd1b..4ceabff4c 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -16,12 +16,13 @@
package com.android.inputmethod.keyboard;
+import android.content.Context;
import android.content.res.Resources;
import android.os.SystemClock;
import android.util.Log;
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.PointerTrackerQueue;
import com.android.inputmethod.latin.LatinImeLogger;
@@ -39,7 +40,7 @@ public class PointerTracker {
private static final boolean DEBUG_LISTENER = false;
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
- public interface UIProxy {
+ public interface DrawingProxy {
public void invalidateKey(Key key);
public void showKeyPreview(int keyIndex, PointerTracker tracker);
public void cancelShowKeyPreview(PointerTracker tracker);
@@ -53,10 +54,9 @@ public class PointerTracker {
private final int mLongPressKeyTimeout;
private final int mLongPressShiftKeyTimeout;
- private final LatinKeyboardBaseView mKeyboardView;
- private final UIProxy mProxy;
- private final UIHandler mHandler;
- private final KeyDetector mKeyDetector;
+ private final DrawingProxy mDrawingProxy;
+ private final KeyTimerHandler mKeyTimerHandler;
+ private KeyDetector mKeyDetector;
private KeyboardActionListener mListener = EMPTY_LISTENER;
private final KeyboardSwitcher mKeyboardSwitcher;
private final boolean mHasDistinctMultitouch;
@@ -67,7 +67,6 @@ public class PointerTracker {
private Keyboard mKeyboard;
private List<Key> mKeys;
- private int mKeyHysteresisDistanceSquared = -1;
private int mKeyQuarterWidthSquared;
private final PointerTrackerKeyState mKeyState;
@@ -112,19 +111,18 @@ public class PointerTracker {
public void onSwipeDown() {}
};
- public PointerTracker(int id, LatinKeyboardBaseView keyboardView, UIHandler handler,
- KeyDetector keyDetector, UIProxy proxy) {
- if (proxy == null || handler == null || keyDetector == null)
+ public PointerTracker(int id, Context context, KeyTimerHandler keyTimerHandler,
+ KeyDetector keyDetector, DrawingProxy drawingProxy, boolean hasDistinctMultitouch) {
+ if (drawingProxy == null || keyTimerHandler == null || keyDetector == null)
throw new NullPointerException();
mPointerId = id;
- mKeyboardView = keyboardView;
- mProxy = proxy;
- mHandler = handler;
+ mDrawingProxy = drawingProxy;
+ mKeyTimerHandler = keyTimerHandler;
mKeyDetector = keyDetector;
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mKeyState = new PointerTrackerKeyState(keyDetector);
- mHasDistinctMultitouch = keyboardView.hasDistinctMultitouch();
- final Resources res = mKeyboardView.getResources();
+ mHasDistinctMultitouch = hasDistinctMultitouch;
+ final Resources res = context.getResources();
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
@@ -198,12 +196,13 @@ public class PointerTracker {
mListener.onCancelInput();
}
- public void setKeyboard(Keyboard keyboard, float keyHysteresisDistance) {
- if (keyboard == null || keyHysteresisDistance < 0)
- throw new IllegalArgumentException();
+ public void setKeyboard(Keyboard keyboard, KeyDetector keyDetector) {
+ if (keyboard == null || keyDetector == null)
+ throw new NullPointerException();
mKeyboard = keyboard;
mKeys = keyboard.getKeys();
- mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance);
+ mKeyDetector = keyDetector;
+ mKeyState.setKeyDetector(keyDetector);
final int keyQuarterWidth = keyboard.getKeyWidth() / 4;
mKeyQuarterWidthSquared = keyQuarterWidth * keyQuarterWidth;
// Mark that keyboard layout has been changed.
@@ -262,7 +261,7 @@ public class PointerTracker {
final Key key = getKey(keyIndex);
if (key != null) {
key.onReleased();
- mProxy.invalidateKey(key);
+ mDrawingProxy.invalidateKey(key);
}
}
@@ -270,7 +269,7 @@ public class PointerTracker {
final Key key = getKey(keyIndex);
if (key != null && key.isEnabled()) {
key.onPressed();
- mProxy.invalidateKey(key);
+ mDrawingProxy.invalidateKey(key);
}
}
@@ -404,7 +403,7 @@ public class PointerTracker {
setReleasedKeyGraphics(oldKeyIndex);
callListenerOnRelease(oldKey, oldKey.mCode, true);
startSlidingKeyInput(oldKey);
- mHandler.cancelKeyTimers();
+ mKeyTimerHandler.cancelKeyTimers();
startRepeatKey(keyIndex);
if (mIsAllowedSlidingKeyInput) {
// This onPress call may have changed keyboard layout. Those cases are detected
@@ -462,7 +461,7 @@ public class PointerTracker {
setReleasedKeyGraphics(oldKeyIndex);
callListenerOnRelease(oldKey, oldKey.mCode, true);
startSlidingKeyInput(oldKey);
- mHandler.cancelLongPressTimers();
+ mKeyTimerHandler.cancelLongPressTimers();
if (mIsAllowedSlidingKeyInput) {
keyState.onMoveToNewKey(keyIndex, x, y);
} else {
@@ -503,8 +502,8 @@ public class PointerTracker {
private void onUpEventInternal(int x, int y, long eventTime,
boolean updateReleasedKeyGraphics) {
- mHandler.cancelKeyTimers();
- mProxy.cancelShowKeyPreview(this);
+ mKeyTimerHandler.cancelKeyTimers();
+ mDrawingProxy.cancelShowKeyPreview(this);
mIsInSlidingKeyInput = false;
final PointerTrackerKeyState keyState = mKeyState;
final int keyX, keyY;
@@ -563,8 +562,8 @@ public class PointerTracker {
}
private void onCancelEventInternal() {
- mHandler.cancelKeyTimers();
- mProxy.cancelShowKeyPreview(this);
+ mKeyTimerHandler.cancelKeyTimers();
+ mDrawingProxy.cancelShowKeyPreview(this);
dismissKeyPreview();
setReleasedKeyGraphics(mKeyState.getKeyIndex());
mIsInSlidingKeyInput = false;
@@ -575,7 +574,7 @@ public class PointerTracker {
if (key != null && key.mRepeatable) {
dismissKeyPreview();
onRepeatKey(keyIndex);
- mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
+ mKeyTimerHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
mIsRepeatableKey = true;
} else {
mIsRepeatableKey = false;
@@ -602,13 +601,14 @@ public class PointerTracker {
}
private boolean isMajorEnoughMoveToBeOnNewKey(int x, int y, int newKey) {
- if (mKeys == null || mKeyHysteresisDistanceSquared < 0)
- throw new IllegalStateException("keyboard and/or hysteresis not set");
+ if (mKeys == null || mKeyDetector == null)
+ throw new NullPointerException("keyboard and/or key detector not set");
int curKey = mKeyState.getKeyIndex();
if (newKey == curKey) {
return false;
} else if (isValidKeyIndex(curKey)) {
- return mKeys.get(curKey).squaredDistanceToEdge(x, y) >= mKeyHysteresisDistanceSquared;
+ return mKeys.get(curKey).squaredDistanceToEdge(x, y)
+ >= mKeyDetector.getKeyHysteresisDistanceSquared();
} else {
return true;
}
@@ -630,26 +630,26 @@ public class PointerTracker {
private void showKeyPreview(int keyIndex) {
if (isKeyPreviewNotRequired(keyIndex))
return;
- mProxy.showKeyPreview(keyIndex, this);
+ mDrawingProxy.showKeyPreview(keyIndex, this);
}
private void dismissKeyPreview() {
- mProxy.dismissKeyPreview(this);
+ mDrawingProxy.dismissKeyPreview(this);
}
private void startLongPressTimer(int keyIndex) {
Key key = getKey(keyIndex);
if (key.mCode == Keyboard.CODE_SHIFT) {
- mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
+ mKeyTimerHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
} else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
// 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.
return;
} else if (mKeyboardSwitcher.isInMomentarySwitchState()) {
// 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 {
- mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
+ mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
index 1885ea14e..cc89579bb 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
@@ -23,7 +23,7 @@ import android.graphics.Rect;
import com.android.inputmethod.keyboard.Key;
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.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) {
final Context context = view.getContext();
mRes = context.getResources();
@@ -223,7 +223,7 @@ public class MiniKeyboardBuilder {
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) {
Paint paint = null;
Rect bounds = null;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java
index ddadb1338..6e2b60c30 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java
@@ -23,7 +23,7 @@ import com.android.inputmethod.keyboard.PointerTracker;
* This class keeps track of a key index and a position where {@link PointerTracker} is.
*/
public class PointerTrackerKeyState {
- private final KeyDetector mKeyDetector;
+ private KeyDetector mKeyDetector;
// The position and time at which first down event occurred.
private long mDownTime;
@@ -43,6 +43,10 @@ public class PointerTrackerKeyState {
mKeyDetector = keyDetecor;
}
+ public void setKeyDetector(KeyDetector keyDetector) {
+ mKeyDetector = keyDetector;
+ }
+
public int getKeyIndex() {
return mKeyIndex;
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4a813541d..a9f34c6c7 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -66,7 +66,7 @@ import com.android.inputmethod.deprecated.recorrection.Recorrection;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
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.LatinKeyboardView;
@@ -655,7 +655,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override
public void onWindowHidden() {
super.onWindowHidden();
- LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+ KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.closing();
}
@@ -668,7 +668,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
- LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+ KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.closing();
if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
@@ -677,7 +677,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override
public void onFinishInputView(boolean finishingInput) {
super.onFinishInputView(finishingInput);
- LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+ KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.cancelAllMessages();
// Remove pending messages related to update suggestions
mHandler.cancelUpdateSuggestions();
@@ -866,7 +866,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
- final LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+ final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView == null || mCandidateViewContainer == null)
return;
final int containerHeight = mCandidateViewContainer.getHeight();
diff --git a/java/src/com/android/inputmethod/latin/SettingsActivity.java b/java/src/com/android/inputmethod/latin/SettingsActivity.java
index 434d5d5ea..2da171a63 100644
--- a/java/src/com/android/inputmethod/latin/SettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/SettingsActivity.java
@@ -1,6 +1,20 @@
-package com.android.inputmethod.latin;
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
-import android.os.Bundle;
+package com.android.inputmethod.latin;
public class SettingsActivity extends Settings {
-} \ No newline at end of file
+}