Fix an NPE in recorrection
Also, theoretically, we don't want to retrieve older suggestions if there are no results for a recorrection - that would look random. This bug addresses this too. Bug: 8657919 Change-Id: I44f36d34a708a968ab71fa0592da57f4c97d4b7fmain
parent
530fd15eff
commit
ae7d1530b4
|
@ -1678,7 +1678,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
private SuggestedWords getSuggestedWordsGestureLocked(final InputPointers batchPointers) {
|
private SuggestedWords getSuggestedWordsGestureLocked(final InputPointers batchPointers) {
|
||||||
mLatinIme.mWordComposer.setBatchInputPointers(batchPointers);
|
mLatinIme.mWordComposer.setBatchInputPointers(batchPointers);
|
||||||
final SuggestedWords suggestedWords =
|
final SuggestedWords suggestedWords =
|
||||||
mLatinIme.getSuggestedWords(Suggest.SESSION_GESTURE);
|
mLatinIme.getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_GESTURE);
|
||||||
final int suggestionCount = suggestedWords.size();
|
final int suggestionCount = suggestedWords.size();
|
||||||
if (suggestionCount <= 1) {
|
if (suggestionCount <= 1) {
|
||||||
final String mostProbableSuggestion = (suggestionCount == 0) ? null
|
final String mostProbableSuggestion = (suggestionCount == 0) ? null
|
||||||
|
@ -2152,7 +2152,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SuggestedWords suggestedWords = getSuggestedWords(Suggest.SESSION_TYPING);
|
final SuggestedWords suggestedWords =
|
||||||
|
getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_TYPING);
|
||||||
final String typedWord = mWordComposer.getTypedWord();
|
final String typedWord = mWordComposer.getTypedWord();
|
||||||
showSuggestionStrip(suggestedWords, typedWord);
|
showSuggestionStrip(suggestedWords, typedWord);
|
||||||
}
|
}
|
||||||
|
@ -2162,7 +2163,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
if (keyboard == null || mSuggest == null) {
|
if (keyboard == null || mSuggest == null) {
|
||||||
return SuggestedWords.EMPTY;
|
return SuggestedWords.EMPTY;
|
||||||
}
|
}
|
||||||
final String typedWord = mWordComposer.getTypedWord();
|
|
||||||
// Get the word on which we should search the bigrams. If we are composing a word, it's
|
// Get the word on which we should search the bigrams. If we are composing a word, it's
|
||||||
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
|
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
|
||||||
// should just skip whitespace if any, so 1.
|
// should just skip whitespace if any, so 1.
|
||||||
|
@ -2170,10 +2170,13 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
final String prevWord =
|
final String prevWord =
|
||||||
mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators,
|
mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators,
|
||||||
mWordComposer.isComposingWord() ? 2 : 1);
|
mWordComposer.isComposingWord() ? 2 : 1);
|
||||||
final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
|
return mSuggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(),
|
||||||
prevWord, keyboard.getProximityInfo(), mSettings.getCurrent().mCorrectionEnabled,
|
mSettings.getCurrent().mCorrectionEnabled, sessionId);
|
||||||
sessionId);
|
}
|
||||||
return maybeRetrieveOlderSuggestions(typedWord, suggestedWords);
|
|
||||||
|
private SuggestedWords getSuggestedWordsOrOlderSuggestions(final int sessionId) {
|
||||||
|
return maybeRetrieveOlderSuggestions(mWordComposer.getTypedWord(),
|
||||||
|
getSuggestedWords(sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
|
private SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
|
||||||
|
@ -2186,7 +2189,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// old suggestions. Also, if we are showing the "add to dictionary" hint, we need to
|
// old suggestions. Also, if we are showing the "add to dictionary" hint, we need to
|
||||||
// revert to suggestions - although it is unclear how we can come here if it's displayed.
|
// revert to suggestions - although it is unclear how we can come here if it's displayed.
|
||||||
if (suggestedWords.size() > 1 || typedWord.length() <= 1
|
if (suggestedWords.size() > 1 || typedWord.length() <= 1
|
||||||
|| suggestedWords.mTypedWordValid
|
|| suggestedWords.mTypedWordValid || null == mSuggestionStripView
|
||||||
|| mSuggestionStripView.isShowingAddToDictionaryHint()) {
|
|| mSuggestionStripView.isShowingAddToDictionaryHint()) {
|
||||||
return suggestedWords;
|
return suggestedWords;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue