diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/deprecated/VoiceProxy.java | 38 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 19 |
2 files changed, 9 insertions, 48 deletions
diff --git a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java index 5c4e9af68..700709d50 100644 --- a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java +++ b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java @@ -435,44 +435,6 @@ public class VoiceProxy implements VoiceInput.UiListener { } } - /** - * Tries to apply any voice alternatives for the word if this was a spoken word and - * there are voice alternatives. - * @param touching The word that the cursor is touching, with position information - * @return true if an alternative was found, false otherwise. - */ - public boolean applyVoiceAlternatives(EditingUtils.SelectedWord touching) { - if (!VOICE_INSTALLED) { - return false; - } - // Search for result in spoken word alternatives - String selectedWord = touching.mWord.toString().trim(); - if (!mWordToSuggestions.containsKey(selectedWord)) { - selectedWord = selectedWord.toLowerCase(); - } - if (mWordToSuggestions.containsKey(selectedWord)) { - mShowingVoiceSuggestions = true; - List<CharSequence> suggestions = mWordToSuggestions.get(selectedWord); - SuggestedWords.Builder builder = new SuggestedWords.Builder(); - // If the first letter of touching is capitalized, make all the suggestions - // start with a capital letter. - if (Character.isUpperCase(touching.mWord.charAt(0))) { - for (CharSequence word : suggestions) { - String str = word.toString(); - word = Character.toUpperCase(str.charAt(0)) + str.substring(1); - builder.addWord(word); - } - } else { - builder.addWords(suggestions, null); - } - builder.setTypedWordValid(true).setHasMinimalSuggestion(true); - mService.setSuggestions(builder.build()); -// mService.setCandidatesViewShown(true); - return true; - } - return false; - } - public void handleBackspace() { if (!VOICE_INSTALLED) { return; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 953d87beb..ce3e444d5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1715,7 +1715,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar setSuggestions(SuggestedWords.EMPTY); } - public void setSuggestions(SuggestedWords words) { + public void setSuggestions(final SuggestedWords words) { if (mSuggestionsView != null) { mSuggestionsView.setSuggestions(words); mKeyboardSwitcher.onAutoCorrectionStateChanged( @@ -1830,25 +1830,24 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar showSuggestions(builder.build(), typedWord); } - public void showSuggestions(SuggestedWords suggestedWords, CharSequence typedWord) { + public void showSuggestions(final SuggestedWords suggestedWords, final CharSequence typedWord) { final boolean shouldBlockAutoCorrectionBySafetyNet = Utils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords, mSuggest); if (shouldBlockAutoCorrectionBySafetyNet) { suggestedWords.setShouldBlockAutoCorrection(); } - setSuggestions(suggestedWords); + final CharSequence autoCorrection; if (suggestedWords.size() > 0) { - if (shouldBlockAutoCorrectionBySafetyNet) { - mWordComposer.setAutoCorrection(typedWord); - } else if (suggestedWords.hasAutoCorrectionWord()) { - mWordComposer.setAutoCorrection(suggestedWords.getWord(1)); + if (!shouldBlockAutoCorrectionBySafetyNet && suggestedWords.hasAutoCorrectionWord()) { + autoCorrection = suggestedWords.getWord(1); } else { - mWordComposer.setAutoCorrection(typedWord); + autoCorrection = typedWord; } } else { - // TODO: replace with mWordComposer.deleteAutoCorrection()? - mWordComposer.setAutoCorrection(null); + autoCorrection = null; } + mWordComposer.setAutoCorrection(autoCorrection); + setSuggestions(suggestedWords); setSuggestionStripShown(isSuggestionsStripVisible()); } |