am a76c62e9: Merge "Remove direct calls of setKeyboardXXX from KeyboardSwitcher"
* commit 'a76c62e92d76d876619e721633ce8f86dd1700c3': Remove direct calls of setKeyboardXXX from KeyboardSwitchermain
commit
d657c180bf
|
@ -164,7 +164,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
mKeyboardView.setKeyboard(keyboard);
|
mKeyboardView.setKeyboard(keyboard);
|
||||||
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
||||||
mCurrentId = keyboard.mId;
|
mCurrentId = keyboard.mId;
|
||||||
mState.onSetKeyboard(isAlphabetMode());
|
|
||||||
updateShiftLockState(keyboard);
|
updateShiftLockState(keyboard);
|
||||||
mKeyboardView.setKeyPreviewPopupEnabled(
|
mKeyboardView.setKeyPreviewPopupEnabled(
|
||||||
SettingsValues.isKeyPreviewPopupEnabled(mPrefs, mResources),
|
SettingsValues.isKeyPreviewPopupEnabled(mPrefs, mResources),
|
||||||
|
@ -362,15 +361,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleShift: " + mState);
|
Log.d(TAG, "toggleShift: " + mState);
|
||||||
}
|
}
|
||||||
if (isAlphabetMode()) {
|
mState.onToggleShift(isAlphabetMode(), isSymbolShifted());
|
||||||
setShifted(mState.isShiftedOrShiftLocked() ? UNSHIFT : MANUAL_SHIFT);
|
|
||||||
} else {
|
|
||||||
if (isSymbolShifted()) {
|
|
||||||
setSymbolsKeyboard();
|
|
||||||
} else {
|
|
||||||
setSymbolsShiftedKeyboard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -380,31 +371,17 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleCapsLock: " + mState);
|
Log.d(TAG, "toggleCapsLock: " + mState);
|
||||||
}
|
}
|
||||||
if (isAlphabetMode()) {
|
mState.onToggleCapsLock(isAlphabetMode());
|
||||||
if (mState.isShiftLocked()) {
|
|
||||||
setShiftLocked(false);
|
|
||||||
// TODO: Remove this.
|
|
||||||
// Shift key is long pressed while caps lock state, we will toggle back to normal
|
|
||||||
// state. And mark as if shift key is released.
|
|
||||||
mState.onReleaseCapsLock();
|
|
||||||
} else {
|
|
||||||
setShiftLocked(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle keyboard mode triggered by user touch event.
|
* Toggle between alphabet and symbols modes triggered by user touch event.
|
||||||
*/
|
*/
|
||||||
public void toggleKeyboardMode() {
|
public void toggleAlphabetAndSymbols() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "toggleKeyboardMode: " + mState);
|
Log.d(TAG, "toggleAlphabetAndSymbols: " + mState);
|
||||||
}
|
|
||||||
if (isAlphabetMode()) {
|
|
||||||
setSymbolsKeyboard();
|
|
||||||
} else {
|
|
||||||
setAlphabetKeyboard();
|
|
||||||
}
|
}
|
||||||
|
mState.onToggleAlphabetAndSymbols(isAlphabetMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -464,7 +441,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsKeyboard() {
|
public void setSymbolsKeyboard() {
|
||||||
mState.onSaveShiftLockState();
|
|
||||||
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +448,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetKeyboard() {
|
public void setAlphabetKeyboard() {
|
||||||
setKeyboard(getKeyboard(mMainKeyboardId));
|
setKeyboard(getKeyboard(mMainKeyboardId));
|
||||||
mState.onRestoreShiftLockState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method
|
// TODO: Remove this method
|
||||||
|
|
|
@ -105,12 +105,12 @@ public class KeyboardState {
|
||||||
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
+ " shiftLocked=" + state.mIsShiftLocked + " shift=" + state.mIsShifted);
|
||||||
}
|
}
|
||||||
if (!state.mIsValid || state.mIsAlphabetMode) {
|
if (!state.mIsValid || state.mIsAlphabetMode) {
|
||||||
mSwitchActions.setAlphabetKeyboard();
|
setAlphabetKeyboard();
|
||||||
} else {
|
} else {
|
||||||
if (state.mIsShifted) {
|
if (state.mIsShifted) {
|
||||||
mSwitchActions.setSymbolsShiftedKeyboard();
|
setSymbolsShiftedKeyboard();
|
||||||
} else {
|
} else {
|
||||||
mSwitchActions.setSymbolsKeyboard();
|
setSymbolsKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +126,6 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get rid of this method
|
|
||||||
public void onSetKeyboard(boolean isAlphabetMode) {
|
|
||||||
mSwitchState = isAlphabetMode ? SWITCH_STATE_ALPHA : SWITCH_STATE_SYMBOL_BEGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShiftLocked() {
|
public boolean isShiftLocked() {
|
||||||
return mKeyboardShiftState.isShiftLocked();
|
return mKeyboardShiftState.isShiftLocked();
|
||||||
}
|
}
|
||||||
|
@ -172,32 +167,36 @@ public class KeyboardState {
|
||||||
|
|
||||||
private void toggleAlphabetAndSymbols(boolean isAlphabetMode) {
|
private void toggleAlphabetAndSymbols(boolean isAlphabetMode) {
|
||||||
if (isAlphabetMode) {
|
if (isAlphabetMode) {
|
||||||
mSwitchActions.setSymbolsKeyboard();
|
setSymbolsKeyboard();
|
||||||
} else {
|
} else {
|
||||||
mSwitchActions.setAlphabetKeyboard();
|
setAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleShiftInSymbols(boolean isSymbolShifted) {
|
private void toggleShiftInSymbols(boolean isSymbolShifted) {
|
||||||
if (isSymbolShifted) {
|
if (isSymbolShifted) {
|
||||||
mSwitchActions.setSymbolsKeyboard();
|
setSymbolsKeyboard();
|
||||||
} else {
|
} else {
|
||||||
mSwitchActions.setSymbolsShiftedKeyboard();
|
setSymbolsShiftedKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRestoreShiftLockState() {
|
private void setAlphabetKeyboard() {
|
||||||
|
mSwitchActions.setAlphabetKeyboard();
|
||||||
|
mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
mSwitchActions.setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
mSwitchActions.setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
||||||
mPrevMainKeyboardWasShiftLocked = false;
|
mPrevMainKeyboardWasShiftLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSaveShiftLockState() {
|
private void setSymbolsKeyboard() {
|
||||||
mPrevMainKeyboardWasShiftLocked = isShiftLocked();
|
mPrevMainKeyboardWasShiftLocked = isShiftLocked();
|
||||||
|
mSwitchActions.setSymbolsKeyboard();
|
||||||
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method.
|
private void setSymbolsShiftedKeyboard() {
|
||||||
public void onReleaseCapsLock() {
|
mSwitchActions.setSymbolsShiftedKeyboard();
|
||||||
mShiftKeyState.onRelease();
|
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get rid of isAlphabetMode argument.
|
// TODO: Get rid of isAlphabetMode argument.
|
||||||
|
@ -384,7 +383,7 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
// Snap back to alpha keyboard mode immediately if user types a quote character.
|
// Snap back to alpha keyboard mode immediately if user types a quote character.
|
||||||
if (isLayoutSwitchBackCharacter(code)) {
|
if (isLayoutSwitchBackCharacter(code)) {
|
||||||
mSwitchActions.setAlphabetKeyboard();
|
setAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_SYMBOL:
|
case SWITCH_STATE_SYMBOL:
|
||||||
|
@ -392,12 +391,41 @@ public class KeyboardState {
|
||||||
// Snap back to alpha keyboard mode if user types one or more non-space/enter
|
// Snap back to alpha keyboard mode if user types one or more non-space/enter
|
||||||
// characters followed by a space/enter or a quote character.
|
// characters followed by a space/enter or a quote character.
|
||||||
if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) {
|
if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) {
|
||||||
mSwitchActions.setAlphabetKeyboard();
|
setAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Get rid of isAlphabetMode and isSymbolShifted arguments.
|
||||||
|
public void onToggleShift(boolean isAlphabetMode, boolean isSymbolShifted) {
|
||||||
|
if (isAlphabetMode) {
|
||||||
|
mSwitchActions.setShifted(
|
||||||
|
isShiftedOrShiftLocked() ? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT);
|
||||||
|
} else {
|
||||||
|
toggleShiftInSymbols(isSymbolShifted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Get rid of isAlphabetMode arguments.
|
||||||
|
public void onToggleCapsLock(boolean isAlphabetMode) {
|
||||||
|
if (isAlphabetMode) {
|
||||||
|
if (isShiftLocked()) {
|
||||||
|
mSwitchActions.setShiftLocked(false);
|
||||||
|
// Shift key is long pressed while caps lock state, we will toggle back to normal
|
||||||
|
// state. And mark as if shift key is released.
|
||||||
|
mShiftKeyState.onRelease();
|
||||||
|
} else {
|
||||||
|
mSwitchActions.setShiftLocked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Get rid of isAlphabetMode arguments.
|
||||||
|
public void onToggleAlphabetAndSymbols(boolean isAlphabetMode) {
|
||||||
|
toggleAlphabetAndSymbols(isAlphabetMode);
|
||||||
|
}
|
||||||
|
|
||||||
private static String switchStateToString(int switchState) {
|
private static String switchStateToString(int switchState) {
|
||||||
switch (switchState) {
|
switch (switchState) {
|
||||||
case SWITCH_STATE_ALPHA: return "ALPHA";
|
case SWITCH_STATE_ALPHA: return "ALPHA";
|
||||||
|
|
|
@ -1335,7 +1335,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
// Symbol key is handled in onPress() when device has distinct multi-touch panel.
|
// Symbol key is handled in onPress() when device has distinct multi-touch panel.
|
||||||
if (!distinctMultiTouch) {
|
if (!distinctMultiTouch) {
|
||||||
switcher.toggleKeyboardMode();
|
switcher.toggleAlphabetAndSymbols();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_CANCEL:
|
case Keyboard.CODE_CANCEL:
|
||||||
|
|
Loading…
Reference in New Issue