Rename KeyboardActionListener methods
* Rename KeyboardActionListener.onPress to onPressKey * Rename KeyboardActionListener.onRelease to onReleaseKey * Merge KeyboardSwicther.onPressShift, onPressSymbol, and onPressOtherKey to onPressKey. * Merge KeyboardSwitcher.onReleaseShift and onReleaseSymbol to onReleaseKey. * Merge KeyboardState.onPressShift, onPressSymbol, and onPressOtherKey to onPressKey. * Merge KeyboardState.onReleaseShift and onReleaseSymbol to onReleaseKey. Change-Id: Icf28fd18e238c5e534c292893e4ab5b6b98e72f8
This commit is contained in:
parent
c9fade6b87
commit
2a88440419
12 changed files with 230 additions and 219 deletions
|
@ -434,9 +434,10 @@ public class Keyboard {
|
||||||
case CODE_SHORTCUT: return "shortcut";
|
case CODE_SHORTCUT: return "shortcut";
|
||||||
case CODE_UNSPECIFIED: return "unspec";
|
case CODE_UNSPECIFIED: return "unspec";
|
||||||
default:
|
default:
|
||||||
if (code < 0) Log.w(TAG, "Unknow negative key code=" + code);
|
if (code <= 0) Log.w(TAG, "Unknown non-positive key code=" + code);
|
||||||
if (code < 0x100) return String.format("\\u%02x", code);
|
if (code < CODE_SPACE) return String.format("'\\u%02x'", code);
|
||||||
return String.format("\\u04x", code);
|
if (code < 0x100) return String.format("'%c'", code);
|
||||||
|
return String.format("'\\u%04x'", code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,8 @@ 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 withSliding true if pressing has occurred because the user slid finger from other key
|
|
||||||
* to this key without releasing the finger.
|
|
||||||
*/
|
*/
|
||||||
public void onPress(int primaryCode, boolean withSliding);
|
public void onPressKey(int primaryCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -37,7 +35,7 @@ public interface KeyboardActionListener {
|
||||||
* @param withSliding true if releasing has occurred because the user slid finger from the key
|
* @param withSliding true if releasing has occurred because the user slid finger from the key
|
||||||
* to other key without releasing the finger.
|
* to other key without releasing the finger.
|
||||||
*/
|
*/
|
||||||
public void onRelease(int primaryCode, boolean withSliding);
|
public void onReleaseKey(int primaryCode, boolean withSliding);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a key code to the listener.
|
* Send a key code to the listener.
|
||||||
|
@ -79,9 +77,9 @@ public interface KeyboardActionListener {
|
||||||
|
|
||||||
public static class Adapter implements KeyboardActionListener {
|
public static class Adapter implements KeyboardActionListener {
|
||||||
@Override
|
@Override
|
||||||
public void onPress(int primaryCode, boolean withSliding) {}
|
public void onPressKey(int primaryCode) {}
|
||||||
@Override
|
@Override
|
||||||
public void onRelease(int primaryCode, boolean withSliding) {}
|
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {}
|
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -270,24 +270,12 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
mState.onUpdateShiftState(mInputMethodService.getCurrentAutoCapsState());
|
mState.onUpdateShiftState(mInputMethodService.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressShift(boolean withSliding) {
|
public void onPressKey(int code) {
|
||||||
mState.onPressShift(withSliding);
|
mState.onPressKey(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseShift(boolean withSliding) {
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
mState.onReleaseShift(withSliding);
|
mState.onReleaseKey(code, withSliding);
|
||||||
}
|
|
||||||
|
|
||||||
public void onPressSymbol() {
|
|
||||||
mState.onPressSymbol();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onReleaseSymbol() {
|
|
||||||
mState.onReleaseSymbol();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onOtherKeyPressed() {
|
|
||||||
mState.onOtherKeyPressed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelInput() {
|
public void onCancelInput() {
|
||||||
|
|
|
@ -417,9 +417,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
// the second tap is treated as this double tap event, so that we need not mark tracker
|
// the second tap is treated as this double tap event, so that we need not mark tracker
|
||||||
// calling setAlreadyProcessed() nor remove the tracker from mPointerQueue.
|
// calling setAlreadyProcessed() nor remove the tracker from mPointerQueue.
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
mKeyboardActionListener.onCustomRequest(LatinIME.CODE_HAPTIC_AND_AUDIO_FEEDBACK);
|
invokeCustomRequest(LatinIME.CODE_HAPTIC_AND_AUDIO_FEEDBACK);
|
||||||
} else {
|
} else {
|
||||||
mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
|
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,17 +479,17 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invokeCustomRequest(int code) {
|
private boolean invokeCustomRequest(int code) {
|
||||||
return getKeyboardActionListener().onCustomRequest(code);
|
return mKeyboardActionListener.onCustomRequest(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeCodeInput(int primaryCode) {
|
private void invokeCodeInput(int primaryCode) {
|
||||||
getKeyboardActionListener().onCodeInput(primaryCode, null,
|
mKeyboardActionListener.onCodeInput(primaryCode, null,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeReleaseKey(int primaryCode) {
|
private void invokeReleaseKey(int primaryCode) {
|
||||||
getKeyboardActionListener().onRelease(primaryCode, false);
|
mKeyboardActionListener.onReleaseKey(primaryCode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
|
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
|
||||||
|
@ -514,7 +514,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
: parentKey.mX + parentKey.mWidth / 2;
|
: parentKey.mX + parentKey.mWidth / 2;
|
||||||
final int pointY = parentKey.mY - keyboard.mVerticalGap;
|
final int pointY = parentKey.mY - keyboard.mVerticalGap;
|
||||||
moreKeysPanel.showMoreKeysPanel(
|
moreKeysPanel.showMoreKeysPanel(
|
||||||
this, this, pointX, pointY, mMoreKeysWindow, getKeyboardActionListener());
|
this, this, pointX, pointY, mMoreKeysWindow, mKeyboardActionListener);
|
||||||
final int translatedX = moreKeysPanel.translateX(tracker.getLastX());
|
final int translatedX = moreKeysPanel.translateX(tracker.getLastX());
|
||||||
final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
|
final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
|
||||||
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
|
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
|
||||||
|
|
|
@ -61,12 +61,13 @@ public class MiniKeyboardView extends KeyboardView implements MoreKeysPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPress(int primaryCode, boolean withSliding) {
|
public void onPressKey(int primaryCode) {
|
||||||
mListener.onPress(primaryCode, withSliding);
|
mListener.onPressKey(primaryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRelease(int primaryCode, boolean withSliding) {
|
public void onReleaseKey(int primaryCode, boolean withSliding) {
|
||||||
mListener.onRelease(primaryCode, withSliding);
|
mListener.onReleaseKey(primaryCode, withSliding);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -237,18 +237,18 @@ 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(Key key, boolean withSliding) {
|
private boolean callListenerOnPressAndCheckKeyboardLayoutChange(Key key) {
|
||||||
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, "onPress : " + KeyDetector.printableCode(key)
|
Log.d(TAG, "onPress : " + KeyDetector.printableCode(key)
|
||||||
+ " sliding=" + withSliding + " ignoreModifier=" + ignoreModifierKey
|
+ " ignoreModifier=" + ignoreModifierKey
|
||||||
+ " enabled=" + key.isEnabled());
|
+ " enabled=" + key.isEnabled());
|
||||||
}
|
}
|
||||||
if (ignoreModifierKey) {
|
if (ignoreModifierKey) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
mListener.onPress(key.mCode, withSliding);
|
mListener.onPressKey(key.mCode);
|
||||||
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
||||||
mKeyboardLayoutHasBeenChanged = false;
|
mKeyboardLayoutHasBeenChanged = false;
|
||||||
return keyboardLayoutHasBeenChanged;
|
return keyboardLayoutHasBeenChanged;
|
||||||
|
@ -296,7 +296,7 @@ public class PointerTracker {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
mListener.onRelease(primaryCode, withSliding);
|
mListener.onReleaseKey(primaryCode, withSliding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +495,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 key according to the new
|
// {@link #setKeyboard}. In those cases, we should update key according to the new
|
||||||
// keyboard layout.
|
// keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(key, false)) {
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
||||||
key = onDownKey(x, y, eventTime);
|
key = onDownKey(x, y, eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,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 key according to the
|
// {@link #setKeyboard}. In those cases, we should update key according to the
|
||||||
// new keyboard layout.
|
// new keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(key, true)) {
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
||||||
key = onMoveKey(x, y);
|
key = onMoveKey(x, y);
|
||||||
}
|
}
|
||||||
onMoveToNewKey(key, x, y);
|
onMoveToNewKey(key, x, y);
|
||||||
|
@ -548,7 +548,7 @@ public class PointerTracker {
|
||||||
// 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 key according
|
// at {@link #setKeyboard}. In those cases, we should update key according
|
||||||
// to the new keyboard layout.
|
// to the new keyboard layout.
|
||||||
if (callListenerOnPressAndCheckKeyboardLayoutChange(key, true)) {
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
||||||
key = onMoveKey(x, y);
|
key = onMoveKey(x, y);
|
||||||
}
|
}
|
||||||
onMoveToNewKey(key, x, y);
|
onMoveToNewKey(key, x, y);
|
||||||
|
|
|
@ -21,15 +21,13 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
|
||||||
// TODO: Add unit tests
|
|
||||||
/**
|
/**
|
||||||
* Keyboard state machine.
|
* Keyboard state machine.
|
||||||
*
|
*
|
||||||
* This class contains all keyboard state transition logic.
|
* This class contains all keyboard state transition logic.
|
||||||
*
|
*
|
||||||
* The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressShift(boolean)}, {@link #onReleaseShift(boolean)}, {@link #onPressSymbol()},
|
* {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)},
|
||||||
* {@link #onReleaseSymbol()}, {@link #onOtherKeyPressed()},
|
|
||||||
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
|
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
|
||||||
* {@link #onUpdateShiftState(boolean)}, and {@link #onToggleCapsLock()}.
|
* {@link #onUpdateShiftState(boolean)}, and {@link #onToggleCapsLock()}.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +35,8 @@ import com.android.inputmethod.keyboard.Keyboard;
|
||||||
*/
|
*/
|
||||||
public class KeyboardState {
|
public class KeyboardState {
|
||||||
private static final String TAG = KeyboardState.class.getSimpleName();
|
private static final String TAG = KeyboardState.class.getSimpleName();
|
||||||
private static final boolean DEBUG_STATE = false;
|
private static final boolean DEBUG_EVENT = false;
|
||||||
|
private static final boolean DEBUG_ACTION = false;
|
||||||
|
|
||||||
public interface SwitchActions {
|
public interface SwitchActions {
|
||||||
public void setAlphabetKeyboard();
|
public void setAlphabetKeyboard();
|
||||||
|
@ -97,7 +96,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) {
|
public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onLoadKeyboard");
|
Log.d(TAG, "onLoadKeyboard");
|
||||||
}
|
}
|
||||||
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
|
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
|
||||||
|
@ -122,7 +121,7 @@ public class KeyboardState {
|
||||||
state.mIsShifted = mIsSymbolShifted;
|
state.mIsShifted = mIsSymbolShifted;
|
||||||
}
|
}
|
||||||
state.mIsValid = true;
|
state.mIsValid = true;
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onSaveKeyboardState: alphabet=" + state.mIsAlphabetMode
|
Log.d(TAG, "onSaveKeyboardState: alphabet=" + state.mIsAlphabetMode
|
||||||
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,7 @@ public class KeyboardState {
|
||||||
|
|
||||||
private void onRestoreKeyboardState() {
|
private void onRestoreKeyboardState() {
|
||||||
final SavedKeyboardState state = mSavedKeyboardState;
|
final SavedKeyboardState state = mSavedKeyboardState;
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onRestoreKeyboardState: valid=" + state.mIsValid
|
Log.d(TAG, "onRestoreKeyboardState: valid=" + state.mIsValid
|
||||||
+ " alphabet=" + state.mIsAlphabetMode
|
+ " alphabet=" + state.mIsAlphabetMode
|
||||||
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
||||||
|
@ -162,7 +161,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShifted(int shiftMode) {
|
private void setShifted(int shiftMode) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
|
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
|
||||||
}
|
}
|
||||||
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
|
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
|
||||||
|
@ -182,7 +181,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftLocked(boolean shiftLocked) {
|
private void setShiftLocked(boolean shiftLocked) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked);
|
Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked);
|
||||||
}
|
}
|
||||||
mKeyboardShiftState.setShiftLocked(shiftLocked);
|
mKeyboardShiftState.setShiftLocked(shiftLocked);
|
||||||
|
@ -206,7 +205,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAlphabetKeyboard() {
|
private void setAlphabetKeyboard() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setAlphabetKeyboard");
|
Log.d(TAG, "setAlphabetKeyboard");
|
||||||
}
|
}
|
||||||
mSwitchActions.setAlphabetKeyboard();
|
mSwitchActions.setAlphabetKeyboard();
|
||||||
|
@ -220,7 +219,7 @@ public class KeyboardState {
|
||||||
|
|
||||||
// TODO: Make this method private
|
// TODO: Make this method private
|
||||||
public void setSymbolsKeyboard() {
|
public void setSymbolsKeyboard() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setSymbolsKeyboard");
|
Log.d(TAG, "setSymbolsKeyboard");
|
||||||
}
|
}
|
||||||
mPrevMainKeyboardWasShiftLocked = mKeyboardShiftState.isShiftLocked();
|
mPrevMainKeyboardWasShiftLocked = mKeyboardShiftState.isShiftLocked();
|
||||||
|
@ -231,7 +230,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSymbolsShiftedKeyboard() {
|
private void setSymbolsShiftedKeyboard() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setSymbolsShiftedKeyboard");
|
Log.d(TAG, "setSymbolsShiftedKeyboard");
|
||||||
}
|
}
|
||||||
mSwitchActions.setSymbolsShiftedKeyboard();
|
mSwitchActions.setSymbolsShiftedKeyboard();
|
||||||
|
@ -240,19 +239,40 @@ public class KeyboardState {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressSymbol() {
|
public void onPressKey(int code) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onPressSymbol: " + this);
|
Log.d(TAG, "onPressKey: code=" + Keyboard.printableCode(code) + " " + this);
|
||||||
}
|
}
|
||||||
|
if (code == Keyboard.CODE_SHIFT) {
|
||||||
|
onPressShift();
|
||||||
|
} else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
|
onPressSymbol();
|
||||||
|
} else {
|
||||||
|
mShiftKeyState.onOtherKeyPressed();
|
||||||
|
mSymbolKeyState.onOtherKeyPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
|
if (DEBUG_EVENT) {
|
||||||
|
Log.d(TAG, "onReleaseKey: code=" + Keyboard.printableCode(code)
|
||||||
|
+ " sliding=" + withSliding + " " + this);
|
||||||
|
}
|
||||||
|
if (code == Keyboard.CODE_SHIFT) {
|
||||||
|
onReleaseShift(withSliding);
|
||||||
|
} else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
|
// TODO: Make use of withSliding instead of relying on mSwitchState.
|
||||||
|
onReleaseSymbol();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPressSymbol() {
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols();
|
||||||
mSymbolKeyState.onPress();
|
mSymbolKeyState.onPress();
|
||||||
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseSymbol() {
|
private void onReleaseSymbol() {
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onReleaseSymbol: " + this);
|
|
||||||
}
|
|
||||||
// Snap back to the previous keyboard mode if the user chords the mode change key and
|
// Snap back to the previous keyboard mode if the user chords the mode change key and
|
||||||
// another key, then releases the mode change key.
|
// another key, then releases the mode change key.
|
||||||
if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) {
|
if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) {
|
||||||
|
@ -261,16 +281,8 @@ public class KeyboardState {
|
||||||
mSymbolKeyState.onRelease();
|
mSymbolKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOtherKeyPressed() {
|
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onOtherKeyPressed: " + this);
|
|
||||||
}
|
|
||||||
mShiftKeyState.onOtherKeyPressed();
|
|
||||||
mSymbolKeyState.onOtherKeyPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onUpdateShiftState(boolean autoCaps) {
|
public void onUpdateShiftState(boolean autoCaps) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this);
|
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
onUpdateShiftStateInternal(autoCaps);
|
onUpdateShiftStateInternal(autoCaps);
|
||||||
|
@ -294,10 +306,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressShift(boolean withSliding) {
|
private void onPressShift() {
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onPressShift: sliding=" + withSliding + " " + this);
|
|
||||||
}
|
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
if (mKeyboardShiftState.isShiftLocked()) {
|
if (mKeyboardShiftState.isShiftLocked()) {
|
||||||
// Shift key is pressed while caps lock state, we will treat this state as shifted
|
// Shift key is pressed while caps lock state, we will treat this state as shifted
|
||||||
|
@ -326,10 +335,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseShift(boolean withSliding) {
|
private void onReleaseShift(boolean withSliding) {
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onReleaseShift: sliding=" + withSliding + " " + this);
|
|
||||||
}
|
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
final boolean isShiftLocked = mKeyboardShiftState.isShiftLocked();
|
final boolean isShiftLocked = mKeyboardShiftState.isShiftLocked();
|
||||||
if (mShiftKeyState.isMomentary()) {
|
if (mShiftKeyState.isMomentary()) {
|
||||||
|
@ -363,8 +369,8 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelInput(boolean isSinglePointer) {
|
public void onCancelInput(boolean isSinglePointer) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCancelInput: isSinglePointer=" + isSinglePointer + " " + this);
|
Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this);
|
||||||
}
|
}
|
||||||
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
||||||
if (isSinglePointer) {
|
if (isSinglePointer) {
|
||||||
|
@ -392,8 +398,9 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer, boolean autoCaps) {
|
public void onCodeInput(int code, boolean isSinglePointer, boolean autoCaps) {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer
|
Log.d(TAG, "onCodeInput: code=" + Keyboard.printableCode(code)
|
||||||
|
+ " single=" + isSinglePointer
|
||||||
+ " autoCaps=" + autoCaps + " " + this);
|
+ " autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
switch (mSwitchState) {
|
switch (mSwitchState) {
|
||||||
|
@ -465,7 +472,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onToggleCapsLock() {
|
public void onToggleCapsLock() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onToggleCapsLock: " + this);
|
Log.d(TAG, "onToggleCapsLock: " + this);
|
||||||
}
|
}
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
|
|
|
@ -1239,7 +1239,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
mLastKeyTime = when;
|
mLastKeyTime = when;
|
||||||
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
|
|
||||||
// The space state depends only on the last character pressed and its own previous
|
// The space state depends only on the last character pressed and its own previous
|
||||||
// state. Here, we revert the space state to neutral if the key is actually modifying
|
// state. Here, we revert the space state to neutral if the key is actually modifying
|
||||||
// the input contents (any non-shift key), which is what we should do for
|
// the input contents (any non-shift key), which is what we should do for
|
||||||
|
@ -1262,7 +1261,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SHIFT:
|
case Keyboard.CODE_SHIFT:
|
||||||
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
// Shift and symbol key is handled in onPress() and onRelease().
|
// Shift and symbol key is handled in onPressKey() and onReleaseKey().
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SETTINGS:
|
case Keyboard.CODE_SETTINGS:
|
||||||
onSettingsKeyPressed();
|
onSettingsKeyPressed();
|
||||||
|
@ -2258,28 +2257,17 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPress(int primaryCode, boolean withSliding) {
|
public void onPressKey(int primaryCode) {
|
||||||
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
if (switcher.isVibrateAndSoundFeedbackRequired()) {
|
if (switcher.isVibrateAndSoundFeedbackRequired()) {
|
||||||
hapticAndAudioFeedback(primaryCode);
|
hapticAndAudioFeedback(primaryCode);
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SHIFT) {
|
switcher.onPressKey(primaryCode);
|
||||||
switcher.onPressShift(withSliding);
|
|
||||||
} else if (primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
|
||||||
switcher.onPressSymbol();
|
|
||||||
} else {
|
|
||||||
switcher.onOtherKeyPressed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRelease(int primaryCode, boolean withSliding) {
|
public void onReleaseKey(int primaryCode, boolean withSliding) {
|
||||||
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);
|
||||||
if (primaryCode == Keyboard.CODE_SHIFT) {
|
|
||||||
switcher.onReleaseShift(withSliding);
|
|
||||||
} else if (primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
|
||||||
switcher.onReleaseSymbol();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,13 +56,13 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
private final KeyboardActionListener mSuggestionsPaneListener =
|
private final KeyboardActionListener mSuggestionsPaneListener =
|
||||||
new KeyboardActionListener.Adapter() {
|
new KeyboardActionListener.Adapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onPress(int primaryCode, boolean withSliding) {
|
public void onPressKey(int primaryCode) {
|
||||||
mListener.onPress(primaryCode, withSliding);
|
mListener.onPressKey(primaryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRelease(int primaryCode, boolean withSliding) {
|
public void onReleaseKey(int primaryCode, boolean withSliding) {
|
||||||
mListener.onRelease(primaryCode, withSliding);
|
mListener.onReleaseKey(primaryCode, withSliding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,9 +18,8 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
public class KeyboardStateNonDistinctTests extends AndroidTestCase
|
||||||
|
implements MockKeyboardSwitcher.Constants {
|
||||||
public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
|
||||||
protected MockKeyboardSwitcher mSwitcher;
|
protected MockKeyboardSwitcher mSwitcher;
|
||||||
|
|
||||||
public boolean hasDistinctMultitouch() {
|
public boolean hasDistinctMultitouch() {
|
||||||
|
@ -37,15 +36,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch());
|
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Argument for KeyboardState.onPressShift and onReleaseShift.
|
|
||||||
public static final boolean NOT_SLIDING = false;
|
|
||||||
public static final boolean SLIDING = true;
|
|
||||||
// Argument for KeyboardState.onCodeInput.
|
|
||||||
public static final boolean SINGLE = true;
|
|
||||||
public static final boolean MULTI = false;
|
|
||||||
public static final boolean NO_AUTO_CAPS = false;
|
|
||||||
public static final boolean AUTO_CAPS = true;
|
|
||||||
|
|
||||||
public void assertAlphabetNormal() {
|
public void assertAlphabetNormal() {
|
||||||
assertTrue(mSwitcher.assertAlphabetNormal());
|
assertTrue(mSwitcher.assertAlphabetNormal());
|
||||||
}
|
}
|
||||||
|
@ -78,58 +68,64 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
// Shift key in alphabet mode.
|
// Shift key in alphabet mode.
|
||||||
public void testShift() {
|
public void testShift() {
|
||||||
// Press/release shift key, enter into shift state.
|
// Press/release shift key, enter into shift state.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Press/release shift key, back to normal state.
|
// Press/release shift key, back to normal state.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
|
|
||||||
// Press/release shift key, enter into shift state.
|
// Press/release shift key, enter into shift state.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Press/release letter key, snap back to normal state.
|
// Press/release letter key, snap back to normal state.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('Z');
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
mSwitcher.onCodeInput('Z');
|
||||||
|
mSwitcher.onReleaseKey('Z');
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift key sliding input.
|
// Shift key sliding input.
|
||||||
public void testShiftSliding() {
|
public void testShiftSliding() {
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Slide out shift key.
|
// Slide out shift key.
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT, SLIDING);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
|
|
||||||
// Enter into letter key.
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('Z');
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Release letter key, snap back to alphabet.
|
// Release letter key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
mSwitcher.onCodeInput('Z');
|
||||||
|
mSwitcher.onReleaseKey('Z');
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterSymbolsMode() {
|
public void enterSymbolsMode() {
|
||||||
// Press/release "?123" key.
|
// Press/release "?123" key.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(CODE_SYMBOL);
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveSymbolsMode() {
|
public void leaveSymbolsMode() {
|
||||||
// Press/release "ABC" key.
|
// Press/release "ABC" key.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(CODE_SYMBOL);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SYMBOL);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,27 +141,28 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Press/release "ABC" key, switch back to shift locked mode.
|
// Press/release "ABC" key, switch back to shift locked mode.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(CODE_SYMBOL);
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbols key sliding input.
|
// Symbols key sliding input.
|
||||||
public void testSymbolsSliding() {
|
public void testSymbolsSliding() {
|
||||||
// Press "123?" key.
|
// Press "123?" key.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Slide out from "123?" key.
|
// Slide out from "123?" key.
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL, SLIDING);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
// Enter into letter key.
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('z');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Release letter key, snap back to alphabet.
|
// Release letter key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput('z', SINGLE);
|
mSwitcher.onCodeInput('z');
|
||||||
|
mSwitcher.onReleaseKey('z');
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,15 +171,17 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Press/release "=\<" key.
|
// Press/release "=\<" key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
|
|
||||||
// Press/release "?123" key.
|
// Press/release "?123" key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
leaveSymbolsMode();
|
leaveSymbolsMode();
|
||||||
|
@ -193,17 +192,18 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Press "=\<" key.
|
// Press "=\<" key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
// Slide out "=\<" key.
|
// Slide out "=\<" key.
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT, SLIDING);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
|
|
||||||
// Enter into symbol shifted letter key.
|
// Enter into symbol shifted letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('~');
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
// Release symbol shifted letter key, snap back to symbols.
|
// Release symbol shifted letter key, snap back to symbols.
|
||||||
mSwitcher.onCodeInput('~', SINGLE);
|
mSwitcher.onCodeInput('~');
|
||||||
|
mSwitcher.onReleaseKey('~');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,23 +212,25 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Press/release "=\<" key.
|
// Press/release "=\<" key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
|
|
||||||
// Press "123?" key.
|
// Press "123?" key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Slide out "123?" key.
|
// Slide out "123?" key.
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT, SLIDING);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
// Enter into symbol letter key.
|
// Enter into symbol letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Release symbol letter key, snap back to symbols shift.
|
// Release symbol letter key, snap back to symbols shift.
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
mSwitcher.onCodeInput('1');
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,14 +239,16 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Enter a symbol letter.
|
// Enter a symbol letter.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
mSwitcher.onCodeInput('1');
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Enter space, snap back to alphabet.
|
// Enter space, snap back to alphabet.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey(CODE_SPACE);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SPACE, SINGLE);
|
mSwitcher.onCodeInput(CODE_SPACE);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SPACE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,14 +264,16 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Enter a symbol letter.
|
// Enter a symbol letter.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
mSwitcher.onCodeInput('1');
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Enter snap back letter, snap back to alphabet.
|
// Enter snap back letter, snap back to alphabet.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey(snapBackCode);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput(snapBackCode, SINGLE);
|
mSwitcher.onCodeInput(snapBackCode);
|
||||||
|
mSwitcher.onReleaseKey(snapBackCode);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,10 +285,11 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Release shift key.
|
// Release shift key.
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,16 +301,17 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Slide out shift key.
|
// Slide out shift key.
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT, SLIDING);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Enter into letter key.
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('Z');
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Release letter key, snap back to alphabet.
|
// Release letter key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
mSwitcher.onCodeInput('Z');
|
||||||
|
mSwitcher.onReleaseKey('Z');
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,42 +323,43 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press "123?" key.
|
// Press "123?" key.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Slide out "123?" key.
|
// Slide out "123?" key.
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL, SLIDING);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Enter into symbol letter keys.
|
// Enter into symbol letter keys.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Release symbol letter key, snap back to alphabet.
|
// Release symbol letter key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
mSwitcher.onCodeInput('1');
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterShiftLockWithLongPressShift() {
|
public void enterShiftLockWithLongPressShift() {
|
||||||
// Long press shift key
|
// Long press shift key
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
mSwitcher.onCodeInput(CODE_CAPSLOCK);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveShiftLockWithLongPressShift() {
|
public void leaveShiftLockWithLongPressShift() {
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
mSwitcher.onCodeInput(CODE_CAPSLOCK);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,11 +376,11 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
|
|
||||||
// Tap shift key.
|
// Tap shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_SHIFT, SINGLE);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,25 +388,25 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
// TODO: Move double tap recognizing timer/logic into KeyboardState.
|
// TODO: Move double tap recognizing timer/logic into KeyboardState.
|
||||||
public void testDoubleTapShift() {
|
public void testDoubleTapShift() {
|
||||||
// First shift key tap.
|
// First shift key tap.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Second shift key tap.
|
// Second shift key tap.
|
||||||
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
|
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_CAPSLOCK);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
|
|
||||||
// First shift key tap.
|
// First shift key tap.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
// Second shift key tap.
|
// Second shift key tap.
|
||||||
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
|
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
|
||||||
|
|
|
@ -27,20 +27,22 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
|
||||||
// Shift key chording input.
|
// Shift key chording input.
|
||||||
public void testShiftChording() {
|
public void testShiftChording() {
|
||||||
// Press shift key and hold, enter into choring shift state.
|
// Press shift key and hold, enter into choring shift state.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(Keyboard.CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
|
|
||||||
// Press/release letter keys.
|
// Press/release letter keys.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('Z');
|
||||||
mSwitcher.onCodeInput('Z', MULTI);
|
mSwitcher.onCodeInput('Z', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('Z');
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('X');
|
||||||
mSwitcher.onCodeInput('X', MULTI);
|
mSwitcher.onCodeInput('X', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('X');
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
|
|
||||||
// Release shift key, snap back to normal state.
|
// Release shift key, snap back to normal state.
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
mSwitcher.updateShiftState();
|
mSwitcher.updateShiftState();
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
@ -48,20 +50,22 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
|
||||||
// Symbols key chording input.
|
// Symbols key chording input.
|
||||||
public void testSymbolsChording() {
|
public void testSymbolsChording() {
|
||||||
// Press symbols key and hold, enter into choring shift state.
|
// Press symbols key and hold, enter into choring shift state.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
// Press/release symbol letter keys.
|
// Press/release symbol letter keys.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
mSwitcher.onCodeInput('1', MULTI);
|
mSwitcher.onCodeInput('1', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('2');
|
||||||
mSwitcher.onCodeInput('2', MULTI);
|
mSwitcher.onCodeInput('2', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('2');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
// Release shift key, snap back to normal state.
|
// Release shift key, snap back to normal state.
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(CODE_SYMBOL);
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL);
|
||||||
mSwitcher.updateShiftState();
|
mSwitcher.updateShiftState();
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
@ -74,15 +78,16 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
mSwitcher.onPressKey(CODE_SHIFT);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Press/release letter keys.
|
// Press/release letter keys.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('Z');
|
||||||
mSwitcher.onCodeInput('Z', MULTI);
|
mSwitcher.onCodeInput('Z', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('Z');
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Release shift key, snap back to alphabet.
|
// Release shift key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(CODE_SHIFT);
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
mSwitcher.onReleaseKey(CODE_SHIFT);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,16 +99,17 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press "123?" key.
|
// Press "123?" key.
|
||||||
mSwitcher.onPressSymbol();
|
mSwitcher.onPressKey(CODE_SYMBOL);
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Press/release symbol letter keys.
|
// Press/release symbol letter keys.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput('1', MULTI);
|
mSwitcher.onCodeInput('1', MULTI);
|
||||||
|
mSwitcher.onReleaseKey('1');
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
// Release "123?" key, snap back to alphabet.
|
// Release "123?" key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(CODE_SYMBOL);
|
||||||
mSwitcher.onReleaseSymbol();
|
mSwitcher.onReleaseKey(CODE_SYMBOL);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,26 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardState.SwitchActions;
|
import com.android.inputmethod.keyboard.internal.KeyboardState.SwitchActions;
|
||||||
|
|
||||||
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
public interface Constants {
|
||||||
|
// Argument for KeyboardState.onPressKey and onReleaseKey.
|
||||||
|
public static final boolean NOT_SLIDING = false;
|
||||||
|
public static final boolean SLIDING = true;
|
||||||
|
// Argument for KeyboardState.onCodeInput.
|
||||||
|
public static final boolean SINGLE = true;
|
||||||
|
public static final boolean MULTI = false;
|
||||||
|
public static final boolean NO_AUTO_CAPS = false;
|
||||||
|
public static final boolean AUTO_CAPS = true;
|
||||||
|
|
||||||
|
public static final int CODE_SHIFT = Keyboard.CODE_SHIFT;
|
||||||
|
public static final int CODE_SYMBOL = Keyboard.CODE_SWITCH_ALPHA_SYMBOL;
|
||||||
|
public static final int CODE_CAPSLOCK = Keyboard.CODE_CAPSLOCK;
|
||||||
|
public static final int CODE_SPACE = Keyboard.CODE_SPACE;
|
||||||
|
}
|
||||||
|
|
||||||
public static final String WORD_SEPARATORS = " ,.";
|
public static final String WORD_SEPARATORS = " ,.";
|
||||||
|
|
||||||
private static final int ALPHABET_UNSHIFTED = 0;
|
private static final int ALPHABET_UNSHIFTED = 0;
|
||||||
|
@ -30,7 +47,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
private int mLayout = ALPHABET_UNSHIFTED;
|
private int mLayout = ALPHABET_UNSHIFTED;
|
||||||
|
|
||||||
private boolean mAutoCapsMode = KeyboardStateTests.NO_AUTO_CAPS;
|
private boolean mAutoCapsMode = Constants.NO_AUTO_CAPS;
|
||||||
// Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
|
// Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
|
||||||
private boolean mAutoCapsState = true;
|
private boolean mAutoCapsState = true;
|
||||||
|
|
||||||
|
@ -117,24 +134,20 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onLoadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch);
|
mState.onLoadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressShift(boolean withSliding) {
|
public void onPressKey(int code) {
|
||||||
mState.onPressShift(withSliding);
|
mState.onPressKey(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseShift(boolean withSliding) {
|
public void onReleaseKey(int code) {
|
||||||
mState.onReleaseShift(withSliding);
|
onReleaseKey(code, Constants.NOT_SLIDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressSymbol() {
|
public void onReleaseKey(int code, boolean withSliding) {
|
||||||
mState.onPressSymbol();
|
mState.onReleaseKey(code, withSliding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseSymbol() {
|
public void onCodeInput(int code) {
|
||||||
mState.onReleaseSymbol();
|
onCodeInput(code, Constants.SINGLE);
|
||||||
}
|
|
||||||
|
|
||||||
public void onOtherKeyPressed() {
|
|
||||||
mState.onOtherKeyPressed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer) {
|
public void onCodeInput(int code, boolean isSinglePointer) {
|
||||||
|
|
Loading…
Reference in a new issue