am 8a70e70c: Remove toggleSymbolsShift and rename toggleKeyboardMode
* commit '8a70e70c849cc2c5553c6fd79891c22893fd761b': Remove toggleSymbolsShift and rename toggleKeyboardModemain
commit
1ee3fae10c
|
@ -99,7 +99,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
private static final int SWITCH_STATE_CHORDING_SYMBOL = 6;
|
private static final int SWITCH_STATE_CHORDING_SYMBOL = 6;
|
||||||
private int mSwitchState = SWITCH_STATE_ALPHA;
|
private int mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
|
|
||||||
private static String mLayoutSwitchBackSymbols;
|
private String mLayoutSwitchBackSymbols;
|
||||||
|
|
||||||
private int mThemeIndex = -1;
|
private int mThemeIndex = -1;
|
||||||
private Context mThemeContext;
|
private Context mThemeContext;
|
||||||
|
@ -231,7 +231,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mKeyboardView.setKeyboard(keyboard);
|
mKeyboardView.setKeyboard(keyboard);
|
||||||
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
||||||
mCurrentId = keyboard.mId;
|
mCurrentId = keyboard.mId;
|
||||||
mSwitchState = getSwitchState(mCurrentId);
|
mSwitchState = getSwitchState();
|
||||||
updateShiftLockState(keyboard);
|
updateShiftLockState(keyboard);
|
||||||
mKeyboardView.setKeyPreviewPopupEnabled(
|
mKeyboardView.setKeyPreviewPopupEnabled(
|
||||||
Settings.Values.isKeyPreviewPopupEnabled(mPrefs, mResources),
|
Settings.Values.isKeyPreviewPopupEnabled(mPrefs, mResources),
|
||||||
|
@ -242,8 +242,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
updateShiftState();
|
updateShiftState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getSwitchState(KeyboardId id) {
|
private int getSwitchState() {
|
||||||
return id.equals(mMainKeyboardId) ? SWITCH_STATE_ALPHA : SWITCH_STATE_SYMBOL_BEGIN;
|
return isAlphabetMode() ? SWITCH_STATE_ALPHA : SWITCH_STATE_SYMBOL_BEGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShiftLockState(Keyboard keyboard) {
|
private void updateShiftLockState(Keyboard keyboard) {
|
||||||
|
@ -252,12 +252,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// sticky shift key). To show or dismiss the indicator, we need to call setShiftLocked()
|
// sticky shift key). To show or dismiss the indicator, we need to call setShiftLocked()
|
||||||
// that takes care of the current keyboard having such ALT key or not.
|
// that takes care of the current keyboard having such ALT key or not.
|
||||||
keyboard.setShiftLocked(keyboard.hasShiftLockKey());
|
keyboard.setShiftLocked(keyboard.hasShiftLockKey());
|
||||||
mState.setShiftLocked(keyboard.hasShiftLockKey());
|
|
||||||
} else if (mCurrentId.equals(mSymbolsKeyboardId)) {
|
} else if (mCurrentId.equals(mSymbolsKeyboardId)) {
|
||||||
// Symbol keyboard has an ALT key that has a caps lock style indicator. To disable the
|
// Symbol keyboard has an ALT key that has a caps lock style indicator. To disable the
|
||||||
// indicator, we need to call setShiftLocked(false).
|
// indicator, we need to call setShiftLocked(false).
|
||||||
keyboard.setShiftLocked(false);
|
keyboard.setShiftLocked(false);
|
||||||
mState.setShiftLocked(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +424,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (isAlphabetMode()) {
|
if (isAlphabetMode()) {
|
||||||
setShifted(mState.isShiftedOrShiftLocked() ? UNSHIFT : MANUAL_SHIFT);
|
setShifted(mState.isShiftedOrShiftLocked() ? UNSHIFT : MANUAL_SHIFT);
|
||||||
} else {
|
} else {
|
||||||
toggleShiftInSymbol();
|
toggleShiftInSymbols();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,15 +445,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeKeyboardMode() {
|
public void toggleKeyboardMode() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "changeKeyboardMode: " + mState);
|
Log.d(TAG, "toggleKeyboard: " + mState);
|
||||||
}
|
}
|
||||||
toggleKeyboardMode();
|
toggleAlphabetAndSymbols();
|
||||||
if (mState.isShiftLocked() && isAlphabetMode()) {
|
|
||||||
setShiftLocked(true);
|
|
||||||
}
|
|
||||||
updateShiftState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startIgnoringDoubleTap() {
|
private void startIgnoringDoubleTap() {
|
||||||
|
@ -515,7 +509,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In symbol mode, just toggle symbol and symbol more keyboard.
|
// In symbol mode, just toggle symbol and symbol more keyboard.
|
||||||
toggleShift();
|
toggleShiftInSymbols();
|
||||||
mSwitchState = SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE;
|
mSwitchState = SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE;
|
||||||
}
|
}
|
||||||
mState.onPressShift(isAlphabetMode, isShiftLocked, isAutomaticTemporaryUpperCase,
|
mState.onPressShift(isAlphabetMode, isShiftLocked, isAutomaticTemporaryUpperCase,
|
||||||
|
@ -562,7 +556,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
|
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
|
||||||
// key and another key, then releases the shift key.
|
// key and another key, then releases the shift key.
|
||||||
if (mSwitchState == SWITCH_STATE_CHORDING_SYMBOL) {
|
if (mSwitchState == SWITCH_STATE_CHORDING_SYMBOL) {
|
||||||
toggleShift();
|
toggleShiftInSymbols();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mState.onReleaseShift();
|
mState.onReleaseShift();
|
||||||
|
@ -572,7 +566,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onPressSymbol: " + mState);
|
Log.d(TAG, "onPressSymbol: " + mState);
|
||||||
}
|
}
|
||||||
changeKeyboardMode();
|
toggleAlphabetAndSymbols();
|
||||||
mState.onPressSymbol();
|
mState.onPressSymbol();
|
||||||
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +578,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// 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) {
|
||||||
changeKeyboardMode();
|
toggleAlphabetAndSymbols();
|
||||||
}
|
}
|
||||||
mState.onReleaseSymbol();
|
mState.onReleaseSymbol();
|
||||||
}
|
}
|
||||||
|
@ -600,37 +594,48 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// 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()) {
|
||||||
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
|
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
|
||||||
changeKeyboardMode();
|
toggleAlphabetAndSymbols();
|
||||||
} else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) {
|
} else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) {
|
||||||
toggleShift();
|
toggleShiftInSymbols();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mPrevMainKeyboardWasShiftLocked;
|
private boolean mPrevMainKeyboardWasShiftLocked;
|
||||||
|
|
||||||
private void toggleKeyboardMode() {
|
private void setSymbolsKeyboard() {
|
||||||
if (mCurrentId.equals(mMainKeyboardId)) {
|
|
||||||
mPrevMainKeyboardWasShiftLocked = mState.isShiftLocked();
|
mPrevMainKeyboardWasShiftLocked = mState.isShiftLocked();
|
||||||
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
setKeyboard(getKeyboard(mSymbolsKeyboardId));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
private void setAlphabetKeyboard() {
|
||||||
setKeyboard(getKeyboard(mMainKeyboardId));
|
setKeyboard(getKeyboard(mMainKeyboardId));
|
||||||
setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
setShiftLocked(mPrevMainKeyboardWasShiftLocked);
|
||||||
mPrevMainKeyboardWasShiftLocked = false;
|
mPrevMainKeyboardWasShiftLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleAlphabetAndSymbols() {
|
||||||
|
if (isAlphabetMode()) {
|
||||||
|
setSymbolsKeyboard();
|
||||||
|
} else {
|
||||||
|
setAlphabetKeyboard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleShiftInSymbol() {
|
private boolean isSymbolShifted() {
|
||||||
if (isAlphabetMode())
|
return mCurrentId != null && mCurrentId.equals(mSymbolsShiftedKeyboardId);
|
||||||
return;
|
}
|
||||||
final LatinKeyboard keyboard;
|
|
||||||
if (mCurrentId.equals(mSymbolsKeyboardId)
|
private void setSymbolsShiftedKeyboard() {
|
||||||
|| !mCurrentId.equals(mSymbolsShiftedKeyboardId)) {
|
setKeyboard(getKeyboard(mSymbolsShiftedKeyboardId));
|
||||||
keyboard = getKeyboard(mSymbolsShiftedKeyboardId);
|
}
|
||||||
} else {
|
|
||||||
keyboard = getKeyboard(mSymbolsKeyboardId);
|
private void toggleShiftInSymbols() {
|
||||||
|
if (isSymbolShifted()) {
|
||||||
|
setSymbolsKeyboard();
|
||||||
|
} else {
|
||||||
|
setSymbolsShiftedKeyboard();
|
||||||
}
|
}
|
||||||
setKeyboard(keyboard);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInMomentarySwitchState() {
|
public boolean isInMomentarySwitchState() {
|
||||||
|
@ -654,7 +659,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
return c == Keyboard.CODE_SPACE || c == Keyboard.CODE_ENTER;
|
return c == Keyboard.CODE_SPACE || c == Keyboard.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLayoutSwitchBackCharacter(int c) {
|
private boolean isLayoutSwitchBackCharacter(int c) {
|
||||||
if (TextUtils.isEmpty(mLayoutSwitchBackSymbols)) return false;
|
if (TextUtils.isEmpty(mLayoutSwitchBackSymbols)) return false;
|
||||||
if (mLayoutSwitchBackSymbols.indexOf(c) >= 0) return true;
|
if (mLayoutSwitchBackSymbols.indexOf(c) >= 0) return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -688,7 +693,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// and slid to other key, then released the finger.
|
// and slid to other key, then released the finger.
|
||||||
// If the user cancels the sliding input, snapping back to the previous keyboard
|
// If the user cancels the sliding input, snapping back to the previous keyboard
|
||||||
// mode is handled by {@link #onCancelInput}.
|
// mode is handled by {@link #onCancelInput}.
|
||||||
changeKeyboardMode();
|
toggleAlphabetAndSymbols();
|
||||||
} else {
|
} else {
|
||||||
// Chording input is being started. The keyboard mode will be snapped back to the
|
// Chording input is being started. The keyboard mode will be snapped back to the
|
||||||
// previous mode in {@link onReleaseSymbol} when the mode change key is released.
|
// previous mode in {@link onReleaseSymbol} when the mode change key is released.
|
||||||
|
@ -702,7 +707,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
} else if (isSinglePointer()) {
|
} else if (isSinglePointer()) {
|
||||||
// Snap back to the previous keyboard mode if the user pressed the shift key on
|
// Snap back to the previous keyboard mode if the user pressed the shift key on
|
||||||
// symbol mode and slid to other key, then released the finger.
|
// symbol mode and slid to other key, then released the finger.
|
||||||
toggleShift();
|
toggleShiftInSymbols();
|
||||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||||
} else {
|
} else {
|
||||||
// Chording input is being started. The keyboard mode will be snapped back to the
|
// Chording input is being started. The keyboard mode will be snapped back to the
|
||||||
|
@ -716,7 +721,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
// 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)) {
|
||||||
changeKeyboardMode();
|
setAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_SYMBOL:
|
case SWITCH_STATE_SYMBOL:
|
||||||
|
@ -724,7 +729,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
// 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)) {
|
||||||
changeKeyboardMode();
|
setAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1333,7 +1333,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.changeKeyboardMode();
|
switcher.toggleKeyboardMode();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_CANCEL:
|
case Keyboard.CODE_CANCEL:
|
||||||
|
|
Loading…
Reference in New Issue