am 41afa87a: Merge "Remove automatic switch back to alphabet feature"
* commit '41afa87a72fab4f7f328569f5ebe86d2b6127641': Remove automatic switch back to alphabet featuremain
commit
89a1755627
|
@ -29,19 +29,6 @@
|
||||||
<string name="symbols_word_separators">"	 \n"()[]{}*&<>+=|.,;:!?/_\"</string>
|
<string name="symbols_word_separators">"	 \n"()[]{}*&<>+=|.,;:!?/_\"</string>
|
||||||
<!-- Word connectors -->
|
<!-- Word connectors -->
|
||||||
<string name="symbols_word_connectors">\'-</string>
|
<string name="symbols_word_connectors">\'-</string>
|
||||||
<!-- Symbol characters list that should switch back to the main layout -->
|
|
||||||
<!-- U+2018: "‘" LEFT SINGLE QUOTATION MARK
|
|
||||||
U+2019: "’" RIGHT SINGLE QUOTATION MARK
|
|
||||||
U+201A: "‚" SINGLE LOW-9 QUOTATION MARK
|
|
||||||
U+201B: "‛" SINGLE HIGH-REVERSED-9 QUOTATION MARK
|
|
||||||
U+201C: "“" LEFT DOUBLE QUOTATION MARK
|
|
||||||
U+201D: "”" RIGHT DOUBLE QUOTATION MARK
|
|
||||||
U+201E: "„" DOUBLE LOW-9 QUOTATION MARK
|
|
||||||
U+201F: "‟" DOUBLE HIGH-REVERSED-9 QUOTATION MARK
|
|
||||||
U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
|
||||||
U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -->
|
|
||||||
<!-- <string name="layout_switch_back_symbols">\"\'‘’‚‛“”„‟«»</string> -->
|
|
||||||
<string name="layout_switch_back_symbols"></string>
|
|
||||||
|
|
||||||
<!-- Always show the suggestion strip -->
|
<!-- Always show the suggestion strip -->
|
||||||
<string name="prefs_suggestion_visibility_show_value">0</string>
|
<string name="prefs_suggestion_visibility_show_value">0</string>
|
||||||
|
|
|
@ -149,7 +149,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
settingsValues.isLanguageSwitchKeyEnabled());
|
settingsValues.isLanguageSwitchKeyEnabled());
|
||||||
mKeyboardLayoutSet = builder.build();
|
mKeyboardLayoutSet = builder.build();
|
||||||
try {
|
try {
|
||||||
mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols));
|
mState.onLoadKeyboard();
|
||||||
mFeedbackManager.onSettingsChanged(settingsValues);
|
mFeedbackManager.onSettingsChanged(settingsValues);
|
||||||
} catch (KeyboardLayoutSetException e) {
|
} catch (KeyboardLayoutSetException e) {
|
||||||
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
|
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.android.inputmethod.latin.Constants;
|
||||||
*
|
*
|
||||||
* This class contains all keyboard state transition logic.
|
* This class contains all keyboard state transition logic.
|
||||||
*
|
*
|
||||||
* The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressKey(int, boolean, int)}, {@link #onReleaseKey(int, boolean)},
|
* {@link #onPressKey(int, boolean, int)}, {@link #onReleaseKey(int, boolean)},
|
||||||
* {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)},
|
* {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)},
|
||||||
* {@link #onUpdateShiftState(int)}, {@link #onLongPressTimeout(int)}.
|
* {@link #onUpdateShiftState(int)}, {@link #onLongPressTimeout(int)}.
|
||||||
|
@ -74,7 +74,6 @@ public final class KeyboardState {
|
||||||
private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3;
|
private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3;
|
||||||
private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4;
|
private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4;
|
||||||
private int mSwitchState = SWITCH_STATE_ALPHA;
|
private int mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
private String mLayoutSwitchBackSymbols;
|
|
||||||
|
|
||||||
private boolean mIsAlphabetMode;
|
private boolean mIsAlphabetMode;
|
||||||
private AlphabetShiftState mAlphabetShiftState = new AlphabetShiftState();
|
private AlphabetShiftState mAlphabetShiftState = new AlphabetShiftState();
|
||||||
|
@ -109,15 +108,14 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardState(SwitchActions switchActions) {
|
public KeyboardState(final SwitchActions switchActions) {
|
||||||
mSwitchActions = switchActions;
|
mSwitchActions = switchActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadKeyboard(String layoutSwitchBackSymbols) {
|
public void onLoadKeyboard() {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onLoadKeyboard: " + this);
|
Log.d(TAG, "onLoadKeyboard: " + this);
|
||||||
}
|
}
|
||||||
mLayoutSwitchBackSymbols = layoutSwitchBackSymbols;
|
|
||||||
// Reset alphabet shift state.
|
// Reset alphabet shift state.
|
||||||
mAlphabetShiftState.setShiftLocked(false);
|
mAlphabetShiftState.setShiftLocked(false);
|
||||||
mPrevMainKeyboardWasShiftLocked = false;
|
mPrevMainKeyboardWasShiftLocked = false;
|
||||||
|
@ -177,7 +175,7 @@ public final class KeyboardState {
|
||||||
private static final int AUTOMATIC_SHIFT = 2;
|
private static final int AUTOMATIC_SHIFT = 2;
|
||||||
private static final int SHIFT_LOCK_SHIFTED = 3;
|
private static final int SHIFT_LOCK_SHIFTED = 3;
|
||||||
|
|
||||||
private void setShifted(int shiftMode) {
|
private void setShifted(final int shiftMode) {
|
||||||
if (DEBUG_ACTION) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode) + " " + this);
|
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode) + " " + this);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +214,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftLocked(boolean shiftLocked) {
|
private void setShiftLocked(final boolean shiftLocked) {
|
||||||
if (DEBUG_ACTION) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked + " " + this);
|
Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked + " " + this);
|
||||||
}
|
}
|
||||||
|
@ -313,7 +311,7 @@ public final class KeyboardState {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(int code, boolean isSinglePointer, int autoCaps) {
|
public void onPressKey(final int code, final boolean isSinglePointer, final int autoCaps) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
||||||
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
||||||
|
@ -346,7 +344,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(int code, boolean withSliding) {
|
public void onReleaseKey(final int code, final boolean withSliding) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onReleaseKey: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onReleaseKey: code=" + Constants.printableCode(code)
|
||||||
+ " sliding=" + withSliding + " " + this);
|
+ " sliding=" + withSliding + " " + this);
|
||||||
|
@ -364,7 +362,7 @@ public final class KeyboardState {
|
||||||
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onReleaseSymbol(boolean withSliding) {
|
private void onReleaseSymbol(final boolean withSliding) {
|
||||||
if (mSymbolKeyState.isChording()) {
|
if (mSymbolKeyState.isChording()) {
|
||||||
// Switch back to the previous keyboard mode if the user chords the mode change key and
|
// Switch 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.
|
||||||
|
@ -378,7 +376,7 @@ public final class KeyboardState {
|
||||||
mSymbolKeyState.onRelease();
|
mSymbolKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongPressTimeout(int code) {
|
public void onLongPressTimeout(final int code) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onLongPressTimeout: code=" + Constants.printableCode(code) + " " + this);
|
Log.d(TAG, "onLongPressTimeout: code=" + Constants.printableCode(code) + " " + this);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +386,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdateShiftState(int autoCaps) {
|
public void onUpdateShiftState(final int autoCaps) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this);
|
Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +402,7 @@ public final class KeyboardState {
|
||||||
resetKeyboardStateToAlphabet();
|
resetKeyboardStateToAlphabet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlphabetShiftState(int autoCaps) {
|
private void updateAlphabetShiftState(final int autoCaps) {
|
||||||
if (!mIsAlphabetMode) return;
|
if (!mIsAlphabetMode) return;
|
||||||
if (!mShiftKeyState.isReleasing()) {
|
if (!mShiftKeyState.isReleasing()) {
|
||||||
// Ignore update shift state event while the shift key is being pressed (including
|
// Ignore update shift state event while the shift key is being pressed (including
|
||||||
|
@ -468,7 +466,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onReleaseShift(boolean withSliding) {
|
private void onReleaseShift(final boolean withSliding) {
|
||||||
if (mIsAlphabetMode) {
|
if (mIsAlphabetMode) {
|
||||||
final boolean isShiftLocked = mAlphabetShiftState.isShiftLocked();
|
final boolean isShiftLocked = mAlphabetShiftState.isShiftLocked();
|
||||||
mIsInAlphabetUnshiftedFromShifted = false;
|
mIsInAlphabetUnshiftedFromShifted = false;
|
||||||
|
@ -523,7 +521,7 @@ public final class KeyboardState {
|
||||||
mShiftKeyState.onRelease();
|
mShiftKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelInput(boolean isSinglePointer) {
|
public void onCancelInput(final boolean isSinglePointer) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this);
|
Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this);
|
||||||
}
|
}
|
||||||
|
@ -542,17 +540,11 @@ public final class KeyboardState {
|
||||||
|| mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE;
|
|| mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpaceCharacter(int c) {
|
private static boolean isSpaceCharacter(final int c) {
|
||||||
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLayoutSwitchBackCharacter(int c) {
|
public void onCodeInput(final int code, final boolean isSinglePointer, final int autoCaps) {
|
||||||
if (TextUtils.isEmpty(mLayoutSwitchBackSymbols)) return false;
|
|
||||||
if (mLayoutSwitchBackSymbols.indexOf(c) >= 0) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer, int autoCaps) {
|
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
||||||
+ " single=" + isSinglePointer
|
+ " single=" + isSinglePointer
|
||||||
|
@ -592,17 +584,11 @@ public final class KeyboardState {
|
||||||
|| code == Constants.CODE_OUTPUT_TEXT)) {
|
|| code == Constants.CODE_OUTPUT_TEXT)) {
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||||
}
|
}
|
||||||
// Switch back to alpha keyboard mode immediately if user types one of the switch back
|
|
||||||
// characters.
|
|
||||||
if (isLayoutSwitchBackCharacter(code)) {
|
|
||||||
toggleAlphabetAndSymbols();
|
|
||||||
mPrevSymbolsKeyboardWasShifted = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_SYMBOL:
|
case SWITCH_STATE_SYMBOL:
|
||||||
// Switch back to alpha keyboard mode if user types one or more non-space/enter
|
// Switch back to alpha keyboard mode if user types one or more non-space/enter
|
||||||
// characters followed by a space/enter or one of the switch back characters.
|
// characters followed by a space/enter.
|
||||||
if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) {
|
if (isSpaceCharacter(code)) {
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols();
|
||||||
mPrevSymbolsKeyboardWasShifted = false;
|
mPrevSymbolsKeyboardWasShifted = false;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +601,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String shiftModeToString(int shiftMode) {
|
private static String shiftModeToString(final int shiftMode) {
|
||||||
switch (shiftMode) {
|
switch (shiftMode) {
|
||||||
case UNSHIFT: return "UNSHIFT";
|
case UNSHIFT: return "UNSHIFT";
|
||||||
case MANUAL_SHIFT: return "MANUAL";
|
case MANUAL_SHIFT: return "MANUAL";
|
||||||
|
@ -624,7 +610,7 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String switchStateToString(int switchState) {
|
private static String switchStateToString(final int switchState) {
|
||||||
switch (switchState) {
|
switch (switchState) {
|
||||||
case SWITCH_STATE_ALPHA: return "ALPHA";
|
case SWITCH_STATE_ALPHA: return "ALPHA";
|
||||||
case SWITCH_STATE_SYMBOL_BEGIN: return "SYMBOL-BEGIN";
|
case SWITCH_STATE_SYMBOL_BEGIN: return "SYMBOL-BEGIN";
|
||||||
|
|
|
@ -150,59 +150,6 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
||||||
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic switch back to alphabet by registered letters.
|
|
||||||
public void testSwitchBackChar() {
|
|
||||||
// Set switch back chars.
|
|
||||||
final String switchBackSymbols = "'";
|
|
||||||
final int switchBackCode = switchBackSymbols.codePointAt(0);
|
|
||||||
setLayoutSwitchBackSymbols(switchBackSymbols);
|
|
||||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
|
||||||
|
|
||||||
// Press/release "?123" key, enter into symbols.
|
|
||||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Enter symbol letter.
|
|
||||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Enter switch back letter, switch back to alphabet.
|
|
||||||
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
|
|
||||||
|
|
||||||
// Press/release "?123" key, enter into symbols.
|
|
||||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Press/release "=\<" key, enter into symbols shifted.
|
|
||||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
|
||||||
// Enter symbol shift letter.
|
|
||||||
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
|
||||||
// Enter switch abck letter, switch back to alphabet.
|
|
||||||
pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic switch back to alphabet shift locked by registered letters.
|
|
||||||
public void testSwitchBackCharShiftLocked() {
|
|
||||||
// Set switch back chars.
|
|
||||||
final String switchBackSymbols = "'";
|
|
||||||
final int switchBackCode = switchBackSymbols.codePointAt(0);
|
|
||||||
setLayoutSwitchBackSymbols(switchBackSymbols);
|
|
||||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
|
||||||
// Long press shift key, enter alphabet shift locked.
|
|
||||||
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
|
|
||||||
ALPHABET_SHIFT_LOCKED);
|
|
||||||
|
|
||||||
// Press/release "?123" key, enter into symbols.
|
|
||||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Enter symbol letter.
|
|
||||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Enter switch back letter, switch back to alphabet shift locked.
|
|
||||||
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
|
|
||||||
|
|
||||||
// Press/release "?123" key, enter into symbols.
|
|
||||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
|
||||||
// Press/release "=\<" key, enter into symbols shifted.
|
|
||||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
|
||||||
// Enter symbol shift letter.
|
|
||||||
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
|
||||||
// Enter switch back letter, switch back to alphabet shift locked.
|
|
||||||
pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic upper case test
|
// Automatic upper case test
|
||||||
public void testAutomaticUpperCase() {
|
public void testAutomaticUpperCase() {
|
||||||
// Set capitalize the first character of all words mode.
|
// Set capitalize the first character of all words mode.
|
||||||
|
|
|
@ -22,8 +22,6 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
implements MockKeyboardSwitcher.MockConstants {
|
implements MockKeyboardSwitcher.MockConstants {
|
||||||
protected MockKeyboardSwitcher mSwitcher;
|
protected MockKeyboardSwitcher mSwitcher;
|
||||||
|
|
||||||
private String mLayoutSwitchBackSymbols = "";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
@ -34,88 +32,86 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoCapsMode(int autoCaps) {
|
public void setAutoCapsMode(final int autoCaps) {
|
||||||
mSwitcher.setAutoCapsMode(autoCaps);
|
mSwitcher.setAutoCapsMode(autoCaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayoutSwitchBackSymbols(String switchBackSymbols) {
|
private static void assertLayout(final String message, final int expected, final int actual) {
|
||||||
mLayoutSwitchBackSymbols = switchBackSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertLayout(String message, int expected, int actual) {
|
|
||||||
assertTrue(message + ": expected=" + MockKeyboardSwitcher.getLayoutName(expected)
|
assertTrue(message + ": expected=" + MockKeyboardSwitcher.getLayoutName(expected)
|
||||||
+ " actual=" + MockKeyboardSwitcher.getLayoutName(actual),
|
+ " actual=" + MockKeyboardSwitcher.getLayoutName(actual),
|
||||||
expected == actual);
|
expected == actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateShiftState(int afterUpdate) {
|
public void updateShiftState(final int afterUpdate) {
|
||||||
mSwitcher.updateShiftState();
|
mSwitcher.updateShiftState();
|
||||||
assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId());
|
assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKeyboard(int afterLoad) {
|
public void loadKeyboard(final int afterLoad) {
|
||||||
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
|
mSwitcher.loadKeyboard();
|
||||||
mSwitcher.updateShiftState();
|
mSwitcher.updateShiftState();
|
||||||
assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId());
|
assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotateDevice(int afterRotate) {
|
public void rotateDevice(final int afterRotate) {
|
||||||
mSwitcher.saveKeyboardState();
|
mSwitcher.saveKeyboardState();
|
||||||
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
|
mSwitcher.loadKeyboard();
|
||||||
assertLayout("afterRotate", afterRotate, mSwitcher.getLayoutId());
|
assertLayout("afterRotate", afterRotate, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pressKeyWithoutTimerExpire(int code, boolean isSinglePointer, int afterPress) {
|
private void pressKeyWithoutTimerExpire(final int code, final boolean isSinglePointer,
|
||||||
|
final int afterPress) {
|
||||||
mSwitcher.onPressKey(code, isSinglePointer);
|
mSwitcher.onPressKey(code, isSinglePointer);
|
||||||
assertLayout("afterPress", afterPress, mSwitcher.getLayoutId());
|
assertLayout("afterPress", afterPress, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressKey(int code, int afterPress) {
|
public void pressKey(final int code, final int afterPress) {
|
||||||
mSwitcher.expireDoubleTapTimeout();
|
mSwitcher.expireDoubleTapTimeout();
|
||||||
pressKeyWithoutTimerExpire(code, true, afterPress);
|
pressKeyWithoutTimerExpire(code, true, afterPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseKey(int code, int afterRelease) {
|
public void releaseKey(final int code, final int afterRelease) {
|
||||||
mSwitcher.onCodeInput(code, SINGLE);
|
mSwitcher.onCodeInput(code, SINGLE);
|
||||||
mSwitcher.onReleaseKey(code, NOT_SLIDING);
|
mSwitcher.onReleaseKey(code, NOT_SLIDING);
|
||||||
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
|
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressAndReleaseKey(int code, int afterPress, int afterRelease) {
|
public void pressAndReleaseKey(final int code, final int afterPress, final int afterRelease) {
|
||||||
pressKey(code, afterPress);
|
pressKey(code, afterPress);
|
||||||
releaseKey(code, afterRelease);
|
releaseKey(code, afterRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chordingPressKey(int code, int afterPress) {
|
public void chordingPressKey(final int code, final int afterPress) {
|
||||||
mSwitcher.expireDoubleTapTimeout();
|
mSwitcher.expireDoubleTapTimeout();
|
||||||
pressKeyWithoutTimerExpire(code, false, afterPress);
|
pressKeyWithoutTimerExpire(code, false, afterPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chordingReleaseKey(int code, int afterRelease) {
|
public void chordingReleaseKey(final int code, final int afterRelease) {
|
||||||
mSwitcher.onCodeInput(code, MULTI);
|
mSwitcher.onCodeInput(code, MULTI);
|
||||||
mSwitcher.onReleaseKey(code, NOT_SLIDING);
|
mSwitcher.onReleaseKey(code, NOT_SLIDING);
|
||||||
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
|
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chordingPressAndReleaseKey(int code, int afterPress, int afterRelease) {
|
public void chordingPressAndReleaseKey(final int code, final int afterPress,
|
||||||
|
final int afterRelease) {
|
||||||
chordingPressKey(code, afterPress);
|
chordingPressKey(code, afterPress);
|
||||||
chordingReleaseKey(code, afterRelease);
|
chordingReleaseKey(code, afterRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressAndSlideFromKey(int code, int afterPress, int afterSlide) {
|
public void pressAndSlideFromKey(final int code, final int afterPress, final int afterSlide) {
|
||||||
pressKey(code, afterPress);
|
pressKey(code, afterPress);
|
||||||
mSwitcher.onReleaseKey(code, SLIDING);
|
mSwitcher.onReleaseKey(code, SLIDING);
|
||||||
assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId());
|
assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void longPressKey(int code, int afterPress, int afterLongPress) {
|
public void longPressKey(final int code, final int afterPress, final int afterLongPress) {
|
||||||
pressKey(code, afterPress);
|
pressKey(code, afterPress);
|
||||||
mSwitcher.onLongPressTimeout(code);
|
mSwitcher.onLongPressTimeout(code);
|
||||||
assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId());
|
assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void longPressAndReleaseKey(int code, int afterPress, int afterLongPress,
|
public void longPressAndReleaseKey(final int code, final int afterPress,
|
||||||
int afterRelease) {
|
final int afterLongPress, final int afterRelease) {
|
||||||
longPressKey(code, afterPress, afterLongPress);
|
longPressKey(code, afterPress, afterLongPress);
|
||||||
releaseKey(code, afterRelease);
|
releaseKey(code, afterRelease);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
return mLayout;
|
return mLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLayoutName(int layoutId) {
|
public static String getLayoutName(final int layoutId) {
|
||||||
switch (layoutId) {
|
switch (layoutId) {
|
||||||
case MockConstants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED";
|
case MockConstants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED";
|
||||||
case MockConstants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
|
case MockConstants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
|
||||||
|
@ -74,7 +74,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoCapsMode(int autoCaps) {
|
public void setAutoCapsMode(final int autoCaps) {
|
||||||
mAutoCapsMode = autoCaps;
|
mAutoCapsMode = autoCaps;
|
||||||
mAutoCapsState = autoCaps;
|
mAutoCapsState = autoCaps;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(int code) {
|
public void startLongPressTimer(final int code) {
|
||||||
mLongPressTimeoutCode = code;
|
mLongPressTimeoutCode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,11 +149,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hapticAndAudioFeedback(int code) {
|
public void hapticAndAudioFeedback(final int code) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongPressTimeout(int code) {
|
public void onLongPressTimeout(final int code) {
|
||||||
// TODO: Handle simultaneous long presses.
|
// TODO: Handle simultaneous long presses.
|
||||||
if (mLongPressTimeoutCode == code) {
|
if (mLongPressTimeoutCode == code) {
|
||||||
mLongPressTimeoutCode = 0;
|
mLongPressTimeoutCode = 0;
|
||||||
|
@ -165,26 +165,26 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onUpdateShiftState(mAutoCapsState);
|
mState.onUpdateShiftState(mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKeyboard(String layoutSwitchBackSymbols) {
|
public void loadKeyboard() {
|
||||||
mState.onLoadKeyboard(layoutSwitchBackSymbols);
|
mState.onLoadKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveKeyboardState() {
|
public void saveKeyboardState() {
|
||||||
mState.onSaveKeyboardState();
|
mState.onSaveKeyboardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(int code, boolean isSinglePointer) {
|
public void onPressKey(final int code, final boolean isSinglePointer) {
|
||||||
mState.onPressKey(code, isSinglePointer, mAutoCapsState);
|
mState.onPressKey(code, isSinglePointer, mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(int code, boolean withSliding) {
|
public void onReleaseKey(final int code, final boolean withSliding) {
|
||||||
mState.onReleaseKey(code, withSliding);
|
mState.onReleaseKey(code, withSliding);
|
||||||
if (mLongPressTimeoutCode == code) {
|
if (mLongPressTimeoutCode == code) {
|
||||||
mLongPressTimeoutCode = 0;
|
mLongPressTimeoutCode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(int code, boolean isSinglePointer) {
|
public void onCodeInput(final int code, final boolean isSinglePointer) {
|
||||||
if (mAutoCapsMode == MockConstants.CAP_MODE_WORDS) {
|
if (mAutoCapsMode == MockConstants.CAP_MODE_WORDS) {
|
||||||
if (Constants.isLetterCode(code)) {
|
if (Constants.isLetterCode(code)) {
|
||||||
mAutoCapsState = (code == MockConstants.CODE_AUTO_CAPS_TRIGGER)
|
mAutoCapsState = (code == MockConstants.CODE_AUTO_CAPS_TRIGGER)
|
||||||
|
@ -196,7 +196,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onCodeInput(code, isSinglePointer, mAutoCapsState);
|
mState.onCodeInput(code, isSinglePointer, mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelInput(boolean isSinglePointer) {
|
public void onCancelInput(final boolean isSinglePointer) {
|
||||||
mState.onCancelInput(isSinglePointer);
|
mState.onCancelInput(isSinglePointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue