am 81e0ca5f: [IL49] Move InputLogic-related init code to InputLogic.

* commit '81e0ca5fd395fd67c7b93e7d87e7d90fa136f065':
  [IL49] Move InputLogic-related init code to InputLogic.
main
Jean Chalard 2013-12-27 03:55:05 -08:00 committed by Android Git Automerger
commit b70d74a3f9
2 changed files with 22 additions and 19 deletions

View File

@ -755,12 +755,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// The app calling setText() has the effect of clearing the composing // The app calling setText() has the effect of clearing the composing
// span, so we should reset our state unconditionally, even if restarting is true. // span, so we should reset our state unconditionally, even if restarting is true.
mInputLogic.mEnteredText = null; mInputLogic.startInput(restarting, editorInfo);
mInputLogic.resetComposingState(true /* alsoResetLastComposedWord */);
mInputLogic.mDeleteCount = 0;
mInputLogic.mSpaceState = SpaceState.NONE;
mInputLogic.mRecapitalizeStatus.deactivate();
mInputLogic.mCurrentlyPressedHardwareKeys.clear();
// Note: the following does a round-trip IPC on the main thread: be careful // Note: the following does a round-trip IPC on the main thread: be careful
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale(); final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
@ -773,11 +768,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// otherwise it will clear the suggestion strip. // otherwise it will clear the suggestion strip.
setPunctuationSuggestions(); setPunctuationSuggestions();
} }
mInputLogic.mSuggestedWords = SuggestedWords.EMPTY;
// Sometimes, while rotating, for some reason the framework tells the app we are not // Sometimes, while rotating, for some reason the framework tells the app we are not
// connected to it and that means we can't refresh the cache. In this case, schedule a // connected to it and that means we can't refresh the cache. In this case, schedule a
// refresh later. // refresh later.
// TODO[IL]: Can the following be moved to InputLogic#startInput?
final boolean canReachInputConnection; final boolean canReachInputConnection;
if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess( if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess(
editorInfo.initialSelStart, editorInfo.initialSelEnd, editorInfo.initialSelStart, editorInfo.initialSelEnd,
@ -824,12 +819,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
setSuggestionStripShownInternal( setSuggestionStripShownInternal(
isSuggestionsStripVisible(), /* needsInputViewShown */ false); isSuggestionsStripVisible(), /* needsInputViewShown */ false);
mInputLogic.mLastSelectionStart = editorInfo.initialSelStart;
mInputLogic.mLastSelectionEnd = editorInfo.initialSelEnd;
// In some cases (namely, after rotation of the device) editorInfo.initialSelStart is lying
// so we try using some heuristics to find out about these and fix them.
mInputLogic.tryFixLyingCursorPosition();
mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelUpdateSuggestionStrip();
mHandler.cancelDoubleSpacePeriodTimer(); mHandler.cancelDoubleSpacePeriodTimer();
@ -873,10 +862,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Remove pending messages related to update suggestions // Remove pending messages related to update suggestions
mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelUpdateSuggestionStrip();
// Should do the following in onFinishInputInternal but until JB MR2 it's not called :( // Should do the following in onFinishInputInternal but until JB MR2 it's not called :(
if (mInputLogic.mWordComposer.isComposingWord()) { mInputLogic.finishInput();
mInputLogic.mConnection.finishComposingText();
}
mInputLogic.resetComposingState(true /* alsoResetLastComposedWord */);
// Notify ResearchLogger // Notify ResearchLogger
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_onFinishInputViewInternal(finishingInput, ResearchLogger.latinIME_onFinishInputViewInternal(finishingInput,

View File

@ -116,9 +116,22 @@ public final class InputLogic {
* some things must not be done (for example, the keyboard should not be reset to the * some things must not be done (for example, the keyboard should not be reset to the
* alphabetic layout), so do not send false to this just in case. * alphabetic layout), so do not send false to this just in case.
* *
* @param restarting whether input is starting in the same field as before. * @param restarting whether input is starting in the same field as before. Unused for now.
* @param editorInfo the editorInfo associated with the editor.
*/ */
public void startInput(final boolean restarting) { public void startInput(final boolean restarting, final EditorInfo editorInfo) {
mEnteredText = null;
resetComposingState(true /* alsoResetLastComposedWord */);
mDeleteCount = 0;
mSpaceState = SpaceState.NONE;
mRecapitalizeStatus.deactivate();
mCurrentlyPressedHardwareKeys.clear();
mSuggestedWords = SuggestedWords.EMPTY;
mLastSelectionStart = editorInfo.initialSelStart;
mLastSelectionEnd = editorInfo.initialSelEnd;
// In some cases (namely, after rotation of the device) editorInfo.initialSelStart is lying
// so we try using some heuristics to find out about these and fix them.
tryFixLyingCursorPosition();
mInputLogicHandler = new InputLogicHandler(); mInputLogicHandler = new InputLogicHandler();
} }
@ -126,6 +139,10 @@ public final class InputLogic {
* Clean up the input logic after input is finished. * Clean up the input logic after input is finished.
*/ */
public void finishInput() { public void finishInput() {
if (mWordComposer.isComposingWord()) {
mConnection.finishComposingText();
}
resetComposingState(true /* alsoResetLastComposedWord */);
mInputLogicHandler.destroy(); mInputLogicHandler.destroy();
mInputLogicHandler = null; mInputLogicHandler = null;
} }