Merge "[IL108] Remove some uses of LatinIME in input logic."

This commit is contained in:
Jean Chalard 2014-02-05 08:49:43 +00:00 committed by Android (Google) Code Review
commit a6ea33b4d7
2 changed files with 13 additions and 8 deletions

View file

@ -117,7 +117,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private static final String SCHEME_PACKAGE = "package"; private static final String SCHEME_PACKAGE = "package";
private final Settings mSettings; private final Settings mSettings;
private final InputLogic mInputLogic = new InputLogic(this); private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */,
this /* SuggestionStripViewAccessor */);
private View mExtractArea; private View mExtractArea;
private View mKeyPreviewBackingView; private View mKeyPreviewBackingView;

View file

@ -44,6 +44,7 @@ import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.utils.AsyncResultHolder; import com.android.inputmethod.latin.utils.AsyncResultHolder;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
@ -65,6 +66,7 @@ public final class InputLogic {
// TODO : Remove this member when we can. // TODO : Remove this member when we can.
private final LatinIME mLatinIME; private final LatinIME mLatinIME;
private final SuggestionStripViewAccessor mSuggestionStripViewAccessor;
// Never null. // Never null.
private InputLogicHandler mInputLogicHandler = InputLogicHandler.NULL_HANDLER; private InputLogicHandler mInputLogicHandler = InputLogicHandler.NULL_HANDLER;
@ -94,8 +96,10 @@ public final class InputLogic {
// Find a way to remove it for readability. // Find a way to remove it for readability.
public boolean mIsAutoCorrectionIndicatorOn; public boolean mIsAutoCorrectionIndicatorOn;
public InputLogic(final LatinIME latinIME) { public InputLogic(final LatinIME latinIME,
final SuggestionStripViewAccessor suggestionStripViewAccessor) {
mLatinIME = latinIME; mLatinIME = latinIME;
mSuggestionStripViewAccessor = suggestionStripViewAccessor;
mWordComposer = new WordComposer(); mWordComposer = new WordComposer();
mEventInterpreter = new EventInterpreter(latinIME); mEventInterpreter = new EventInterpreter(latinIME);
mConnection = new RichInputConnection(latinIME); mConnection = new RichInputConnection(latinIME);
@ -638,7 +642,7 @@ public final class InputLogic {
mSpaceState = SpaceState.WEAK; mSpaceState = SpaceState.WEAK;
} }
// In case the "add to dictionary" hint was still displayed. // In case the "add to dictionary" hint was still displayed.
mLatinIME.dismissAddToDictionaryHint(); mSuggestionStripViewAccessor.dismissAddToDictionaryHint();
} }
handler.postUpdateSuggestionStrip(); handler.postUpdateSuggestionStrip();
if (settingsValues.mIsInternal) { if (settingsValues.mIsInternal) {
@ -714,7 +718,7 @@ public final class InputLogic {
if (maybeDoubleSpacePeriod(settingsValues, handler)) { if (maybeDoubleSpacePeriod(settingsValues, handler)) {
keyboardSwitcher.updateShiftState(); keyboardSwitcher.updateShiftState();
mSpaceState = SpaceState.DOUBLE; mSpaceState = SpaceState.DOUBLE;
} else if (!mLatinIME.isShowingPunctuationList()) { } else if (!mSuggestionStripViewAccessor.isShowingPunctuationList()) {
mSpaceState = SpaceState.WEAK; mSpaceState = SpaceState.WEAK;
} }
} }
@ -745,7 +749,7 @@ public final class InputLogic {
// Set punctuation right away. onUpdateSelection will fire but tests whether it is // Set punctuation right away. onUpdateSelection will fire but tests whether it is
// already displayed or not, so it's okay. // already displayed or not, so it's okay.
mLatinIME.setNeutralSuggestionStrip(); mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
} }
keyboardSwitcher.updateShiftState(); keyboardSwitcher.updateShiftState();
@ -1098,7 +1102,7 @@ public final class InputLogic {
} }
if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled) { if (!mWordComposer.isComposingWord() && !settingsValues.mBigramPredictionEnabled) {
mLatinIME.setNeutralSuggestionStrip(); mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
return; return;
} }
@ -1120,7 +1124,7 @@ public final class InputLogic {
final SuggestedWords suggestedWords = holder.get(null, final SuggestedWords suggestedWords = holder.get(null,
Constants.GET_SUGGESTED_WORDS_TIMEOUT); Constants.GET_SUGGESTED_WORDS_TIMEOUT);
if (suggestedWords != null) { if (suggestedWords != null) {
mLatinIME.showSuggestionStrip(suggestedWords); mSuggestionStripViewAccessor.showSuggestionStrip(suggestedWords);
} }
} }
@ -1482,7 +1486,7 @@ public final class InputLogic {
final int newSelStart, final int newSelEnd) { final int newSelStart, final int newSelEnd) {
final boolean shouldFinishComposition = mWordComposer.isComposingWord(); final boolean shouldFinishComposition = mWordComposer.isComposingWord();
resetComposingState(true /* alsoResetLastComposedWord */); resetComposingState(true /* alsoResetLastComposedWord */);
mLatinIME.setNeutralSuggestionStrip(); mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart, newSelEnd, mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart, newSelEnd,
shouldFinishComposition); shouldFinishComposition);
} }