diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 0fb90143d..76cb8ff29 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -525,6 +525,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return mAutoModeSwitchState == AUTO_MODE_SWITCH_STATE_MOMENTARY; } + public boolean isVibrateAndSoundFeedbackRequired() { + return mInputView == null || !mInputView.isInSlidingKeyInput(); + } + private int getPointerCount() { return mInputView == null ? 0 : mInputView.getPointerCount(); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 47d4d1ade..11b7ec241 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -1308,6 +1308,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { return pointers.get(id); } + public boolean isInSlidingKeyInput() { + if (mMiniKeyboard != null) { + return mMiniKeyboard.isInSlidingKeyInput(); + } else { + return mPointerQueue.isInSlidingKeyInput(); + } + } + public int getPointerCount() { return mOldPointerCount; } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 15eab8fed..e4312a8ca 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -69,6 +69,9 @@ public class PointerTracker { // true if this pointer is repeatable key private boolean mIsRepeatableKey; + // true if this pointer is in sliding key input + private boolean mIsInSlidingKeyInput; + // true if sliding key is allowed. private boolean mIsAllowedSlidingKeyInput; @@ -168,6 +171,10 @@ public class PointerTracker { mKeyState.onSetKeyboard(); } + public boolean isInSlidingKeyInput() { + return mIsInSlidingKeyInput; + } + private boolean isValidKeyIndex(int keyIndex) { return keyIndex >= 0 && keyIndex < mKeys.length; } @@ -258,6 +265,7 @@ public class PointerTracker { || mKeyDetector instanceof MiniKeyboardKeyDetector; mKeyAlreadyProcessed = false; mIsRepeatableKey = false; + mIsInSlidingKeyInput = false; checkMultiTap(eventTime, keyIndex); if (isValidKeyIndex(keyIndex)) { callListenerOnPress(mKeys[keyIndex].mCodes[0]); @@ -295,6 +303,7 @@ public class PointerTracker { // The pointer has been slid in to the new key from the previous key, we must call // onRelease() first to notify that the previous key has been released, then call // onPress() to notify that the new key is being pressed. + mIsInSlidingKeyInput = true; callListenerOnRelease(oldKey.mCodes[0]); mHandler.cancelLongPressTimers(); if (mIsAllowedSlidingKeyInput) { @@ -312,6 +321,7 @@ public class PointerTracker { if (oldKey != null && !isMinorMoveBounce(x, y, keyIndex)) { // The pointer has been slid out from the previous key, we must call onRelease() to // notify that the previous key has been released. + mIsInSlidingKeyInput = true; callListenerOnRelease(oldKey.mCodes[0]); mHandler.cancelLongPressTimers(); if (mIsAllowedSlidingKeyInput) { @@ -332,9 +342,10 @@ public class PointerTracker { int y = pointY; if (DEBUG_EVENT) printTouchEvent("onUpEvent :", x, y, eventTime); - showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY); mHandler.cancelKeyTimers(); mHandler.cancelPopupPreview(); + showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY); + mIsInSlidingKeyInput = false; if (mKeyAlreadyProcessed) return; final PointerTrackerKeyState keyState = mKeyState; @@ -359,6 +370,7 @@ public class PointerTracker { mHandler.cancelKeyTimers(); mHandler.cancelPopupPreview(); showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY); + mIsInSlidingKeyInput = false; int keyIndex = mKeyState.getKeyIndex(); if (isValidKeyIndex(keyIndex)) mProxy.invalidateKey(mKeys[keyIndex]); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java index e559b4cde..236c9d550 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java @@ -65,6 +65,14 @@ public class PointerTrackerQueue { mQueue.remove(tracker); } + public boolean isInSlidingKeyInput() { + for (final PointerTracker tracker : mQueue) { + if (tracker.isInSlidingKeyInput()) + return true; + } + return false; + } + @Override public String toString() { StringBuilder sb = new StringBuilder("["); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 3a3a000de..45785ab36 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1887,8 +1887,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onPress(int primaryCode) { - vibrate(); - playKeyClick(primaryCode); + if (mKeyboardSwitcher.isVibrateAndSoundFeedbackRequired()) { + vibrate(); + playKeyClick(primaryCode); + } KeyboardSwitcher switcher = mKeyboardSwitcher; final boolean distinctMultiTouch = switcher.hasDistinctMultitouch(); if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {