From 41ec3ec2f3a95f0af2697da92cee4920e6156763 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 26 May 2011 12:31:52 +0900 Subject: [PATCH] Enable choosing a bigram prediction several times in a row. This change fixes a bug that prevented to choose a prediction several times in a row because the predictions would be replaced right away by punctuations. Please note several things about this change: - Recorrection is pretty much in the middle of being refactored. This change has no effect on recorrection itself, but may make existing strange behavior more obvious when moving the cursor for example. - The part of this change in Recorrection.java is not used in master at the moment because ongoing changes on recorrection result in the control never landing there, but would have been needed in the past and may be needed in the future. - This change may have adverse effects on performance which need to be evaluated. A comment in the code has also been written to this effect. - This does not fix bug 4466199, only addresses a pinpoint case of it to help evaluating the bigram predictions feature. Bug: 4466199 Change-Id: I7219e5aeb74dff9251d12b2a72f94448dbb3e63f --- .../deprecated/recorrection/Recorrection.java | 10 +++++----- .../com/android/inputmethod/latin/LatinIME.java | 14 ++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java index 7f88066b6..d40728d25 100644 --- a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java +++ b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java @@ -218,10 +218,10 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL mService.showSuggestions(builder.build(), entries.getOriginalWord()); } - public void setRecorrectionSuggestions(VoiceProxy voiceProxy, CandidateView candidateView, - Suggest suggest, KeyboardSwitcher keyboardSwitcher, WordComposer word, - boolean hasUncommittedTypedChars, int lastSelectionStart, int lastSelectionEnd, - String wordSeparators) { + public void fetchAndDisplayRecorrectionSuggestions(VoiceProxy voiceProxy, + CandidateView candidateView, Suggest suggest, KeyboardSwitcher keyboardSwitcher, + WordComposer word, boolean hasUncommittedTypedChars, int lastSelectionStart, + int lastSelectionEnd, String wordSeparators) { if (!InputConnectionCompatUtils.RECORRECTION_SUPPORTED) return; if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return; voiceProxy.setShowingVoiceSuggestions(false); @@ -249,7 +249,7 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL ic.endBatchEdit(); } else { abortRecorrection(true); - mService.setPunctuationSuggestions(); // Show the punctuation suggestions list + mService.updateBigramPredictions(); } } else { abortRecorrection(true); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d625951fc..06e93c8b5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -222,9 +222,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar updateSuggestions(); break; case MSG_UPDATE_OLD_SUGGESTIONS: - mRecorrection.setRecorrectionSuggestions(mVoiceProxy, mCandidateView, mSuggest, - mKeyboardSwitcher, mWord, mHasUncommittedTypedChars, mLastSelectionStart, - mLastSelectionEnd, mSettingsValues.mWordSeparators); + mRecorrection.fetchAndDisplayRecorrectionSuggestions(mVoiceProxy, mCandidateView, + mSuggest, mKeyboardSwitcher, mWord, mHasUncommittedTypedChars, + mLastSelectionStart, mLastSelectionEnd, mSettingsValues.mWordSeparators); break; case MSG_UPDATE_SHIFT_STATE: switcher.updateShiftState(); @@ -1621,8 +1621,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (!showingAddToDictionaryHint) { // If we're not showing the "Touch again to save", then show corrections again. // In case the cursor position doesn't change, make sure we show the suggestions again. - clearSuggestions(); - mHandler.postUpdateOldSuggestions(); + updateBigramPredictions(); + // Updating the predictions right away may be slow and feel unresponsive on slower + // terminals. On the other hand if we just postUpdateBigramPredictions() it will + // take a noticeable delay to update them which may feel uneasy. } if (showingAddToDictionaryHint) { mCandidateView.showAddToDictionaryHint(suggestion); @@ -1655,7 +1657,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private static final WordComposer sEmptyWordComposer = new WordComposer(); - private void updateBigramPredictions() { + public void updateBigramPredictions() { if (mSuggest == null || !isSuggestionsRequested()) return;