Merge "Distinguish key press in repeat key"
commit
1a894aeb82
|
@ -26,9 +26,10 @@ public interface KeyboardActionListener {
|
||||||
*
|
*
|
||||||
* @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key,
|
* @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key,
|
||||||
* the value will be zero.
|
* the value will be zero.
|
||||||
|
* @param isRepeatKey true if pressing has occurred while key repeat input.
|
||||||
* @param isSinglePointer true if pressing has occurred while no other key is being pressed.
|
* @param isSinglePointer true if pressing has occurred while no other key is being pressed.
|
||||||
*/
|
*/
|
||||||
public void onPressKey(int primaryCode, boolean isSinglePointer);
|
public void onPressKey(int primaryCode, boolean isRepeatKey, boolean isSinglePointer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user releases a key. This is sent after the {@link #onCodeInput} is called.
|
* Called when the user releases a key. This is sent after the {@link #onCodeInput} is called.
|
||||||
|
@ -102,7 +103,7 @@ public interface KeyboardActionListener {
|
||||||
|
|
||||||
public static class Adapter implements KeyboardActionListener {
|
public static class Adapter implements KeyboardActionListener {
|
||||||
@Override
|
@Override
|
||||||
public void onPressKey(int primaryCode, boolean isSinglePointer) {}
|
public void onPressKey(int primaryCode, boolean isRepeatKey, boolean isSinglePointer) {}
|
||||||
@Override
|
@Override
|
||||||
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -246,7 +246,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
startTypingStateTimer(currentKey);
|
startTypingStateTimer(currentKey);
|
||||||
final KeyboardActionListener listener =
|
final KeyboardActionListener listener =
|
||||||
keyboardView.getKeyboardActionListener();
|
keyboardView.getKeyboardActionListener();
|
||||||
listener.onPressKey(code, true /* isSinglePointer */);
|
listener.onPressKey(code, true /* isRepeatKey */, true /* isSinglePointer */);
|
||||||
listener.onCodeInput(code,
|
listener.onCodeInput(code,
|
||||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
}
|
}
|
||||||
|
@ -987,7 +987,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
if (key.hasNoPanelAutoMoreKey()) {
|
if (key.hasNoPanelAutoMoreKey()) {
|
||||||
final int moreKeyCode = key.mMoreKeys[0].mCode;
|
final int moreKeyCode = key.mMoreKeys[0].mCode;
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
listener.onPressKey(moreKeyCode, true /* isSinglePointer */);
|
listener.onPressKey(moreKeyCode, false /* isRepeatKey */, true /* isSinglePointer */);
|
||||||
listener.onCodeInput(moreKeyCode,
|
listener.onCodeInput(moreKeyCode,
|
||||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
listener.onReleaseKey(moreKeyCode, false /* withSliding */);
|
listener.onReleaseKey(moreKeyCode, false /* withSliding */);
|
||||||
|
|
|
@ -456,7 +456,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
mListener.onPressKey(key.mCode, getActivePointerTrackerCount() == 1);
|
mListener.onPressKey(key.mCode, false /* isRepeatKey */,
|
||||||
|
getActivePointerTrackerCount() == 1);
|
||||||
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
||||||
mKeyboardLayoutHasBeenChanged = false;
|
mKeyboardLayoutHasBeenChanged = false;
|
||||||
mTimerProxy.startTypingStateTimer(key);
|
mTimerProxy.startTypingStateTimer(key);
|
||||||
|
|
|
@ -2677,22 +2677,30 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hapticAndAudioFeedback(final int code, final boolean isRepeatKey) {
|
||||||
|
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
||||||
|
if (keyboardView != null && keyboardView.isInSlidingKeyInput()) {
|
||||||
|
// No need to feedback while sliding input.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isRepeatKey && code == Constants.CODE_DELETE && !mConnection.canDeleteCharacters()) {
|
||||||
|
// No need to feedback when repeating delete key will have no effect.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, keyboardView);
|
||||||
|
}
|
||||||
|
|
||||||
// Callback of the {@link KeyboardActionListener}. This is called when a key is depressed;
|
// Callback of the {@link KeyboardActionListener}. This is called when a key is depressed;
|
||||||
// release matching call is {@link #onReleaseKey(int,boolean)} below.
|
// release matching call is {@link #onReleaseKey(int,boolean)} below.
|
||||||
@Override
|
@Override
|
||||||
public void onPressKey(final int primaryCode, final boolean isSinglePointer) {
|
public void onPressKey(final int primaryCode, final boolean isRepeatKey,
|
||||||
|
final boolean isSinglePointer) {
|
||||||
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer);
|
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer);
|
||||||
final MainKeyboardView mKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
hapticAndAudioFeedback(primaryCode, isRepeatKey);
|
||||||
final boolean noFeedback = (mKeyboardView != null && mKeyboardView.isInSlidingKeyInput())
|
|
||||||
|| (primaryCode == Constants.CODE_DELETE && !mConnection.canDeleteCharacters());
|
|
||||||
if (!noFeedback) {
|
|
||||||
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
|
|
||||||
primaryCode, mKeyboardView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback of the {@link KeyboardActionListener}. This is called when a key is released;
|
// Callback of the {@link KeyboardActionListener}. This is called when a key is released;
|
||||||
// press matching call is {@link #onPressKey(int,boolean)} above.
|
// press matching call is {@link #onPressKey(int,boolean,boolean)} above.
|
||||||
@Override
|
@Override
|
||||||
public void onReleaseKey(final int primaryCode, final boolean withSliding) {
|
public void onReleaseKey(final int primaryCode, final boolean withSliding) {
|
||||||
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);
|
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);
|
||||||
|
|
Loading…
Reference in New Issue