aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-10-08 12:51:15 +0900
committerTadashi G. Takaoka <takaoka@google.com>2010-10-08 19:05:16 +0900
commit5e02930a7f40b704f357f127d3d38fbdc193ffa1 (patch)
tree756a83791a33a9ebaabc7d72d461938745673a47 /java/src
parente13a301328b7104624db5b37a9b043fd7a6825b7 (diff)
downloadlatinime-5e02930a7f40b704f357f127d3d38fbdc193ffa1.tar.gz
latinime-5e02930a7f40b704f357f127d3d38fbdc193ffa1.tar.xz
latinime-5e02930a7f40b704f357f127d3d38fbdc193ffa1.zip
Reduce delay before mini popup keyboard is shown
Before this change, the delay was 500 ms that came from ViewConfiguration.getLongPressTimeout(). This change reduces the delay to 400 ms. Bug: 3074984 Change-Id: Ia5af5e877a3c4bb29211ef4040c728ac09a9fe85
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java7
-rw-r--r--java/src/com/android/inputmethod/latin/PointerTracker.java27
2 files changed, 19 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 75ef691c8..bcd1bb056 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -154,7 +154,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
}
// Timing constants
- private static final int REPEAT_INTERVAL = PointerTracker.REPEAT_INTERVAL;
+ private final int mKeyRepeatInterval;
// Miscellaneous constants
/* package */ static final int NOT_A_KEY = -1;
@@ -261,7 +261,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
case MSG_REPEAT_KEY: {
final PointerTracker tracker = (PointerTracker)msg.obj;
tracker.repeatKey(msg.arg1);
- startKeyRepeatTimer(REPEAT_INTERVAL, msg.arg1, tracker);
+ startKeyRepeatTimer(mKeyRepeatInterval, msg.arg1, tracker);
break;
}
case MSG_LONGPRESS_KEY: {
@@ -542,6 +542,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
mHasDistinctMultitouch = context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
+ mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
}
public void setOnKeyboardActionListener(OnKeyboardActionListener listener) {
@@ -1218,7 +1219,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
// 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, mHandler, mKeyDetector, this, mHasDistinctMultitouch);
+ new PointerTracker(i, mHandler, mKeyDetector, this, getResources());
if (keys != null)
tracker.setKeyboard(keys, mKeyHysteresisDistance);
if (listener != null)
diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java
index b416a984c..448e27910 100644
--- a/java/src/com/android/inputmethod/latin/PointerTracker.java
+++ b/java/src/com/android/inputmethod/latin/PointerTracker.java
@@ -19,11 +19,11 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.latin.LatinKeyboardBaseView.OnKeyboardActionListener;
import com.android.inputmethod.latin.LatinKeyboardBaseView.UIHandler;
+import android.content.res.Resources;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.Keyboard.Key;
import android.util.Log;
import android.view.MotionEvent;
-import android.view.ViewConfiguration;
public class PointerTracker {
private static final String TAG = "PointerTracker";
@@ -33,15 +33,15 @@ public class PointerTracker {
public interface UIProxy {
public void invalidateKey(Key key);
public void showPreview(int keyIndex, PointerTracker tracker);
+ public boolean hasDistinctMultitouch();
}
public final int mPointerId;
// Timing constants
- private static final int REPEAT_START_DELAY = 400;
- /* package */ static final int REPEAT_INTERVAL = 50; // ~20 keys per second
- private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
- private static final int MULTITAP_INTERVAL = 800; // milliseconds
+ private final int mDelayBeforeKeyRepeatStart;
+ private final int mLongPressKeyTimeout;
+ private final int mMultiTapKeyTimeout;
// Miscellaneous constants
private static final int NOT_A_KEY = LatinKeyboardBaseView.NOT_A_KEY;
@@ -164,7 +164,7 @@ public class PointerTracker {
}
public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector, UIProxy proxy,
- boolean hasDistinctMultitouch) {
+ Resources res) {
if (proxy == null || handler == null || keyDetector == null)
throw new NullPointerException();
mPointerId = id;
@@ -172,7 +172,10 @@ public class PointerTracker {
mHandler = handler;
mKeyDetector = keyDetector;
mKeyState = new KeyState(keyDetector);
- mHasDistinctMultitouch = hasDistinctMultitouch;
+ mHasDistinctMultitouch = proxy.hasDistinctMultitouch();
+ mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
+ mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
+ mMultiTapKeyTimeout = res.getInteger(R.integer.config_multi_tap_key_timeout);
resetMultiTap();
}
@@ -278,10 +281,10 @@ public class PointerTracker {
if (isValidKeyIndex(keyIndex)) {
if (mKeys[keyIndex].repeatable) {
repeatKey(keyIndex);
- mHandler.startKeyRepeatTimer(REPEAT_START_DELAY, keyIndex, this);
+ mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
mIsRepeatableKey = true;
}
- mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
+ mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
}
showKeyPreviewAndUpdateKey(keyIndex);
}
@@ -296,11 +299,11 @@ public class PointerTracker {
if (isValidKeyIndex(keyIndex)) {
if (keyState.getKeyIndex() == NOT_A_KEY) {
keyState.onMoveToNewKey(keyIndex, x, y);
- mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
+ mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
} else if (!isMinorMoveBounce(x, y, keyIndex)) {
resetMultiTap();
keyState.onMoveToNewKey(keyIndex, x, y);
- mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
+ mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
}
} else {
if (keyState.getKeyIndex() != NOT_A_KEY) {
@@ -489,7 +492,7 @@ public class PointerTracker {
return;
final boolean isMultiTap =
- (eventTime < mLastTapTime + MULTITAP_INTERVAL && keyIndex == mLastSentIndex);
+ (eventTime < mLastTapTime + mMultiTapKeyTimeout && keyIndex == mLastSentIndex);
if (key.codes.length > 1) {
mInMultiTap = true;
if (isMultiTap) {