Don't play key press sound if the key is disabled
Change-Id: I1c6d1b16a7420bc7e5f97f50da549e6a89498f18main
parent
810a9ff9d4
commit
690b1360bf
|
@ -129,32 +129,42 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if keyboard has been changed by this callback.
|
// Returns true if keyboard has been changed by this callback.
|
||||||
private boolean callListenerOnPressAndCheckKeyboardLayoutChange(int primaryCode) {
|
private boolean callListenerOnPressAndCheckKeyboardLayoutChange(Key key) {
|
||||||
if (DEBUG_LISTENER)
|
if (DEBUG_LISTENER)
|
||||||
Log.d(TAG, "onPress : " + keyCodePrintable(primaryCode));
|
Log.d(TAG, "onPress : " + keyCodePrintable(key.mCode));
|
||||||
mListener.onPress(primaryCode);
|
if (key.mEnabled) {
|
||||||
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
mListener.onPress(key.mCode);
|
||||||
mKeyboardLayoutHasBeenChanged = false;
|
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
||||||
return keyboardLayoutHasBeenChanged;
|
mKeyboardLayoutHasBeenChanged = false;
|
||||||
|
return keyboardLayoutHasBeenChanged;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callListenerOnCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
||||||
|
// primaryCode is different from {@link Key#mCode}.
|
||||||
|
private void callListenerOnCodeInput(Key key, int primaryCode, int[] keyCodes, int x, int y) {
|
||||||
if (DEBUG_LISTENER)
|
if (DEBUG_LISTENER)
|
||||||
Log.d(TAG, "onCodeInput: " + keyCodePrintable(primaryCode)
|
Log.d(TAG, "onCodeInput: " + keyCodePrintable(primaryCode)
|
||||||
+ " codes="+ Arrays.toString(keyCodes) + " x=" + x + " y=" + y);
|
+ " codes="+ Arrays.toString(keyCodes) + " x=" + x + " y=" + y);
|
||||||
mListener.onCodeInput(primaryCode, keyCodes, x, y);
|
if (key.mEnabled)
|
||||||
|
mListener.onCodeInput(primaryCode, keyCodes, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callListenerOnTextInput(CharSequence text) {
|
private void callListenerOnTextInput(Key key) {
|
||||||
if (DEBUG_LISTENER)
|
if (DEBUG_LISTENER)
|
||||||
Log.d(TAG, "onTextInput: text=" + text);
|
Log.d(TAG, "onTextInput: text=" + key.mOutputText);
|
||||||
mListener.onTextInput(text);
|
if (key.mEnabled)
|
||||||
|
mListener.onTextInput(key.mOutputText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callListenerOnRelease(int primaryCode) {
|
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
||||||
|
// primaryCode is different from {@link Key#mCode}.
|
||||||
|
private void callListenerOnRelease(Key key, int primaryCode) {
|
||||||
if (DEBUG_LISTENER)
|
if (DEBUG_LISTENER)
|
||||||
Log.d(TAG, "onRelease : " + keyCodePrintable(primaryCode));
|
Log.d(TAG, "onRelease : " + keyCodePrintable(primaryCode));
|
||||||
mListener.onRelease(primaryCode);
|
if (key.mEnabled)
|
||||||
|
mListener.onRelease(primaryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callListenerOnCancelInput() {
|
private void callListenerOnCancelInput() {
|
||||||
|
@ -313,7 +323,7 @@ public class PointerTracker {
|
||||||
// This onPress call may have changed keyboard layout. Those cases are detected at
|
// This onPress call may have changed keyboard layout. Those cases are detected at
|
||||||
// {@link #setKeyboard}. In those cases, we should update keyIndex according to the new
|
// {@link #setKeyboard}. In those cases, we should update keyIndex according to the new
|
||||||
// keyboard layout.
|
// keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(mKeys[keyIndex].mCode))
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(mKeys[keyIndex]))
|
||||||
keyIndex = mKeyState.onDownKey(x, y, eventTime);
|
keyIndex = mKeyState.onDownKey(x, y, eventTime);
|
||||||
}
|
}
|
||||||
if (isValidKeyIndex(keyIndex)) {
|
if (isValidKeyIndex(keyIndex)) {
|
||||||
|
@ -346,7 +356,7 @@ public class PointerTracker {
|
||||||
// This onPress call may have changed keyboard layout. Those cases are detected at
|
// This onPress call may have changed keyboard layout. Those cases are detected at
|
||||||
// {@link #setKeyboard}. In those cases, we should update keyIndex according to the
|
// {@link #setKeyboard}. In those cases, we should update keyIndex according to the
|
||||||
// new keyboard layout.
|
// new keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(getKey(keyIndex).mCode))
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(getKey(keyIndex)))
|
||||||
keyIndex = keyState.onMoveKey(x, y);
|
keyIndex = keyState.onMoveKey(x, y);
|
||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
startLongPressTimer(keyIndex);
|
startLongPressTimer(keyIndex);
|
||||||
|
@ -355,13 +365,13 @@ public class PointerTracker {
|
||||||
// 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;
|
mIsInSlidingKeyInput = true;
|
||||||
callListenerOnRelease(oldKey.mCode);
|
callListenerOnRelease(oldKey, oldKey.mCode);
|
||||||
mHandler.cancelLongPressTimers();
|
mHandler.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
// This onPress call may have changed keyboard layout. Those cases are detected
|
// This onPress call may have changed keyboard layout. Those cases are detected
|
||||||
// at {@link #setKeyboard}. In those cases, we should update keyIndex according
|
// at {@link #setKeyboard}. In those cases, we should update keyIndex according
|
||||||
// to the new keyboard layout.
|
// to the new keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(getKey(keyIndex).mCode))
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(getKey(keyIndex)))
|
||||||
keyIndex = keyState.onMoveKey(x, y);
|
keyIndex = keyState.onMoveKey(x, y);
|
||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
startLongPressTimer(keyIndex);
|
startLongPressTimer(keyIndex);
|
||||||
|
@ -390,7 +400,7 @@ public class PointerTracker {
|
||||||
// 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;
|
mIsInSlidingKeyInput = true;
|
||||||
callListenerOnRelease(oldKey.mCode);
|
callListenerOnRelease(oldKey, oldKey.mCode);
|
||||||
mHandler.cancelLongPressTimers();
|
mHandler.cancelLongPressTimers();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
keyState.onMoveToNewKey(keyIndex, x ,y);
|
keyState.onMoveToNewKey(keyIndex, x ,y);
|
||||||
|
@ -539,8 +549,8 @@ public class PointerTracker {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key.mOutputText != null) {
|
if (key.mOutputText != null) {
|
||||||
callListenerOnTextInput(key.mOutputText);
|
callListenerOnTextInput(key);
|
||||||
callListenerOnRelease(key.mCode);
|
callListenerOnRelease(key, key.mCode);
|
||||||
} else {
|
} else {
|
||||||
int code = key.mCode;
|
int code = key.mCode;
|
||||||
final int[] codes = mKeyDetector.newCodeArray();
|
final int[] codes = mKeyDetector.newCodeArray();
|
||||||
|
@ -561,9 +571,8 @@ public class PointerTracker {
|
||||||
codes[1] = codes[0];
|
codes[1] = codes[0];
|
||||||
codes[0] = code;
|
codes[0] = code;
|
||||||
}
|
}
|
||||||
if (key.mEnabled)
|
callListenerOnCodeInput(key, code, codes, x, y);
|
||||||
callListenerOnCodeInput(code, codes, x, y);
|
callListenerOnRelease(key, code);
|
||||||
callListenerOnRelease(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue