Merge "Never include the typed word in recorrections"
commit
2910990065
|
@ -247,7 +247,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
case MSG_RESUME_SUGGESTIONS:
|
||||
latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor(
|
||||
latinIme.mSettings.getCurrent(),
|
||||
msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */,
|
||||
latinIme.mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
||||
break;
|
||||
case MSG_REOPEN_DICTIONARIES:
|
||||
|
@ -288,8 +287,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
sendMessage(obtainMessage(MSG_REOPEN_DICTIONARIES));
|
||||
}
|
||||
|
||||
public void postResumeSuggestions(final boolean shouldIncludeResumedWordInSuggestions,
|
||||
final boolean shouldDelay) {
|
||||
public void postResumeSuggestions(final boolean shouldDelay) {
|
||||
final LatinIME latinIme = getOwnerInstance();
|
||||
if (latinIme == null) {
|
||||
return;
|
||||
|
@ -299,13 +297,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
removeMessages(MSG_RESUME_SUGGESTIONS);
|
||||
if (shouldDelay) {
|
||||
sendMessageDelayed(obtainMessage(MSG_RESUME_SUGGESTIONS,
|
||||
shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
|
||||
0 /* ignored */), mDelayInMillisecondsToUpdateSuggestions);
|
||||
sendMessageDelayed(obtainMessage(MSG_RESUME_SUGGESTIONS),
|
||||
mDelayInMillisecondsToUpdateSuggestions);
|
||||
} else {
|
||||
sendMessage(obtainMessage(MSG_RESUME_SUGGESTIONS,
|
||||
shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
|
||||
0 /* ignored */));
|
||||
sendMessage(obtainMessage(MSG_RESUME_SUGGESTIONS));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,8 +617,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
if (mHandler.hasPendingWaitForDictionaryLoad()) {
|
||||
mHandler.cancelWaitForDictionaryLoad();
|
||||
mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
|
||||
false /* shouldDelay */);
|
||||
mHandler.postResumeSuggestions(false /* shouldDelay */);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -931,8 +925,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// initialSelStart and initialSelEnd sometimes are lying. Make a best effort to
|
||||
// work around this bug.
|
||||
mInputLogic.mConnection.tryFixLyingCursorPosition();
|
||||
mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
|
||||
true /* shouldDelay */);
|
||||
mHandler.postResumeSuggestions(true /* shouldDelay */);
|
||||
needToCallLoadKeyboardLater = false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -435,8 +435,7 @@ public final class InputLogic {
|
|||
// removed.
|
||||
mConnection.removeBackgroundColorFromHighlightedTextIfNecessary();
|
||||
// We moved the cursor. If we are touching a word, we need to resume suggestion.
|
||||
mLatinIME.mHandler.postResumeSuggestions(false /* shouldIncludeResumedWordInSuggestions */,
|
||||
true /* shouldDelay */);
|
||||
mLatinIME.mHandler.postResumeSuggestions(true /* shouldDelay */);
|
||||
// Stop the last recapitalization, if started.
|
||||
mRecapitalizeStatus.stop();
|
||||
return true;
|
||||
|
@ -1186,7 +1185,7 @@ public final class InputLogic {
|
|||
&& !mConnection.isCursorFollowedByWordCharacter(
|
||||
inputTransaction.mSettingsValues.mSpacingAndPunctuations)) {
|
||||
restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues,
|
||||
true /* shouldIncludeResumedWordInSuggestions */, currentKeyboardScriptId);
|
||||
currentKeyboardScriptId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1442,12 +1441,10 @@ public final class InputLogic {
|
|||
* do nothing.
|
||||
*
|
||||
* @param settingsValues the current values of the settings.
|
||||
* @param shouldIncludeResumedWordInSuggestions whether to include the word on which we resume
|
||||
* suggestions in the suggestion list.
|
||||
*/
|
||||
// TODO: make this private.
|
||||
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues,
|
||||
final boolean shouldIncludeResumedWordInSuggestions,
|
||||
// TODO: remove this argument, put it into settingsValues
|
||||
final int currentKeyboardScriptId) {
|
||||
// HACK: We may want to special-case some apps that exhibit bad behavior in case of
|
||||
|
@ -1495,13 +1492,6 @@ public final class InputLogic {
|
|||
if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return;
|
||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
|
||||
final String typedWord = range.mWord.toString();
|
||||
if (shouldIncludeResumedWordInSuggestions) {
|
||||
suggestions.add(new SuggestedWordInfo(typedWord,
|
||||
SuggestedWords.MAX_SUGGESTIONS + 1,
|
||||
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
|
||||
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
|
||||
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
|
||||
}
|
||||
if (!isResumableWord(settingsValues, typedWord)) {
|
||||
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
||||
return;
|
||||
|
@ -1534,7 +1524,7 @@ public final class InputLogic {
|
|||
mConnection.maybeMoveTheCursorAroundAndRestoreToWorkaroundABug();
|
||||
mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor,
|
||||
expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor());
|
||||
if (suggestions.size() <= (shouldIncludeResumedWordInSuggestions ? 1 : 0)) {
|
||||
if (suggestions.size() <= 0) {
|
||||
// If there weren't any suggestion spans on this word, suggestions#size() will be 1
|
||||
// if shouldIncludeResumedWordInSuggestions is true, 0 otherwise. In this case, we
|
||||
// have no useful suggestions, so we will try to compute some for it instead.
|
||||
|
@ -1544,8 +1534,7 @@ public final class InputLogic {
|
|||
public void onGetSuggestedWords(
|
||||
final SuggestedWords suggestedWordsIncludingTypedWord) {
|
||||
final SuggestedWords suggestedWords;
|
||||
if (suggestedWordsIncludingTypedWord.size() > 1
|
||||
&& !shouldIncludeResumedWordInSuggestions) {
|
||||
if (suggestedWordsIncludingTypedWord.size() > 1) {
|
||||
// We were able to compute new suggestions for this word.
|
||||
// Remove the typed word, since we don't want to display it in this
|
||||
// case. The #getSuggestedWordsExcludingTypedWordForRecorrection()
|
||||
|
@ -2198,10 +2187,7 @@ public final class InputLogic {
|
|||
}
|
||||
mConnection.tryFixLyingCursorPosition();
|
||||
if (tryResumeSuggestions) {
|
||||
// This is triggered when starting input anew, so we want to include the resumed
|
||||
// word in suggestions.
|
||||
handler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
|
||||
true /* shouldDelay */);
|
||||
handler.postResumeSuggestions(true /* shouldDelay */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue