am 944923f2: Fix: too many calls to getSuggestedWordsForTypingInput

* commit '944923f26660959bfc347c55b66f40de924d3068':
  Fix: too many calls to getSuggestedWordsForTypingInput
main
Jean Chalard 2014-05-29 08:44:55 +00:00 committed by Android Git Automerger
commit 441ae6e8ef
3 changed files with 32 additions and 3 deletions

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;

View File

@ -786,10 +786,11 @@ public final class InputLogic {
final int codePoint = inputTransaction.mEvent.mCodePoint; final int codePoint = inputTransaction.mEvent.mCodePoint;
final SettingsValues settingsValues = inputTransaction.mSettingsValues; final SettingsValues settingsValues = inputTransaction.mSettingsValues;
boolean didAutoCorrect = false; boolean didAutoCorrect = false;
final boolean wasComposingWord = mWordComposer.isComposingWord();
// We avoid sending spaces in languages without spaces if we were composing. // We avoid sending spaces in languages without spaces if we were composing.
final boolean shouldAvoidSendingCode = Constants.CODE_SPACE == codePoint final boolean shouldAvoidSendingCode = Constants.CODE_SPACE == codePoint
&& !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces && !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces
&& mWordComposer.isComposingWord(); && wasComposingWord;
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) { if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection // If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the separator at the current cursor position. // first so that we can insert the separator at the current cursor position.
@ -840,13 +841,16 @@ public final class InputLogic {
if (Constants.CODE_SPACE == codePoint) { if (Constants.CODE_SPACE == codePoint) {
if (maybeDoubleSpacePeriod(inputTransaction)) { if (maybeDoubleSpacePeriod(inputTransaction)) {
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
inputTransaction.setRequiresUpdateSuggestions();
mSpaceState = SpaceState.DOUBLE; mSpaceState = SpaceState.DOUBLE;
} else if (!mSuggestedWords.isPunctuationSuggestions()) { } else if (!mSuggestedWords.isPunctuationSuggestions()) {
mSpaceState = SpaceState.WEAK; mSpaceState = SpaceState.WEAK;
} }
startDoubleSpacePeriodCountdown(inputTransaction); startDoubleSpacePeriodCountdown(inputTransaction);
if (wasComposingWord) {
inputTransaction.setRequiresUpdateSuggestions(); inputTransaction.setRequiresUpdateSuggestions();
}
} else { } else {
if (swapWeakSpace) { if (swapWeakSpace) {
swapSwapperAndSpace(inputTransaction); swapSwapperAndSpace(inputTransaction);
@ -943,6 +947,11 @@ public final class InputLogic {
if (mConnection.revertDoubleSpacePeriod()) { if (mConnection.revertDoubleSpacePeriod()) {
// No need to reset mSpaceState, it has already be done (that's why we // No need to reset mSpaceState, it has already be done (that's why we
// receive it as a parameter) // receive it as a parameter)
inputTransaction.setRequiresUpdateSuggestions();
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
WordComposer.CAPS_MODE_OFF,
getPrevWordsInfoFromNthPreviousWordForSuggestion(
inputTransaction.mSettingsValues.mSpacingAndPunctuations, 1));
return; return;
} }
} else if (SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) { } else if (SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) {

View File

@ -481,6 +481,27 @@ public class InputLogicTests extends InputTestsBase {
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null); suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
} }
public void testPredictionsWithDoubleSpaceToPeriod() {
final String WORD_TO_TYPE = "Barack ";
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// No need to test here, testPredictionsAfterSpace is testing it already
type(" ");
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// Test the predictions have been cleared
SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("predictions cleared after double-space-to-period", suggestedWords.size(), 0);
type(Constants.CODE_DELETE);
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// Test the first prediction is displayed
suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("predictions after cancel double-space-to-period", "Obama",
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
public void testPredictionsAfterManualPick() { public void testPredictionsAfterManualPick() {
final String WORD_TO_TYPE = "Barack"; final String WORD_TO_TYPE = "Barack";
type(WORD_TO_TYPE); type(WORD_TO_TYPE);