Add KeyboardState.SwitchActions.setAlphabetShiftLockShifted

Change-Id: I6c49d8eb0a8272840ff03e0940d88a31c3d20bd9
main
Tadashi G. Takaoka 2012-01-26 18:25:48 +09:00
parent 736d740aa5
commit 757f8d96ee
5 changed files with 36 additions and 18 deletions

View File

@ -240,6 +240,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
private static final int ALPHABET_MANUAL_SHIFTED = 1;
private static final int ALPHABET_AUTOMATIC_SHIFTED = 2;
private static final int ALPHABET_SHIFT_LOCKED = 3;
private static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4;
// TODO: Remove this method.
private void updateAlphabetKeyboardShiftState(int shiftMode) {
@ -260,6 +261,10 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
case ALPHABET_SHIFT_LOCKED:
keyboard.setShiftLocked(true);
break;
case ALPHABET_SHIFT_LOCK_SHIFTED:
keyboard.setShiftLocked(true);
keyboard.setShifted(true);
break;
}
mKeyboardView.invalidateAllKeys();
if (shiftMode != ALPHABET_SHIFT_LOCKED) {
@ -298,6 +303,13 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
updateAlphabetKeyboardShiftState(ALPHABET_SHIFT_LOCKED);
}
// Implements {@link KeyboardState.SwitchActions}.
@Override
public void setAlphabetShiftLockShiftedKeyboard() {
setKeyboard(mKeyboardSet.getMainKeyboard());
updateAlphabetKeyboardShiftState(ALPHABET_SHIFT_LOCK_SHIFTED);
}
// Implements {@link KeyboardState.SwitchActions}.
@Override
public void setSymbolsKeyboard() {

View File

@ -43,8 +43,7 @@ public class KeyboardState {
public void setAlphabetManualShiftedKeyboard();
public void setAlphabetAutomaticShiftedKeyboard();
public void setAlphabetShiftLockedKeyboard();
// TODO: Add this.
//public void setAlphabetShiftLockShiftedKeyboard();
public void setAlphabetShiftLockShiftedKeyboard();
public void setSymbolsKeyboard();
public void setSymbolsShiftedKeyboard();
@ -157,14 +156,10 @@ public class KeyboardState {
}
}
// TODO: Remove this method.
public boolean isShiftLocked() {
return mAlphabetShiftState.isShiftLocked();
}
private static final int UNSHIFT = 0;
private static final int MANUAL_SHIFT = 1;
private static final int AUTOMATIC_SHIFT = 2;
private static final int SHIFT_LOCK_SHIFTED = 3;
private void setShifted(int shiftMode) {
if (DEBUG_ACTION) {
@ -198,6 +193,10 @@ public class KeyboardState {
mSwitchActions.setAlphabetKeyboard();
}
break;
case SHIFT_LOCK_SHIFTED:
mAlphabetShiftState.setShifted(true);
mSwitchActions.setAlphabetShiftLockShiftedKeyboard();
break;
}
}
@ -349,7 +348,7 @@ public class KeyboardState {
if (mAlphabetShiftState.isShiftLocked()) {
// Shift key is pressed while caps lock state, we will treat this state as shifted
// caps lock state and mark as if shift key pressed while normal state.
setShifted(MANUAL_SHIFT);
setShifted(SHIFT_LOCK_SHIFTED);
mShiftKeyState.onPress();
} else if (mAlphabetShiftState.isAutomaticTemporaryUpperCase()) {
// Shift key is pressed while automatic temporary upper case, we have to move to

View File

@ -40,9 +40,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press shift key and hold, enter into choring shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
pressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED);
// Press/release letter key.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
chordingPressAndReleaseKey('Z', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED);
// Release shift key, switch back to alphabet shift locked.
releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED);

View File

@ -246,13 +246,13 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
}
// Double tap shift key.
@ -265,7 +265,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
secondTapShiftKey(ALPHABET_SHIFT_LOCKED);
// First shift key tap.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Second shift key tap.
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
}
@ -289,7 +289,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Update shift state, remained in alphabet shift locked.
updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -320,7 +320,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Update shift state, remained in alphabet shift locked (not automatic shifted).
updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
@ -375,7 +375,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Alphabet shift locked -> "?123" key + letter -> alphabet shift locked.
// Press and slide from shift key, enter alphabet shifted.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Enter/release letter key, switch back to shift locked.
pressAndReleaseKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
}

View File

@ -40,8 +40,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
public static final int ALPHABET_MANUAL_SHIFTED = 1;
public static final int ALPHABET_AUTOMATIC_SHIFTED = 2;
public static final int ALPHABET_SHIFT_LOCKED = 3;
public static final int SYMBOLS_UNSHIFTED = 4;
public static final int SYMBOLS_SHIFTED = 5;
public static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4;
public static final int SYMBOLS_UNSHIFTED = 5;
public static final int SYMBOLS_SHIFTED = 6;
}
private int mLayout = Constants.ALPHABET_UNSHIFTED;
@ -62,6 +63,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
case Constants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
case Constants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED";
case Constants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED";
case Constants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED";
case Constants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED";
case Constants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED";
default: return "UNKNOWN<" + layoutId + ">";
@ -92,6 +94,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
mLayout = Constants.ALPHABET_SHIFT_LOCKED;
}
@Override
public void setAlphabetShiftLockShiftedKeyboard() {
mLayout = Constants.ALPHABET_SHIFT_LOCK_SHIFTED;
}
@Override
public void setSymbolsKeyboard() {
mLayout = Constants.SYMBOLS_UNSHIFTED;