From 1531528bfe01d0ce88888d23952a4c7092a15f17 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 2 Sep 2011 14:09:10 +0900 Subject: [PATCH] Add an option to prevent insertion of suggestion spans This is to help debug of Bug: 5250788 Change-Id: I961321aff3776c4912eaf7a1fa4de0c01d715f24 --- java/res/values/strings.xml | 5 +++++ java/res/xml/prefs.xml | 6 ++++++ java/src/com/android/inputmethod/latin/LatinIME.java | 10 +++++++--- java/src/com/android/inputmethod/latin/Settings.java | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 2b9193690..37cb23b70 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -75,6 +75,11 @@ Use names from Contacts for suggestions and corrections + + Enable recorrections + + Set suggestions for recorrections + Auto-capitalization diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 2f321814e..d02e5d7b6 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -132,6 +132,12 @@ android:summary="@string/bigram_suggestion_summary" android:persistent="true" android:defaultValue="true" /> + diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 85363fd36..cea59fe0a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1807,9 +1807,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final InputConnection ic = getCurrentInputConnection(); if (ic != null) { mVoiceProxy.rememberReplacedWord(bestWord, mSettingsValues.mWordSeparators); - SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); - ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( - this, bestWord, suggestedWords), 1); + if (mSettingsValues.mEnableSuggestionSpanInsertion) { + final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); + ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( + this, bestWord, suggestedWords), 1); + } else { + ic.commitText(bestWord, 1); + } } mRecorrection.saveRecorrectionSuggestion(mWordComposer, bestWord); mHasUncommittedTypedChars = false; diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 1e2ef4824..c42f0564c 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -82,6 +82,8 @@ public class Settings extends InputMethodSettingsActivity "pref_key_preview_popup_dismiss_delay"; public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; + public static final String PREF_KEY_ENABLE_SPAN_INSERT = + "enable_span_insert"; public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode"; @@ -117,6 +119,7 @@ public class Settings extends InputMethodSettingsActivity // Prediction: use bigrams to predict the next word when there is no input for it yet public final boolean mBigramPredictionEnabled; public final boolean mUseContactsDict; + public final boolean mEnableSuggestionSpanInsertion; private final boolean mShowSettingsKey; private final boolean mVoiceKeyEnabled; @@ -179,6 +182,8 @@ public class Settings extends InputMethodSettingsActivity && isBigramPredictionEnabled(prefs, res); mAutoCorrectionThreshold = getAutoCorrectionThreshold(prefs, res); mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true); + mEnableSuggestionSpanInsertion = + prefs.getBoolean(Settings.PREF_KEY_ENABLE_SPAN_INSERT, true); final boolean defaultShowSettingsKey = res.getBoolean( R.bool.config_default_show_settings_key); mShowSettingsKey = isShowSettingsKeyOption(res)