am 036930e8: Merge "[IL33] Opportunistically remove some KeyboardSwitcher"

* commit '036930e80dd040ba045244ff05375f4f1c0eb348':
  [IL33] Opportunistically remove some KeyboardSwitcher
main
Jean Chalard 2013-12-23 22:30:27 -08:00 committed by Android Git Automerger
commit d064a55ef6
2 changed files with 20 additions and 22 deletions

View File

@ -1246,7 +1246,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Called from PointerTracker through the KeyboardActionListener interface // Called from PointerTracker through the KeyboardActionListener interface
@Override @Override
public void onTextInput(final String rawText) { public void onTextInput(final String rawText) {
mInputLogic.onTextInput(mSettings.getCurrent(), rawText, mKeyboardSwitcher, mHandler); mInputLogic.onTextInput(mSettings.getCurrent(), rawText, mHandler);
mKeyboardSwitcher.updateShiftState();
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT);
} }
@Override @Override

View File

@ -137,8 +137,8 @@ public final class InputLogic {
* @param rawText the text to input. * @param rawText the text to input.
*/ */
public void onTextInput(final SettingsValues settingsValues, final String rawText, public void onTextInput(final SettingsValues settingsValues, final String rawText,
// TODO: remove these arguments // TODO: remove this argument
final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) { final LatinIME.UIHandler handler) {
mConnection.beginBatchEdit(); mConnection.beginBatchEdit();
if (mWordComposer.isComposingWord()) { if (mWordComposer.isComposingWord()) {
commitCurrentAutoCorrection(settingsValues, rawText, handler); commitCurrentAutoCorrection(settingsValues, rawText, handler);
@ -162,8 +162,6 @@ public final class InputLogic {
mConnection.endBatchEdit(); mConnection.endBatchEdit();
// Space state must be updated before calling updateShiftState // Space state must be updated before calling updateShiftState
mSpaceState = SpaceState.NONE; mSpaceState = SpaceState.NONE;
keyboardSwitcher.updateShiftState();
keyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT);
mEnteredText = text; mEnteredText = text;
} }
@ -221,7 +219,8 @@ public final class InputLogic {
if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) { if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
// TODO: Instead of checking for alphabetic keyboard here, separate keycodes for // TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
// alphabetic shift and shift while in symbol layout. // alphabetic shift and shift while in symbol layout.
performRecapitalization(settingsValues, keyboardSwitcher); performRecapitalization(settingsValues);
keyboardSwitcher.updateShiftState();
} }
break; break;
case Constants.CODE_CAPSLOCK: case Constants.CODE_CAPSLOCK:
@ -347,7 +346,7 @@ public final class InputLogic {
} }
mConnection.endBatchEdit(); mConnection.endBatchEdit();
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
getActualCapsMode(settingsValues, keyboardSwitcher), getActualCapsMode(settingsValues, keyboardSwitcher.getKeyboardShiftMode()),
// Prev word is 1st word before cursor // Prev word is 1st word before cursor
getNthPreviousWordForSuggestion(settingsValues, 1 /* nthPreviousWord */)); getNthPreviousWordForSuggestion(settingsValues, 1 /* nthPreviousWord */));
} }
@ -385,7 +384,8 @@ public final class InputLogic {
mSpaceState = SpaceState.PHANTOM; mSpaceState = SpaceState.PHANTOM;
keyboardSwitcher.updateShiftState(); keyboardSwitcher.updateShiftState();
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
getActualCapsMode(settingsValues, keyboardSwitcher), commitParts[0]); getActualCapsMode(settingsValues,
keyboardSwitcher.getKeyboardShiftMode()), commitParts[0]);
++mAutoCommitSequenceNumber; ++mAutoCommitSequenceNumber;
} }
} }
@ -533,7 +533,7 @@ public final class InputLogic {
// We pass 1 to getPreviousWordForSuggestion because we were not composing a word // We pass 1 to getPreviousWordForSuggestion because we were not composing a word
// yet, so the word we want is the 1st word before the cursor. // yet, so the word we want is the 1st word before the cursor.
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
getActualCapsMode(settingsValues, keyboardSwitcher), getActualCapsMode(settingsValues, keyboardSwitcher.getKeyboardShiftMode()),
getNthPreviousWordForSuggestion(settingsValues, 1 /* nthPreviousWord */)); getNthPreviousWordForSuggestion(settingsValues, 1 /* nthPreviousWord */));
} }
mConnection.setComposingText(getTextWithUnderline( mConnection.setComposingText(getTextWithUnderline(
@ -609,7 +609,8 @@ public final class InputLogic {
if (Constants.CODE_SPACE == codePoint) { if (Constants.CODE_SPACE == codePoint) {
if (settingsValues.isSuggestionsRequested()) { if (settingsValues.isSuggestionsRequested()) {
if (maybeDoubleSpacePeriod(settingsValues, keyboardSwitcher, handler)) { if (maybeDoubleSpacePeriod(settingsValues, handler)) {
keyboardSwitcher.updateShiftState();
mSpaceState = SpaceState.DOUBLE; mSpaceState = SpaceState.DOUBLE;
} else if (!mLatinIME.isShowingPunctuationList()) { } else if (!mLatinIME.isShowingPunctuationList()) {
mSpaceState = SpaceState.WEAK; mSpaceState = SpaceState.WEAK;
@ -866,8 +867,8 @@ public final class InputLogic {
* @return true if we applied the double-space-to-period transformation, false otherwise. * @return true if we applied the double-space-to-period transformation, false otherwise.
*/ */
private boolean maybeDoubleSpacePeriod(final SettingsValues settingsValues, private boolean maybeDoubleSpacePeriod(final SettingsValues settingsValues,
// TODO: remove these arguments // TODO: remove this argument
final KeyboardSwitcher keyboardSwitcher, final LatinIME.UIHandler handler) { final LatinIME.UIHandler handler) {
if (!settingsValues.mUseDoubleSpacePeriod) return false; if (!settingsValues.mUseDoubleSpacePeriod) return false;
if (!handler.isAcceptingDoubleSpacePeriod()) return false; if (!handler.isAcceptingDoubleSpacePeriod()) return false;
// We only do this when we see two spaces and an accepted code point before the cursor. // We only do this when we see two spaces and an accepted code point before the cursor.
@ -895,7 +896,6 @@ public final class InputLogic {
false /* isBatchMode */); false /* isBatchMode */);
} }
mWordComposer.discardPreviousWordForSuggestion(); mWordComposer.discardPreviousWordForSuggestion();
keyboardSwitcher.updateShiftState();
return true; return true;
} }
return false; return false;
@ -931,9 +931,7 @@ public final class InputLogic {
* Performs a recapitalization event. * Performs a recapitalization event.
* @param settingsValues The current settings values. * @param settingsValues The current settings values.
*/ */
private void performRecapitalization(final SettingsValues settingsValues, private void performRecapitalization(final SettingsValues settingsValues) {
// TODO: remove this argument.
final KeyboardSwitcher keyboardSwitcher) {
if (mLastSelectionStart == mLastSelectionEnd) { if (mLastSelectionStart == mLastSelectionEnd) {
return; // No selection return; // No selection
} }
@ -966,8 +964,6 @@ public final class InputLogic {
mLastSelectionStart = mRecapitalizeStatus.getNewCursorStart(); mLastSelectionStart = mRecapitalizeStatus.getNewCursorStart();
mLastSelectionEnd = mRecapitalizeStatus.getNewCursorEnd(); mLastSelectionEnd = mRecapitalizeStatus.getNewCursorEnd();
mConnection.setSelection(mLastSelectionStart, mLastSelectionEnd); mConnection.setSelection(mLastSelectionStart, mLastSelectionEnd);
// Match the keyboard to the new state.
keyboardSwitcher.updateShiftState();
} }
private String performAdditionToUserHistoryDictionary(final SettingsValues settingsValues, private String performAdditionToUserHistoryDictionary(final SettingsValues settingsValues,
@ -1236,12 +1232,12 @@ public final class InputLogic {
/** /**
* Factor in auto-caps and manual caps and compute the current caps mode. * Factor in auto-caps and manual caps and compute the current caps mode.
* @param settingsValues the current settings values. * @param settingsValues the current settings values.
* @param keyboardSwitcher the keyboard switcher. Caps mode depends on its mode. * @param keyboardShiftMode the current shift mode of the keyboard. See
* KeyboardSwitcher#getKeyboardShiftMode() for possible values.
* @return the actual caps mode the keyboard is in right now. * @return the actual caps mode the keyboard is in right now.
*/ */
public int getActualCapsMode(final SettingsValues settingsValues, private int getActualCapsMode(final SettingsValues settingsValues,
final KeyboardSwitcher keyboardSwitcher) { final int keyboardShiftMode) {
final int keyboardShiftMode = keyboardSwitcher.getKeyboardShiftMode();
if (keyboardShiftMode != WordComposer.CAPS_MODE_AUTO_SHIFTED) return keyboardShiftMode; if (keyboardShiftMode != WordComposer.CAPS_MODE_AUTO_SHIFTED) return keyboardShiftMode;
final int auto = getCurrentAutoCapsState(settingsValues); final int auto = getCurrentAutoCapsState(settingsValues);
if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) { if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) {