Suppress haptic feedback while sliding key input
Bug: 3298222 Change-Id: I9507a98cc833fc6403cf9abf23457748a2bf89demain
parent
5ef421b58a
commit
cb2469ae17
|
@ -525,6 +525,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return mAutoModeSwitchState == AUTO_MODE_SWITCH_STATE_MOMENTARY;
|
return mAutoModeSwitchState == AUTO_MODE_SWITCH_STATE_MOMENTARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVibrateAndSoundFeedbackRequired() {
|
||||||
|
return mInputView == null || !mInputView.isInSlidingKeyInput();
|
||||||
|
}
|
||||||
|
|
||||||
private int getPointerCount() {
|
private int getPointerCount() {
|
||||||
return mInputView == null ? 0 : mInputView.getPointerCount();
|
return mInputView == null ? 0 : mInputView.getPointerCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1308,6 +1308,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
return pointers.get(id);
|
return pointers.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInSlidingKeyInput() {
|
||||||
|
if (mMiniKeyboard != null) {
|
||||||
|
return mMiniKeyboard.isInSlidingKeyInput();
|
||||||
|
} else {
|
||||||
|
return mPointerQueue.isInSlidingKeyInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getPointerCount() {
|
public int getPointerCount() {
|
||||||
return mOldPointerCount;
|
return mOldPointerCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class PointerTracker {
|
||||||
// true if this pointer is repeatable key
|
// true if this pointer is repeatable key
|
||||||
private boolean mIsRepeatableKey;
|
private boolean mIsRepeatableKey;
|
||||||
|
|
||||||
|
// true if this pointer is in sliding key input
|
||||||
|
private boolean mIsInSlidingKeyInput;
|
||||||
|
|
||||||
// true if sliding key is allowed.
|
// true if sliding key is allowed.
|
||||||
private boolean mIsAllowedSlidingKeyInput;
|
private boolean mIsAllowedSlidingKeyInput;
|
||||||
|
|
||||||
|
@ -168,6 +171,10 @@ public class PointerTracker {
|
||||||
mKeyState.onSetKeyboard();
|
mKeyState.onSetKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInSlidingKeyInput() {
|
||||||
|
return mIsInSlidingKeyInput;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isValidKeyIndex(int keyIndex) {
|
private boolean isValidKeyIndex(int keyIndex) {
|
||||||
return keyIndex >= 0 && keyIndex < mKeys.length;
|
return keyIndex >= 0 && keyIndex < mKeys.length;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +265,7 @@ public class PointerTracker {
|
||||||
|| mKeyDetector instanceof MiniKeyboardKeyDetector;
|
|| mKeyDetector instanceof MiniKeyboardKeyDetector;
|
||||||
mKeyAlreadyProcessed = false;
|
mKeyAlreadyProcessed = false;
|
||||||
mIsRepeatableKey = false;
|
mIsRepeatableKey = false;
|
||||||
|
mIsInSlidingKeyInput = false;
|
||||||
checkMultiTap(eventTime, keyIndex);
|
checkMultiTap(eventTime, keyIndex);
|
||||||
if (isValidKeyIndex(keyIndex)) {
|
if (isValidKeyIndex(keyIndex)) {
|
||||||
callListenerOnPress(mKeys[keyIndex].mCodes[0]);
|
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
|
// 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
|
// onRelease() first to notify that the previous key has been released, then call
|
||||||
// onPress() to notify that the new key is being pressed.
|
// onPress() to notify that the new key is being pressed.
|
||||||
|
mIsInSlidingKeyInput = true;
|
||||||
callListenerOnRelease(oldKey.mCodes[0]);
|
callListenerOnRelease(oldKey.mCodes[0]);
|
||||||
mHandler.cancelLongPressTimers();
|
mHandler.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
|
@ -312,6 +321,7 @@ public class PointerTracker {
|
||||||
if (oldKey != null && !isMinorMoveBounce(x, y, keyIndex)) {
|
if (oldKey != null && !isMinorMoveBounce(x, y, keyIndex)) {
|
||||||
// The pointer has been slid out from the previous key, we must call onRelease() to
|
// The pointer has been slid out from the previous key, we must call onRelease() to
|
||||||
// notify that the previous key has been released.
|
// notify that the previous key has been released.
|
||||||
|
mIsInSlidingKeyInput = true;
|
||||||
callListenerOnRelease(oldKey.mCodes[0]);
|
callListenerOnRelease(oldKey.mCodes[0]);
|
||||||
mHandler.cancelLongPressTimers();
|
mHandler.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
|
@ -332,9 +342,10 @@ public class PointerTracker {
|
||||||
int y = pointY;
|
int y = pointY;
|
||||||
if (DEBUG_EVENT)
|
if (DEBUG_EVENT)
|
||||||
printTouchEvent("onUpEvent :", x, y, eventTime);
|
printTouchEvent("onUpEvent :", x, y, eventTime);
|
||||||
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
|
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
mHandler.cancelPopupPreview();
|
mHandler.cancelPopupPreview();
|
||||||
|
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
|
||||||
|
mIsInSlidingKeyInput = false;
|
||||||
if (mKeyAlreadyProcessed)
|
if (mKeyAlreadyProcessed)
|
||||||
return;
|
return;
|
||||||
final PointerTrackerKeyState keyState = mKeyState;
|
final PointerTrackerKeyState keyState = mKeyState;
|
||||||
|
@ -359,6 +370,7 @@ public class PointerTracker {
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
mHandler.cancelPopupPreview();
|
mHandler.cancelPopupPreview();
|
||||||
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
|
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
|
||||||
|
mIsInSlidingKeyInput = false;
|
||||||
int keyIndex = mKeyState.getKeyIndex();
|
int keyIndex = mKeyState.getKeyIndex();
|
||||||
if (isValidKeyIndex(keyIndex))
|
if (isValidKeyIndex(keyIndex))
|
||||||
mProxy.invalidateKey(mKeys[keyIndex]);
|
mProxy.invalidateKey(mKeys[keyIndex]);
|
||||||
|
|
|
@ -65,6 +65,14 @@ public class PointerTrackerQueue {
|
||||||
mQueue.remove(tracker);
|
mQueue.remove(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInSlidingKeyInput() {
|
||||||
|
for (final PointerTracker tracker : mQueue) {
|
||||||
|
if (tracker.isInSlidingKeyInput())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder("[");
|
StringBuilder sb = new StringBuilder("[");
|
||||||
|
|
|
@ -1887,8 +1887,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPress(int primaryCode) {
|
public void onPress(int primaryCode) {
|
||||||
|
if (mKeyboardSwitcher.isVibrateAndSoundFeedbackRequired()) {
|
||||||
vibrate();
|
vibrate();
|
||||||
playKeyClick(primaryCode);
|
playKeyClick(primaryCode);
|
||||||
|
}
|
||||||
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
|
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
|
||||||
if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {
|
if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {
|
||||||
|
|
Loading…
Reference in New Issue