diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
3 files changed, 29 insertions, 14 deletions
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 db8ca3490..e99bb7016 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) diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index 617d7f1f2..07a44f72d 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -50,6 +50,7 @@ import android.widget.TextView; import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.compat.LinearLayoutCompatUtils; import com.android.inputmethod.keyboard.KeyboardActionListener; +import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.MoreKeysPanel; import com.android.inputmethod.keyboard.PointerTracker; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; @@ -70,7 +71,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On private final ViewGroup mSuggestionsPlacer; private final ViewGroup mSuggestionsStrip; - private View mKeyboardView; + private KeyboardView mKeyboardView; private final View mMoreSuggestionsContainer; private final MoreSuggestionsView mMoreSuggestionsView; @@ -515,7 +516,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On */ public void setListener(Listener listener, View inputView) { mListener = listener; - mKeyboardView = inputView.findViewById(R.id.keyboard_view); + mKeyboardView = (KeyboardView)inputView.findViewById(R.id.keyboard_view); } public void setSuggestions(SuggestedWords suggestions) { @@ -658,7 +659,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On mSuggestionsPlacer.removeAllViews(); mSuggestionsPlacer.addView(mSuggestionsStrip); mSuggestionsStrip.removeAllViews(); - mMoreSuggestionsWindow.dismiss(); + dismissMoreSuggestions(); } private void hidePreview() { @@ -702,13 +703,13 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On final int index = requestCode; final CharSequence word = mSuggestions.getWord(index); mListener.pickSuggestionManually(index, word); - mMoreSuggestionsView.dismissMoreKeysPanel(); + dismissMoreSuggestions(); return true; } @Override public void onCancelInput() { - mMoreSuggestionsView.dismissMoreKeysPanel(); + dismissMoreSuggestions(); } }; @@ -716,14 +717,19 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On new MoreKeysPanel.Controller() { @Override public boolean dismissMoreKeysPanel() { - if (mMoreSuggestionsWindow.isShowing()) { - mMoreSuggestionsWindow.dismiss(); - return true; - } - return false; + return dismissMoreSuggestions(); } }; + private boolean dismissMoreSuggestions() { + if (mMoreSuggestionsWindow.isShowing()) { + mMoreSuggestionsWindow.dismiss(); + mKeyboardView.dimEntireKeyboard(false); + return true; + } + return false; + } + @Override public boolean onLongClick(View view) { final SuggestionsStripParams params = mStripParams; @@ -754,7 +760,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On tracker.onShowMoreKeysPanel( translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel); view.setPressed(false); - // TODO: Should gray out the keyboard here as well? + mKeyboardView.dimEntireKeyboard(true); return true; } return false; |