aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/PointerTracker.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/PointerTracker.java')
-rw-r--r--java/src/com/android/inputmethod/latin/PointerTracker.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java
index 448e27910..a1cc8090e 100644
--- a/java/src/com/android/inputmethod/latin/PointerTracker.java
+++ b/java/src/com/android/inputmethod/latin/PointerTracker.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.latin;
+import com.android.inputmethod.latin.BaseKeyboard.Key;
import com.android.inputmethod.latin.LatinKeyboardBaseView.OnKeyboardActionListener;
import com.android.inputmethod.latin.LatinKeyboardBaseView.UIHandler;
@@ -45,7 +46,7 @@ public class PointerTracker {
// Miscellaneous constants
private static final int NOT_A_KEY = LatinKeyboardBaseView.NOT_A_KEY;
- private static final int[] KEY_DELETE = { Keyboard.KEYCODE_DELETE };
+ private static final int[] KEY_DELETE = { BaseKeyboard.KEYCODE_DELETE };
private final UIProxy mProxy;
private final UIHandler mHandler;
@@ -53,6 +54,7 @@ public class PointerTracker {
private OnKeyboardActionListener mListener;
private final boolean mHasDistinctMultitouch;
+ private BaseKeyboard mKeyboard;
private Key[] mKeys;
private int mKeyHysteresisDistanceSquared = -1;
@@ -183,9 +185,10 @@ public class PointerTracker {
mListener = listener;
}
- public void setKeyboard(Key[] keys, float keyHysteresisDistance) {
- if (keys == null || keyHysteresisDistance < 0)
+ public void setKeyboard(BaseKeyboard keyboard, Key[] keys, float keyHysteresisDistance) {
+ if (keyboard == null || keys == null || keyHysteresisDistance < 0)
throw new IllegalArgumentException();
+ mKeyboard = keyboard;
mKeys = keys;
mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance);
// Update current key index because keyboard layout has been changed.
@@ -205,8 +208,8 @@ public class PointerTracker {
if (key == null)
return false;
int primaryCode = key.codes[0];
- return primaryCode == Keyboard.KEYCODE_SHIFT
- || primaryCode == Keyboard.KEYCODE_MODE_CHANGE;
+ return primaryCode == BaseKeyboard.KEYCODE_SHIFT
+ || primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE;
}
public boolean isModifier() {
@@ -296,7 +299,8 @@ public class PointerTracker {
return;
KeyState keyState = mKeyState;
int keyIndex = keyState.onMoveKey(x, y);
- if (isValidKeyIndex(keyIndex)) {
+ Key key = getKey(keyIndex);
+ if (key != null) {
if (keyState.getKeyIndex() == NOT_A_KEY) {
keyState.onMoveToNewKey(keyIndex, x, y);
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
@@ -419,6 +423,20 @@ public class PointerTracker {
}
}
+ private void startLongPressTimer(int keyIndex) {
+ Key key = getKey(keyIndex);
+ // If keyboard is in temporary upper case state and the key has temporary shift label,
+ // long press should not be started.
+ if (isTemporaryUpperCase() && key.temporaryShiftLabel != null)
+ return;
+ mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
+ }
+
+ private boolean isTemporaryUpperCase() {
+ return mKeyboard instanceof LatinKeyboard
+ && ((LatinKeyboard)mKeyboard).isTemporaryUpperCase();
+ }
+
private void detectAndSendKey(int index, int x, int y, long eventTime) {
final OnKeyboardActionListener listener = mListener;
final Key key = getKey(index);
@@ -440,12 +458,20 @@ public class PointerTracker {
// Multi-tap
if (mInMultiTap) {
if (mTapCount != -1) {
- mListener.onKey(Keyboard.KEYCODE_DELETE, KEY_DELETE, x, y);
+ mListener.onKey(BaseKeyboard.KEYCODE_DELETE, KEY_DELETE, x, y);
} else {
mTapCount = 0;
}
code = key.codes[mTapCount];
}
+
+ // If keyboard is in temporary upper case state and key has temporary shift label,
+ // alternate character code should be sent.
+ if (isTemporaryUpperCase() && key.temporaryShiftLabel != null) {
+ code = key.temporaryShiftLabel.charAt(0);
+ codes[0] = code;
+ }
+
/*
* Swap the first and second values in the codes array if the primary code is not
* the first value but the second value in the array. This happens when key