From b5880034268111a094c9e684cec9cca784386140 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 14 Dec 2011 16:50:03 +0900 Subject: [PATCH] Refactoring. Small simplification of the code. Change-Id: I1f67ae529bbb2c9316bf5e083d367c57040ea22c --- .../android/inputmethod/latin/LatinIME.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index eb2f7971e..ff850b7d0 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1586,7 +1586,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mHandler.postUpdateSuggestions(); } - boolean pickedDefault = false; // Handle separator final InputConnection ic = getCurrentInputConnection(); if (ic != null) { @@ -1603,27 +1602,26 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled && !mInputTypeNoAutoCorrect; if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { - pickedDefault = pickDefaultSuggestion(primaryCode); + final boolean pickedDefaultSuggestion = pickDefaultSuggestion(primaryCode); + if (pickedDefaultSuggestion) { + final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull(); + final String typedWord = mWordComposer.getTypedWord(); + if (TextUtils.isEmpty(typedWord)) { + throw new RuntimeException("We have non-committed chars but the typed word " + + "is empty? Impossible! I must commit suicide."); + } + if (!typedWord.equals(autoCorrection)) { + // This will make the correction flash for a short while as a visual clue + // to the user that auto-correction happened. + InputConnectionCompatUtils.commitCorrection(ic, + mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection); + } + } } else { commitTyped(ic); } } - if (pickedDefault) { - final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull(); - final String typedWord = mWordComposer.getTypedWord(); - if (TextUtils.isEmpty(typedWord)) { - throw new RuntimeException("We have non-committed chars but the typed word " - + "is empty? Impossible! I must commit suicide."); - } - if (!typedWord.equals(autoCorrection)) { - // This will make the correction flash for a short while as a visual clue - // to the user that auto-correction happened. - InputConnectionCompatUtils.commitCorrection( - ic, mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection); - } - } - final boolean swapMagicSpace; if (Keyboard.CODE_ENTER == primaryCode && (SPACE_STATE_MAGIC == spaceState || SPACE_STATE_SWAP_PUNCTUATION == spaceState)) {