aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/MainKeyboardView.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java75
1 files changed, 25 insertions, 50 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 6c6fc6157..7f335027f 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -57,6 +57,7 @@ import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview;
import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
+import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.CollectionUtils;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.CoordinateUtils;
@@ -201,7 +202,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private static final int MSG_TYPING_STATE_EXPIRED = 0;
private static final int MSG_REPEAT_KEY = 1;
private static final int MSG_LONGPRESS_KEY = 2;
- private static final int MSG_DOUBLE_TAP = 3;
+ private static final int MSG_DOUBLE_TAP_SHIFT_KEY = 3;
private static final int MSG_UPDATE_BATCH_INPUT = 4;
private final int mKeyRepeatStartTimeout;
@@ -240,16 +241,14 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
case MSG_REPEAT_KEY:
final Key currentKey = tracker.getKey();
if (currentKey != null && currentKey.mCode == msg.arg1) {
- tracker.onRegisterKey(currentKey);
+ tracker.onRepeatKey(currentKey);
+ AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
+ currentKey.mCode, keyboardView);
startKeyRepeatTimer(tracker, mKeyRepeatInterval);
}
break;
case MSG_LONGPRESS_KEY:
- if (tracker != null) {
- keyboardView.onLongPress(tracker);
- } else {
- KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
- }
+ keyboardView.onLongPress(tracker);
break;
case MSG_UPDATE_BATCH_INPUT:
tracker.updateBatchInputByTimer(SystemClock.uptimeMillis());
@@ -281,23 +280,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
@Override
- public void startLongPressTimer(final int code) {
- cancelLongPressTimer();
- final int delay;
- switch (code) {
- case Constants.CODE_SHIFT:
- delay = mLongPressShiftLockTimeout;
- break;
- default:
- delay = 0;
- break;
- }
- if (delay > 0) {
- sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, code, 0), delay);
- }
- }
-
- @Override
public void startLongPressTimer(final PointerTracker tracker) {
cancelLongPressTimer();
if (tracker == null) {
@@ -312,9 +294,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
default:
final int longpressTimeout =
Settings.getInstance().getCurrent().mKeyLongpressTimeout;
- if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
- // We use longer timeout for sliding finger input started from the symbols
- // mode key.
+ if (tracker.isInSlidingKeyInputFromModifier()) {
+ // We use longer timeout for sliding finger input started from the modifier key.
delay = longpressTimeout * 3;
} else {
delay = longpressTimeout;
@@ -390,19 +371,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
@Override
- public void startDoubleTapTimer() {
- sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP),
+ public void startDoubleTapShiftKeyTimer() {
+ sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP_SHIFT_KEY),
ViewConfiguration.getDoubleTapTimeout());
}
@Override
- public void cancelDoubleTapTimer() {
- removeMessages(MSG_DOUBLE_TAP);
+ public void cancelDoubleTapShiftKeyTimer() {
+ removeMessages(MSG_DOUBLE_TAP_SHIFT_KEY);
}
@Override
- public boolean isInDoubleTapTimeout() {
- return hasMessages(MSG_DOUBLE_TAP);
+ public boolean isInDoubleTapShiftKeyTimeout() {
+ return hasMessages(MSG_DOUBLE_TAP_SHIFT_KEY);
}
@Override
@@ -827,10 +808,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final KeyDrawParams drawParams = mKeyDrawParams;
previewText.setTextColor(drawParams.mPreviewTextColor);
final Drawable background = previewText.getBackground();
- if (background != null) {
- background.setState(KEY_PREVIEW_BACKGROUND_DEFAULT_STATE);
- background.setAlpha(PREVIEW_ALPHA);
- }
final String label = key.getPreviewLabel();
// What we show as preview should match what we show on a key top in onDraw().
if (label != null) {
@@ -884,6 +861,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (background != null) {
final int hasMoreKeys = (key.mMoreKeys != null) ? STATE_HAS_MOREKEYS : STATE_NORMAL;
background.setState(KEY_PREVIEW_BACKGROUND_STATE_TABLE[statePosition][hasMoreKeys]);
+ background.setAlpha(PREVIEW_ALPHA);
}
ViewLayoutUtils.placeViewAt(
previewText, previewX, previewY, previewWidth, previewHeight);
@@ -987,38 +965,36 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
/**
* Called when a key is long pressed.
* @param tracker the pointer tracker which pressed the parent key
- * @return true if the long press is handled, false otherwise. Subclasses should call the
- * method on the base class if the subclass doesn't wish to handle the call.
*/
- private boolean onLongPress(final PointerTracker tracker) {
+ private void onLongPress(final PointerTracker tracker) {
if (isShowingMoreKeysPanel()) {
- return false;
+ return;
}
final Key key = tracker.getKey();
if (key == null) {
- return false;
+ return;
}
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.mainKeyboardView_onLongPress();
}
final int code = key.mCode;
- if (key.hasEmbeddedMoreKey()) {
+ if (key.hasNoPanelAutoMoreKey()) {
final int embeddedCode = key.mMoreKeys[0].mCode;
tracker.onLongPressed();
invokeCodeInput(embeddedCode);
invokeReleaseKey(code);
- KeyboardSwitcher.getInstance().hapticAndAudioFeedback(code);
- return true;
+ AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, this);
+ return;
}
if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) {
// Long pressing the space key invokes IME switcher dialog.
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
tracker.onLongPressed();
invokeReleaseKey(code);
- return true;
+ return;
}
}
- return openMoreKeysPanel(key, tracker);
+ openMoreKeysPanel(key, tracker);
}
private boolean invokeCustomRequest(final int requestCode) {
@@ -1034,10 +1010,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mKeyboardActionListener.onReleaseKey(code, false);
}
- private boolean openMoreKeysPanel(final Key key, final PointerTracker tracker) {
+ private void openMoreKeysPanel(final Key key, final PointerTracker tracker) {
final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext());
if (moreKeysPanel == null) {
- return false;
+ return;
}
final int[] lastCoords = CoordinateUtils.newInstance();
@@ -1059,7 +1035,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int translatedX = moreKeysPanel.translateX(CoordinateUtils.x(lastCoords));
final int translatedY = moreKeysPanel.translateY(CoordinateUtils.y(lastCoords));
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
- return true;
}
public boolean isInSlidingKeyInput() {