Merge "Fix a bug where suggestions would not be updated."
commit
1b3a142cac
|
@ -330,7 +330,13 @@ public final class InputLogic {
|
||||||
// Another option would be to send suggestions each time we set the composing
|
// Another option would be to send suggestions each time we set the composing
|
||||||
// text, but that is probably too expensive to do, so we decided to leave things
|
// text, but that is probably too expensive to do, so we decided to leave things
|
||||||
// as is.
|
// as is.
|
||||||
resetEntireInputState(settingsValues, newSelStart, newSelEnd);
|
// Also, we're posting a resume suggestions message, and this will update the
|
||||||
|
// suggestions strip in a few milliseconds, so if we cleared the suggestion strip here
|
||||||
|
// we'd have the suggestion strip noticeably janky. To avoid that, we don't clear
|
||||||
|
// it here, which means we'll keep outdated suggestions for a split second but the
|
||||||
|
// visual result is better.
|
||||||
|
resetEntireInputState(settingsValues, newSelStart, newSelEnd,
|
||||||
|
false /* clearSuggestionStrip */);
|
||||||
} else {
|
} else {
|
||||||
// resetEntireInputState calls resetCachesUponCursorMove, but forcing the
|
// resetEntireInputState calls resetCachesUponCursorMove, but forcing the
|
||||||
// composition to end. But in all cases where we don't reset the entire input
|
// composition to end. But in all cases where we don't reset the entire input
|
||||||
|
@ -498,7 +504,7 @@ public final class InputLogic {
|
||||||
// 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 batch input at the current cursor position.
|
// first so that we can insert the batch input at the current cursor position.
|
||||||
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
||||||
mConnection.getExpectedSelectionEnd());
|
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
|
||||||
} else if (wordComposerSize <= 1) {
|
} else if (wordComposerSize <= 1) {
|
||||||
// We auto-correct the previous (typed, not gestured) string iff it's one character
|
// We auto-correct the previous (typed, not gestured) string iff it's one character
|
||||||
// long. The reason for this is, even in the middle of gesture typing, you'll still
|
// long. The reason for this is, even in the middle of gesture typing, you'll still
|
||||||
|
@ -651,7 +657,7 @@ public final class InputLogic {
|
||||||
// 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 character at the current cursor position.
|
// first so that we can insert the character at the current cursor position.
|
||||||
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
||||||
mConnection.getExpectedSelectionEnd());
|
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
|
||||||
} else {
|
} else {
|
||||||
commitTyped(settingsValues, LastComposedWord.NOT_A_SEPARATOR);
|
commitTyped(settingsValues, LastComposedWord.NOT_A_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
@ -693,7 +699,7 @@ public final class InputLogic {
|
||||||
// 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 character at the current cursor position.
|
// first so that we can insert the character at the current cursor position.
|
||||||
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
||||||
mConnection.getExpectedSelectionEnd());
|
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
|
||||||
isComposingWord = false;
|
isComposingWord = false;
|
||||||
}
|
}
|
||||||
// We want to find out whether to start composing a new word with this character. If so,
|
// We want to find out whether to start composing a new word with this character. If so,
|
||||||
|
@ -775,7 +781,7 @@ public final class InputLogic {
|
||||||
// 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.
|
||||||
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
||||||
mConnection.getExpectedSelectionEnd());
|
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
|
||||||
}
|
}
|
||||||
// isComposingWord() may have changed since we stored wasComposing
|
// isComposingWord() may have changed since we stored wasComposing
|
||||||
if (mWordComposer.isComposingWord()) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
|
@ -881,7 +887,7 @@ public final class InputLogic {
|
||||||
// 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 remove the character at the current cursor position.
|
// first so that we can remove the character at the current cursor position.
|
||||||
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
resetEntireInputState(settingsValues, mConnection.getExpectedSelectionStart(),
|
||||||
mConnection.getExpectedSelectionEnd());
|
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
|
||||||
// When we exit this if-clause, mWordComposer.isComposingWord() will return false.
|
// When we exit this if-clause, mWordComposer.isComposingWord() will return false.
|
||||||
}
|
}
|
||||||
if (mWordComposer.isComposingWord()) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
|
@ -1252,18 +1258,28 @@ public final class InputLogic {
|
||||||
// HACK: We may want to special-case some apps that exhibit bad behavior in case of
|
// HACK: We may want to special-case some apps that exhibit bad behavior in case of
|
||||||
// recorrection. This is a temporary, stopgap measure that will be removed later.
|
// recorrection. This is a temporary, stopgap measure that will be removed later.
|
||||||
// TODO: remove this.
|
// TODO: remove this.
|
||||||
if (settingsValues.isBrokenByRecorrection()) return;
|
if (settingsValues.isBrokenByRecorrection()
|
||||||
// Recorrection is not supported in languages without spaces because we don't know
|
// Recorrection is not supported in languages without spaces because we don't know
|
||||||
// how to segment them yet.
|
// how to segment them yet.
|
||||||
if (!settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces) return;
|
|| !settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces
|
||||||
// If no suggestions are requested, don't try restarting suggestions.
|
// If no suggestions are requested, don't try restarting suggestions.
|
||||||
if (!settingsValues.isSuggestionsRequested()) return;
|
|| !settingsValues.isSuggestionsRequested()
|
||||||
// If the cursor is not touching a word, or if there is a selection, return right away.
|
// If the cursor is not touching a word, or if there is a selection, return right away.
|
||||||
if (mConnection.hasSelection()) return;
|
|| mConnection.hasSelection()
|
||||||
// If we don't know the cursor location, return.
|
// If we don't know the cursor location, return.
|
||||||
if (mConnection.getExpectedSelectionStart() < 0) return;
|
|| mConnection.getExpectedSelectionStart() < 0) {
|
||||||
|
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int expectedCursorPosition = mConnection.getExpectedSelectionStart();
|
final int expectedCursorPosition = mConnection.getExpectedSelectionStart();
|
||||||
if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations)) return;
|
if (!mConnection.isCursorTouchingWord(settingsValues.mSpacingAndPunctuations)) {
|
||||||
|
// Show predictions.
|
||||||
|
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
|
||||||
|
WordComposer.CAPS_MODE_OFF,
|
||||||
|
getNthPreviousWordForSuggestion(settingsValues.mSpacingAndPunctuations, 1));
|
||||||
|
mLatinIME.mHandler.postUpdateSuggestionStrip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final TextRange range = mConnection.getWordRangeAtCursor(
|
final TextRange range = mConnection.getWordRangeAtCursor(
|
||||||
settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,
|
settingsValues.mSpacingAndPunctuations.mSortedWordSeparators,
|
||||||
0 /* additionalPrecedingWordsCount */);
|
0 /* additionalPrecedingWordsCount */);
|
||||||
|
@ -1606,14 +1622,17 @@ public final class InputLogic {
|
||||||
* @param settingsValues the current values of the settings.
|
* @param settingsValues the current values of the settings.
|
||||||
* @param newSelStart the new selection start, in java characters.
|
* @param newSelStart the new selection start, in java characters.
|
||||||
* @param newSelEnd the new selection end, in java characters.
|
* @param newSelEnd the new selection end, in java characters.
|
||||||
|
* @param clearSuggestionStrip whether this method should clear the suggestion strip.
|
||||||
*/
|
*/
|
||||||
// TODO: how is this different from startInput ?!
|
// TODO: how is this different from startInput ?!
|
||||||
// TODO: remove all references to this in LatinIME and make this private
|
// TODO: remove all references to this in LatinIME and make this private
|
||||||
public void resetEntireInputState(final SettingsValues settingsValues,
|
public void resetEntireInputState(final SettingsValues settingsValues,
|
||||||
final int newSelStart, final int newSelEnd) {
|
final int newSelStart, final int newSelEnd, final boolean clearSuggestionStrip) {
|
||||||
final boolean shouldFinishComposition = mWordComposer.isComposingWord();
|
final boolean shouldFinishComposition = mWordComposer.isComposingWord();
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
|
if (clearSuggestionStrip) {
|
||||||
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
|
||||||
|
}
|
||||||
mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart, newSelEnd,
|
mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart, newSelEnd,
|
||||||
shouldFinishComposition);
|
shouldFinishComposition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue