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: Ia5af5e877a3c4bb29211ef4040c728ac09a9fe85main
parent
e13a301328
commit
5e02930a7f
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
**
|
|
||||||
** Copyright 2010, 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.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
|
||||||
android:id="@android:id/keyboardView"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@color/latinkeyboard_extension_background"
|
|
||||||
android:verticalCorrection="0dip"
|
|
||||||
|
|
||||||
latin:keyBackground="@drawable/btn_keyboard_key_fulltrans"
|
|
||||||
/>
|
|
|
@ -25,4 +25,8 @@
|
||||||
<integer name="config_preview_fadeout_anim_time">90</integer>
|
<integer name="config_preview_fadeout_anim_time">90</integer>
|
||||||
<integer name="config_mini_keyboard_fadein_anim_time">0</integer>
|
<integer name="config_mini_keyboard_fadein_anim_time">0</integer>
|
||||||
<integer name="config_mini_keyboard_fadeout_anim_time">100</integer>
|
<integer name="config_mini_keyboard_fadeout_anim_time">100</integer>
|
||||||
|
<integer name="config_delay_before_key_repeat_start">400</integer>
|
||||||
|
<integer name="config_key_repeat_interval">50</integer>
|
||||||
|
<integer name="config_long_press_key_timeout">400</integer>
|
||||||
|
<integer name="config_multi_tap_key_timeout">800</integer>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timing constants
|
// Timing constants
|
||||||
private static final int REPEAT_INTERVAL = PointerTracker.REPEAT_INTERVAL;
|
private final int mKeyRepeatInterval;
|
||||||
|
|
||||||
// Miscellaneous constants
|
// Miscellaneous constants
|
||||||
/* package */ static final int NOT_A_KEY = -1;
|
/* package */ static final int NOT_A_KEY = -1;
|
||||||
|
@ -261,7 +261,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
case MSG_REPEAT_KEY: {
|
case MSG_REPEAT_KEY: {
|
||||||
final PointerTracker tracker = (PointerTracker)msg.obj;
|
final PointerTracker tracker = (PointerTracker)msg.obj;
|
||||||
tracker.repeatKey(msg.arg1);
|
tracker.repeatKey(msg.arg1);
|
||||||
startKeyRepeatTimer(REPEAT_INTERVAL, msg.arg1, tracker);
|
startKeyRepeatTimer(mKeyRepeatInterval, msg.arg1, tracker);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_LONGPRESS_KEY: {
|
case MSG_LONGPRESS_KEY: {
|
||||||
|
@ -542,6 +542,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
|
||||||
|
|
||||||
mHasDistinctMultitouch = context.getPackageManager()
|
mHasDistinctMultitouch = context.getPackageManager()
|
||||||
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
|
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
|
||||||
|
mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnKeyboardActionListener(OnKeyboardActionListener listener) {
|
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.
|
// 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, mHandler, mKeyDetector, this, mHasDistinctMultitouch);
|
new PointerTracker(i, mHandler, mKeyDetector, this, getResources());
|
||||||
if (keys != null)
|
if (keys != null)
|
||||||
tracker.setKeyboard(keys, mKeyHysteresisDistance);
|
tracker.setKeyboard(keys, mKeyHysteresisDistance);
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
|
|
|
@ -19,11 +19,11 @@ package com.android.inputmethod.latin;
|
||||||
import com.android.inputmethod.latin.LatinKeyboardBaseView.OnKeyboardActionListener;
|
import com.android.inputmethod.latin.LatinKeyboardBaseView.OnKeyboardActionListener;
|
||||||
import com.android.inputmethod.latin.LatinKeyboardBaseView.UIHandler;
|
import com.android.inputmethod.latin.LatinKeyboardBaseView.UIHandler;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.inputmethodservice.Keyboard;
|
import android.inputmethodservice.Keyboard;
|
||||||
import android.inputmethodservice.Keyboard.Key;
|
import android.inputmethodservice.Keyboard.Key;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
|
||||||
|
|
||||||
public class PointerTracker {
|
public class PointerTracker {
|
||||||
private static final String TAG = "PointerTracker";
|
private static final String TAG = "PointerTracker";
|
||||||
|
@ -33,15 +33,15 @@ public class PointerTracker {
|
||||||
public interface UIProxy {
|
public interface UIProxy {
|
||||||
public void invalidateKey(Key key);
|
public void invalidateKey(Key key);
|
||||||
public void showPreview(int keyIndex, PointerTracker tracker);
|
public void showPreview(int keyIndex, PointerTracker tracker);
|
||||||
|
public boolean hasDistinctMultitouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int mPointerId;
|
public final int mPointerId;
|
||||||
|
|
||||||
// Timing constants
|
// Timing constants
|
||||||
private static final int REPEAT_START_DELAY = 400;
|
private final int mDelayBeforeKeyRepeatStart;
|
||||||
/* package */ static final int REPEAT_INTERVAL = 50; // ~20 keys per second
|
private final int mLongPressKeyTimeout;
|
||||||
private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
|
private final int mMultiTapKeyTimeout;
|
||||||
private static final int MULTITAP_INTERVAL = 800; // milliseconds
|
|
||||||
|
|
||||||
// Miscellaneous constants
|
// Miscellaneous constants
|
||||||
private static final int NOT_A_KEY = LatinKeyboardBaseView.NOT_A_KEY;
|
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,
|
public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector, UIProxy proxy,
|
||||||
boolean hasDistinctMultitouch) {
|
Resources res) {
|
||||||
if (proxy == null || handler == null || keyDetector == null)
|
if (proxy == null || handler == null || keyDetector == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
mPointerId = id;
|
mPointerId = id;
|
||||||
|
@ -172,7 +172,10 @@ public class PointerTracker {
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mKeyDetector = keyDetector;
|
mKeyDetector = keyDetector;
|
||||||
mKeyState = new KeyState(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();
|
resetMultiTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,10 +281,10 @@ public class PointerTracker {
|
||||||
if (isValidKeyIndex(keyIndex)) {
|
if (isValidKeyIndex(keyIndex)) {
|
||||||
if (mKeys[keyIndex].repeatable) {
|
if (mKeys[keyIndex].repeatable) {
|
||||||
repeatKey(keyIndex);
|
repeatKey(keyIndex);
|
||||||
mHandler.startKeyRepeatTimer(REPEAT_START_DELAY, keyIndex, this);
|
mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
|
||||||
mIsRepeatableKey = true;
|
mIsRepeatableKey = true;
|
||||||
}
|
}
|
||||||
mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
|
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
||||||
}
|
}
|
||||||
showKeyPreviewAndUpdateKey(keyIndex);
|
showKeyPreviewAndUpdateKey(keyIndex);
|
||||||
}
|
}
|
||||||
|
@ -296,11 +299,11 @@ public class PointerTracker {
|
||||||
if (isValidKeyIndex(keyIndex)) {
|
if (isValidKeyIndex(keyIndex)) {
|
||||||
if (keyState.getKeyIndex() == NOT_A_KEY) {
|
if (keyState.getKeyIndex() == NOT_A_KEY) {
|
||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
|
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
||||||
} else if (!isMinorMoveBounce(x, y, keyIndex)) {
|
} else if (!isMinorMoveBounce(x, y, keyIndex)) {
|
||||||
resetMultiTap();
|
resetMultiTap();
|
||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
mHandler.startLongPressTimer(LONGPRESS_TIMEOUT, keyIndex, this);
|
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (keyState.getKeyIndex() != NOT_A_KEY) {
|
if (keyState.getKeyIndex() != NOT_A_KEY) {
|
||||||
|
@ -489,7 +492,7 @@ public class PointerTracker {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final boolean isMultiTap =
|
final boolean isMultiTap =
|
||||||
(eventTime < mLastTapTime + MULTITAP_INTERVAL && keyIndex == mLastSentIndex);
|
(eventTime < mLastTapTime + mMultiTapKeyTimeout && keyIndex == mLastSentIndex);
|
||||||
if (key.codes.length > 1) {
|
if (key.codes.length > 1) {
|
||||||
mInMultiTap = true;
|
mInMultiTap = true;
|
||||||
if (isMultiTap) {
|
if (isMultiTap) {
|
||||||
|
|
Loading…
Reference in New Issue