[IL135] Make getCurrentAutoCapsState private
Bug: 8636060 Change-Id: I800aefe6fee4c14df6fe5abe21b2387c69abb8f5main
parent
ddc163988a
commit
f091c491ea
|
@ -147,7 +147,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues settingsValues) {
|
public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues settingsValues,
|
||||||
|
final int currentAutoCapsState, final int currentRecapitalizeState) {
|
||||||
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
||||||
mThemeContext, editorInfo);
|
mThemeContext, editorInfo);
|
||||||
final Resources res = mThemeContext.getResources();
|
final Resources res = mThemeContext.getResources();
|
||||||
|
@ -162,7 +163,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mKeyboardLayoutSet = builder.build();
|
mKeyboardLayoutSet = builder.build();
|
||||||
mCurrentSettingsValues = settingsValues;
|
mCurrentSettingsValues = settingsValues;
|
||||||
try {
|
try {
|
||||||
mState.onLoadKeyboard();
|
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale(), mThemeContext);
|
mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale(), mThemeContext);
|
||||||
} 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());
|
||||||
|
@ -221,13 +222,14 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
||||||
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
||||||
public void resetKeyboardStateToAlphabet() {
|
public void resetKeyboardStateToAlphabet(final int currentAutoCapsState,
|
||||||
mState.onResetKeyboardStateToAlphabet();
|
final int currentRecapitalizeState) {
|
||||||
|
mState.onResetKeyboardStateToAlphabet(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(final int code, final boolean isSinglePointer,
|
public void onPressKey(final int code, final boolean isSinglePointer,
|
||||||
final int currentAutoCapsState) {
|
final int currentAutoCapsState, final int currentRecapitalizeState) {
|
||||||
mState.onPressKey(code, isSinglePointer, currentAutoCapsState);
|
mState.onPressKey(code, isSinglePointer, currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(final int code, final boolean withSliding,
|
public void onReleaseKey(final int code, final boolean withSliding,
|
||||||
|
@ -235,8 +237,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onReleaseKey(code, withSliding, currentAutoCapsState, currentRecapitalizeState);
|
mState.onReleaseKey(code, withSliding, currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinishSlidingInput() {
|
public void onFinishSlidingInput(final int currentAutoCapsState,
|
||||||
mState.onFinishSlidingInput();
|
final int currentRecapitalizeState) {
|
||||||
|
mState.onFinishSlidingInput(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
|
@ -297,14 +300,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
setKeyboard(mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS_SHIFTED));
|
setKeyboard(mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS_SHIFTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
|
||||||
// TODO[IL]: merge the two following methods; remove the one without args.
|
|
||||||
@Override
|
|
||||||
public void requestUpdatingShiftState() {
|
|
||||||
mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState(),
|
|
||||||
mLatinIME.getCurrentRecapitalizeState());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Future method for requesting an updating to the shift state.
|
// Future method for requesting an updating to the shift state.
|
||||||
public void requestUpdatingShiftState(final int currentAutoCapsState,
|
public void requestUpdatingShiftState(final int currentAutoCapsState,
|
||||||
final int currentRecapitalizeState) {
|
final int currentRecapitalizeState) {
|
||||||
|
@ -339,8 +334,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
/**
|
/**
|
||||||
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
||||||
*/
|
*/
|
||||||
public void onCodeInput(final int code, final int currentAutoCapsState) {
|
public void onCodeInput(final int code, final int currentAutoCapsState,
|
||||||
mState.onCodeInput(code, currentAutoCapsState);
|
final int currentRecapitalizeState) {
|
||||||
|
mState.onCodeInput(code, currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingEmojiPalettes() {
|
public boolean isShowingEmojiPalettes() {
|
||||||
|
|
|
@ -27,10 +27,10 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
*
|
*
|
||||||
* This class contains all keyboard state transition logic.
|
* This class contains all keyboard state transition logic.
|
||||||
*
|
*
|
||||||
* The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard(int, int)}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean,int,int)},
|
* {@link #onPressKey(int,boolean,int,int)}, {@link #onReleaseKey(int,boolean,int,int)},
|
||||||
* {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()},
|
* {@link #onCodeInput(int,int,int)}, {@link #onFinishSlidingInput(int,int)},
|
||||||
* {@link #onUpdateShiftState(int,int)}, {@link #onResetKeyboardStateToAlphabet()}.
|
* {@link #onUpdateShiftState(int,int)}, {@link #onResetKeyboardStateToAlphabet(int,int)}.
|
||||||
*
|
*
|
||||||
* The actions are {@link SwitchActions}'s methods.
|
* The actions are {@link SwitchActions}'s methods.
|
||||||
*/
|
*/
|
||||||
|
@ -49,8 +49,6 @@ public final class KeyboardState {
|
||||||
public void setSymbolsKeyboard();
|
public void setSymbolsKeyboard();
|
||||||
public void setSymbolsShiftedKeyboard();
|
public void setSymbolsShiftedKeyboard();
|
||||||
|
|
||||||
// Legacy method. TODO: remove the following method.
|
|
||||||
public void requestUpdatingShiftState();
|
|
||||||
/**
|
/**
|
||||||
* Request to call back {@link KeyboardState#onUpdateShiftState(int, int)}.
|
* Request to call back {@link KeyboardState#onUpdateShiftState(int, int)}.
|
||||||
*/
|
*/
|
||||||
|
@ -120,7 +118,8 @@ public final class KeyboardState {
|
||||||
mRecapitalizeMode = RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE;
|
mRecapitalizeMode = RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadKeyboard() {
|
public void onLoadKeyboard(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onLoadKeyboard: " + this);
|
Log.d(TAG, "onLoadKeyboard: " + this);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,7 @@ public final class KeyboardState {
|
||||||
mPrevSymbolsKeyboardWasShifted = false;
|
mPrevSymbolsKeyboardWasShifted = false;
|
||||||
mShiftKeyState.onRelease();
|
mShiftKeyState.onRelease();
|
||||||
mSymbolKeyState.onRelease();
|
mSymbolKeyState.onRelease();
|
||||||
onRestoreKeyboardState();
|
onRestoreKeyboardState(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int UNSHIFT = 0;
|
private static final int UNSHIFT = 0;
|
||||||
|
@ -156,13 +155,14 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRestoreKeyboardState() {
|
private void onRestoreKeyboardState(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
final SavedKeyboardState state = mSavedKeyboardState;
|
final SavedKeyboardState state = mSavedKeyboardState;
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onRestoreKeyboardState: saved=" + state + " " + this);
|
Log.d(TAG, "onRestoreKeyboardState: saved=" + state + " " + this);
|
||||||
}
|
}
|
||||||
if (!state.mIsValid || state.mIsAlphabetMode) {
|
if (!state.mIsValid || state.mIsAlphabetMode) {
|
||||||
setAlphabetKeyboard();
|
setAlphabetKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
} else if (state.mIsEmojiMode) {
|
} else if (state.mIsEmojiMode) {
|
||||||
setEmojiKeyboard();
|
setEmojiKeyboard();
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,8 @@ public final class KeyboardState {
|
||||||
mAlphabetShiftState.setShiftLocked(shiftLocked);
|
mAlphabetShiftState.setShiftLocked(shiftLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleAlphabetAndSymbols() {
|
private void toggleAlphabetAndSymbols(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_ACTION) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "toggleAlphabetAndSymbols: " + this);
|
Log.d(TAG, "toggleAlphabetAndSymbols: " + this);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +255,7 @@ public final class KeyboardState {
|
||||||
mPrevSymbolsKeyboardWasShifted = false;
|
mPrevSymbolsKeyboardWasShifted = false;
|
||||||
} else {
|
} else {
|
||||||
mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted;
|
mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted;
|
||||||
setAlphabetKeyboard();
|
setAlphabetKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
if (mPrevMainKeyboardWasShiftLocked) {
|
if (mPrevMainKeyboardWasShiftLocked) {
|
||||||
setShiftLocked(true);
|
setShiftLocked(true);
|
||||||
}
|
}
|
||||||
|
@ -264,14 +265,15 @@ public final class KeyboardState {
|
||||||
|
|
||||||
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
||||||
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
||||||
private void resetKeyboardStateToAlphabet() {
|
private void resetKeyboardStateToAlphabet(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_ACTION) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "resetKeyboardStateToAlphabet: " + this);
|
Log.d(TAG, "resetKeyboardStateToAlphabet: " + this);
|
||||||
}
|
}
|
||||||
if (mIsAlphabetMode) return;
|
if (mIsAlphabetMode) return;
|
||||||
|
|
||||||
mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted;
|
mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted;
|
||||||
setAlphabetKeyboard();
|
setAlphabetKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
if (mPrevMainKeyboardWasShiftLocked) {
|
if (mPrevMainKeyboardWasShiftLocked) {
|
||||||
setShiftLocked(true);
|
setShiftLocked(true);
|
||||||
}
|
}
|
||||||
|
@ -286,7 +288,8 @@ public final class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAlphabetKeyboard() {
|
private void setAlphabetKeyboard(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_ACTION) {
|
if (DEBUG_ACTION) {
|
||||||
Log.d(TAG, "setAlphabetKeyboard");
|
Log.d(TAG, "setAlphabetKeyboard");
|
||||||
}
|
}
|
||||||
|
@ -297,7 +300,7 @@ public final class KeyboardState {
|
||||||
mIsSymbolShifted = false;
|
mIsSymbolShifted = false;
|
||||||
mRecapitalizeMode = RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE;
|
mRecapitalizeMode = RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE;
|
||||||
mSwitchState = SWITCH_STATE_ALPHA;
|
mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
mSwitchActions.requestUpdatingShiftState();
|
mSwitchActions.requestUpdatingShiftState(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSymbolsKeyboard() {
|
private void setSymbolsKeyboard() {
|
||||||
|
@ -339,10 +342,11 @@ public final class KeyboardState {
|
||||||
mSwitchActions.setEmojiKeyboard();
|
mSwitchActions.setEmojiKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(final int code, final boolean isSinglePointer, final int autoCaps) {
|
public void onPressKey(final int code, final boolean isSinglePointer,
|
||||||
|
final int currentAutoCapsState, final int currentRecapitalizeState) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code) + " single="
|
||||||
+ " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this);
|
+ isSinglePointer + " autoCaps=" + currentAutoCapsState + " " + this);
|
||||||
}
|
}
|
||||||
if (code != Constants.CODE_SHIFT) {
|
if (code != Constants.CODE_SHIFT) {
|
||||||
// Because the double tap shift key timer is to detect two consecutive shift key press,
|
// Because the double tap shift key timer is to detect two consecutive shift key press,
|
||||||
|
@ -354,7 +358,7 @@ public final class KeyboardState {
|
||||||
} else if (code == Constants.CODE_CAPSLOCK) {
|
} else if (code == Constants.CODE_CAPSLOCK) {
|
||||||
// Nothing to do here. See {@link #onReleaseKey(int,boolean)}.
|
// Nothing to do here. See {@link #onReleaseKey(int,boolean)}.
|
||||||
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
onPressSymbol();
|
onPressSymbol(currentAutoCapsState, currentRecapitalizeState);
|
||||||
} else {
|
} else {
|
||||||
mShiftKeyState.onOtherKeyPressed();
|
mShiftKeyState.onOtherKeyPressed();
|
||||||
mSymbolKeyState.onOtherKeyPressed();
|
mSymbolKeyState.onOtherKeyPressed();
|
||||||
|
@ -366,7 +370,8 @@ public final class KeyboardState {
|
||||||
// As for #3, please note that it's required to check even when the auto caps mode is
|
// As for #3, please note that it's required to check even when the auto caps mode is
|
||||||
// off because, for example, we may be in the #1 state within the manual temporary
|
// off because, for example, we may be in the #1 state within the manual temporary
|
||||||
// shifted mode.
|
// shifted mode.
|
||||||
if (!isSinglePointer && mIsAlphabetMode && autoCaps != TextUtils.CAP_MODE_CHARACTERS) {
|
if (!isSinglePointer && mIsAlphabetMode
|
||||||
|
&& currentAutoCapsState != TextUtils.CAP_MODE_CHARACTERS) {
|
||||||
final boolean needsToResetAutoCaps = mAlphabetShiftState.isAutomaticShifted()
|
final boolean needsToResetAutoCaps = mAlphabetShiftState.isAutomaticShifted()
|
||||||
|| (mAlphabetShiftState.isManualShifted() && mShiftKeyState.isReleasing());
|
|| (mAlphabetShiftState.isManualShifted() && mShiftKeyState.isReleasing());
|
||||||
if (needsToResetAutoCaps) {
|
if (needsToResetAutoCaps) {
|
||||||
|
@ -387,21 +392,23 @@ public final class KeyboardState {
|
||||||
} else if (code == Constants.CODE_CAPSLOCK) {
|
} else if (code == Constants.CODE_CAPSLOCK) {
|
||||||
setShiftLocked(!mAlphabetShiftState.isShiftLocked());
|
setShiftLocked(!mAlphabetShiftState.isShiftLocked());
|
||||||
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
onReleaseSymbol(withSliding);
|
onReleaseSymbol(withSliding, currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPressSymbol() {
|
private void onPressSymbol(final int currentAutoCapsState,
|
||||||
toggleAlphabetAndSymbols();
|
final int currentRecapitalizeState) {
|
||||||
|
toggleAlphabetAndSymbols(currentAutoCapsState, currentRecapitalizeState);
|
||||||
mSymbolKeyState.onPress();
|
mSymbolKeyState.onPress();
|
||||||
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onReleaseSymbol(final boolean withSliding) {
|
private void onReleaseSymbol(final boolean withSliding, final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
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.
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols(currentAutoCapsState, currentRecapitalizeState);
|
||||||
} else if (!withSliding) {
|
} else if (!withSliding) {
|
||||||
// If the mode change key is being released without sliding, we should forget the
|
// If the mode change key is being released without sliding, we should forget the
|
||||||
// previous symbols keyboard shift state and simply switch back to symbols layout
|
// previous symbols keyboard shift state and simply switch back to symbols layout
|
||||||
|
@ -422,11 +429,12 @@ public final class KeyboardState {
|
||||||
|
|
||||||
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
// TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout
|
||||||
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
// when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal().
|
||||||
public void onResetKeyboardStateToAlphabet() {
|
public void onResetKeyboardStateToAlphabet(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onResetKeyboardStateToAlphabet: " + this);
|
Log.d(TAG, "onResetKeyboardStateToAlphabet: " + this);
|
||||||
}
|
}
|
||||||
resetKeyboardStateToAlphabet();
|
resetKeyboardStateToAlphabet(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShiftStateForRecapitalize(final int recapitalizeMode) {
|
private void updateShiftStateForRecapitalize(final int recapitalizeMode) {
|
||||||
|
@ -579,20 +587,21 @@ public final class KeyboardState {
|
||||||
mShiftKeyState.onRelease();
|
mShiftKeyState.onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinishSlidingInput() {
|
public void onFinishSlidingInput(final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onFinishSlidingInput: " + this);
|
Log.d(TAG, "onFinishSlidingInput: " + this);
|
||||||
}
|
}
|
||||||
// Switch back to the previous keyboard mode if the user cancels sliding input.
|
// Switch back to the previous keyboard mode if the user cancels sliding input.
|
||||||
switch (mSwitchState) {
|
switch (mSwitchState) {
|
||||||
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols(currentAutoCapsState, currentRecapitalizeState);
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE:
|
case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE:
|
||||||
toggleShiftInSymbols();
|
toggleShiftInSymbols();
|
||||||
break;
|
break;
|
||||||
case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT:
|
case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT:
|
||||||
setAlphabetKeyboard();
|
setAlphabetKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,10 +610,11 @@ public final class KeyboardState {
|
||||||
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(final int code, final int autoCaps) {
|
public void onCodeInput(final int code, final int currentAutoCapsState,
|
||||||
|
final int currentRecapitalizeState) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
||||||
+ " autoCaps=" + autoCaps + " " + this);
|
+ " autoCaps=" + currentAutoCapsState + " " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mSwitchState) {
|
switch (mSwitchState) {
|
||||||
|
@ -640,7 +650,7 @@ public final class KeyboardState {
|
||||||
// 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.
|
// characters followed by a space/enter.
|
||||||
if (isSpaceOrEnter(code)) {
|
if (isSpaceOrEnter(code)) {
|
||||||
toggleAlphabetAndSymbols();
|
toggleAlphabetAndSymbols(currentAutoCapsState, currentRecapitalizeState);
|
||||||
mPrevSymbolsKeyboardWasShifted = false;
|
mPrevSymbolsKeyboardWasShifted = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -648,11 +658,11 @@ public final class KeyboardState {
|
||||||
|
|
||||||
// If the code is a letter, update keyboard shift state.
|
// If the code is a letter, update keyboard shift state.
|
||||||
if (Constants.isLetterCode(code)) {
|
if (Constants.isLetterCode(code)) {
|
||||||
updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
updateAlphabetShiftState(currentAutoCapsState, currentRecapitalizeState);
|
||||||
} else if (code == Constants.CODE_EMOJI) {
|
} else if (code == Constants.CODE_EMOJI) {
|
||||||
setEmojiKeyboard();
|
setEmojiKeyboard();
|
||||||
} else if (code == Constants.CODE_ALPHA_FROM_EMOJI) {
|
} else if (code == Constants.CODE_ALPHA_FROM_EMOJI) {
|
||||||
setAlphabetKeyboard();
|
setAlphabetKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// If we were able to reset the caches, then we can reload the keyboard.
|
// If we were able to reset the caches, then we can reload the keyboard.
|
||||||
// Otherwise, we'll do it when we can.
|
// Otherwise, we'll do it when we can.
|
||||||
latinIme.mKeyboardSwitcher.loadKeyboard(latinIme.getCurrentInputEditorInfo(),
|
latinIme.mKeyboardSwitcher.loadKeyboard(latinIme.getCurrentInputEditorInfo(),
|
||||||
settingsValues);
|
settingsValues, latinIme.getCurrentAutoCapsState(),
|
||||||
|
latinIme.getCurrentAutoCapsState());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +834,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
|
suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
switcher.loadKeyboard(editorInfo, currentSettingsValues);
|
switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
if (!canReachInputConnection) {
|
if (!canReachInputConnection) {
|
||||||
// If we can't reach the input connection, we will call loadKeyboard again later,
|
// If we can't reach the input connection, we will call loadKeyboard again later,
|
||||||
// so we need to save its state now. The call will be done in #retryResetCaches.
|
// so we need to save its state now. The call will be done in #retryResetCaches.
|
||||||
|
@ -842,7 +844,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
} else if (restarting) {
|
} else if (restarting) {
|
||||||
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
|
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
|
||||||
// a keyboard layout set doesn't get reloaded in this method.
|
// a keyboard layout set doesn't get reloaded in this method.
|
||||||
switcher.resetKeyboardStateToAlphabet();
|
switcher.resetKeyboardStateToAlphabet(getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
// In apps like Talk, we come here when the text is sent and the field gets emptied and
|
// In apps like Talk, we come here when the text is sent and the field gets emptied and
|
||||||
// we need to re-evaluate the shift state, but not the whole layout which would be
|
// we need to re-evaluate the shift state, but not the whole layout which would be
|
||||||
// disruptive.
|
// disruptive.
|
||||||
|
@ -1119,17 +1122,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mKeyPreviewBackingView.setVisibility(isFullscreenMode() ? View.GONE : View.VISIBLE);
|
mKeyPreviewBackingView.setVisibility(isFullscreenMode() ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from the KeyboardSwitcher which needs to know auto caps state to display
|
private int getCurrentAutoCapsState() {
|
||||||
// the right layout.
|
|
||||||
// TODO[IL]: Remove this, pass the input logic to the keyboard switcher instead?
|
|
||||||
public int getCurrentAutoCapsState() {
|
|
||||||
return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent());
|
return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from the KeyboardSwitcher which needs to know recaps state to display
|
private int getCurrentRecapitalizeState() {
|
||||||
// the right layout.
|
|
||||||
// TODO[IL]: Remove this, pass the input logic to the keyboard switcher instead?
|
|
||||||
public int getCurrentRecapitalizeState() {
|
|
||||||
return mInputLogic.getCurrentRecapitalizeState();
|
return mInputLogic.getCurrentRecapitalizeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1255,7 +1252,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
||||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||||
updateStateAfterInputTransaction(completeInputTransaction);
|
updateStateAfterInputTransaction(completeInputTransaction);
|
||||||
mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState());
|
mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper method to split the code point and the key code. Ultimately, they should not be
|
// A helper method to split the code point and the key code. Ultimately, they should not be
|
||||||
|
@ -1282,7 +1280,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler);
|
mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler);
|
||||||
mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
||||||
getCurrentRecapitalizeState());
|
getCurrentRecapitalizeState());
|
||||||
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState());
|
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1320,7 +1319,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
@Override
|
@Override
|
||||||
public void onFinishSlidingInput() {
|
public void onFinishSlidingInput() {
|
||||||
// User finished sliding input.
|
// User finished sliding input.
|
||||||
mKeyboardSwitcher.onFinishSlidingInput();
|
mKeyboardSwitcher.onFinishSlidingInput(getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from PointerTracker through the KeyboardActionListener interface
|
// Called from PointerTracker through the KeyboardActionListener interface
|
||||||
|
@ -1509,7 +1509,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
loadSettings();
|
loadSettings();
|
||||||
if (mKeyboardSwitcher.getMainKeyboardView() != null) {
|
if (mKeyboardSwitcher.getMainKeyboardView() != null) {
|
||||||
// Reload keyboard because the current language has been changed.
|
// Reload keyboard because the current language has been changed.
|
||||||
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSettings.getCurrent());
|
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSettings.getCurrent(),
|
||||||
|
getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,7 +1567,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
@Override
|
@Override
|
||||||
public void onPressKey(final int primaryCode, final int repeatCount,
|
public void onPressKey(final int primaryCode, final int repeatCount,
|
||||||
final boolean isSinglePointer) {
|
final boolean isSinglePointer) {
|
||||||
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer, getCurrentAutoCapsState());
|
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer, getCurrentAutoCapsState(),
|
||||||
|
getCurrentRecapitalizeState());
|
||||||
hapticAndAudioFeedback(primaryCode, repeatCount);
|
hapticAndAudioFeedback(primaryCode, repeatCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,11 +124,6 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
// Just ignore.
|
// Just ignore.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestUpdatingShiftState() {
|
|
||||||
mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestUpdatingShiftState(final int currentAutoCapsState,
|
public void requestUpdatingShiftState(final int currentAutoCapsState,
|
||||||
final int currentRecapitalizeState) {
|
final int currentRecapitalizeState) {
|
||||||
|
@ -155,7 +150,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKeyboard() {
|
public void loadKeyboard() {
|
||||||
mState.onLoadKeyboard();
|
mState.onLoadKeyboard(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveKeyboardState() {
|
public void saveKeyboardState() {
|
||||||
|
@ -163,7 +158,8 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPressKey(final int code, final boolean isSinglePointer) {
|
public void onPressKey(final int code, final boolean isSinglePointer) {
|
||||||
mState.onPressKey(code, isSinglePointer, mAutoCapsState);
|
mState.onPressKey(code, isSinglePointer, mAutoCapsState,
|
||||||
|
RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReleaseKey(final int code, final boolean withSliding) {
|
public void onReleaseKey(final int code, final boolean withSliding) {
|
||||||
|
@ -187,10 +183,10 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
} else {
|
} else {
|
||||||
mAutoCapsState = mAutoCapsMode;
|
mAutoCapsState = mAutoCapsMode;
|
||||||
}
|
}
|
||||||
mState.onCodeInput(code, mAutoCapsState);
|
mState.onCodeInput(code, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinishSlidingInput() {
|
public void onFinishSlidingInput() {
|
||||||
mState.onFinishSlidingInput();
|
mState.onFinishSlidingInput(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue