aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java3
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitator.java12
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java81
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java77
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java7
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java15
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java56
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java9
9 files changed, 214 insertions, 50 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java
index 3abfa3fc9..b9a536721 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java
@@ -20,6 +20,7 @@ import android.os.Build;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.annotations.UsedForTesting;
+import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.lang.reflect.Constructor;
@@ -69,7 +70,8 @@ public final class InputMethodSubtypeCompatUtils {
}
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
- return InputMethodSubtypeCompatUtils.isAsciiCapableWithAPI(subtype);
+ return isAsciiCapableWithAPI(subtype)
+ || subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
}
@UsedForTesting
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 140e76879..77cdf49fb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -261,6 +261,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void onToggleEmojiKeyboard() {
+ if (mKeyboardLayoutSet == null) {
+ return;
+ }
if (isShowingEmojiPalettes()) {
setAlphabetKeyboard();
} else {
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
index 36a02669d..60d6bc3e5 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
@@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.annotations.UsedForTesting;
@@ -656,4 +657,15 @@ public class DictionaryFacilitator {
}
dictToDump.dumpAllWordsForDebug();
}
+
+ public ArrayList<Pair<String, DictionaryStats>> getStatsOfEnabledSubDicts() {
+ final ArrayList<Pair<String, DictionaryStats>> statsOfEnabledSubDicts = new ArrayList<>();
+ final Dictionaries dictionaries = mDictionaries;
+ for (final String dictType : SUB_DICT_TYPES) {
+ final ExpandableBinaryDictionary dictionary = dictionaries.getSubDict(dictType);
+ if (dictionary == null) continue;
+ statsOfEnabledSubDicts.add(new Pair<>(dictType, dictionary.getDictionaryStats()));
+ }
+ return statsOfEnabledSubDicts;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 660b2daf2..87b34a99c 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -51,6 +51,7 @@ import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils;
@@ -192,8 +193,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private static final int ARG1_FALSE = 0;
private static final int ARG1_TRUE = 1;
- private int mDelayUpdateSuggestions;
- private int mDelayUpdateShiftState;
+ private int mDelayInMillisecondsToUpdateSuggestions;
+ private int mDelayInMillisecondsToUpdateShiftState;
public UIHandler(final LatinIME ownerInstance) {
super(ownerInstance);
@@ -205,8 +206,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return;
}
final Resources res = latinIme.getResources();
- mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions);
- mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state);
+ mDelayInMillisecondsToUpdateSuggestions =
+ res.getInteger(R.integer.config_delay_in_milliseconds_to_update_suggestions);
+ mDelayInMillisecondsToUpdateShiftState =
+ res.getInteger(R.integer.config_delay_in_milliseconds_to_update_shift_state);
}
@Override
@@ -272,7 +275,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void postUpdateSuggestionStrip(final int inputStyle) {
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTION_STRIP, inputStyle,
- 0 /* ignored */), mDelayUpdateSuggestions);
+ 0 /* ignored */), mDelayInMillisecondsToUpdateSuggestions);
}
public void postReopenDictionaries() {
@@ -285,16 +288,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (latinIme == null) {
return;
}
- if (!latinIme.mSettings.getCurrent()
- .isSuggestionsEnabledPerUserSettings()) {
+ if (!latinIme.mSettings.getCurrent().isSuggestionsEnabledPerUserSettings()) {
return;
}
removeMessages(MSG_RESUME_SUGGESTIONS);
if (shouldDelay) {
sendMessageDelayed(obtainMessage(MSG_RESUME_SUGGESTIONS,
- shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
- 0 /* ignored */),
- mDelayUpdateSuggestions);
+ shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
+ 0 /* ignored */), mDelayInMillisecondsToUpdateSuggestions);
} else {
sendMessage(obtainMessage(MSG_RESUME_SUGGESTIONS,
shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
@@ -335,7 +336,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void postUpdateShiftState() {
removeMessages(MSG_UPDATE_SHIFT_STATE);
- sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), mDelayUpdateShiftState);
+ sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE),
+ mDelayInMillisecondsToUpdateShiftState);
}
@UsedForTesting
@@ -1139,6 +1141,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
+ public boolean onShowInputRequested(final int flags, final boolean configChange) {
+ if ((flags & InputMethod.SHOW_EXPLICIT) == 0 && mKeyboardSwitcher.hasHardwareKeyboard()) {
+ // Even when IME is implicitly shown and physical keyboard is connected, we should
+ // show {@link InputView}.
+ // See {@link InputMethodService#onShowInputRequested(int,boolean)}.
+ return true;
+ }
+ return super.onShowInputRequested(flags, configChange);
+ }
+
+ @Override
public boolean onEvaluateFullscreenMode() {
if (mKeyboardSwitcher.hasHardwareKeyboard()) {
// If there is a hardware keyboard, disable full screen mode.
@@ -1259,10 +1272,26 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSubtypeState.switchSubtype(token, mRichImm);
}
+ // TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
+ // alphabetic shift and shift while in symbol layout and get rid of this method.
+ private int getCodePointForKeyboard(final int codePoint) {
+ if (Constants.CODE_SHIFT == codePoint) {
+ final Keyboard currentKeyboard = mKeyboardSwitcher.getKeyboard();
+ if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
+ return codePoint;
+ } else {
+ return Constants.CODE_SYMBOL_SHIFT;
+ }
+ } else {
+ return codePoint;
+ }
+ }
+
// Implementation of {@link KeyboardActionListener}.
@Override
public void onCodeInput(final int codePoint, final int x, final int y,
final boolean isKeyRepeat) {
+ // TODO: this processing does not belong inside LatinIME, the caller should be doing this.
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
// x and y include some padding, but everything down the line (especially native
// code) needs the coordinates in the keyboard frame.
@@ -1271,36 +1300,30 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// this transformation, it should be done already before calling onCodeInput.
final int keyX = mainKeyboardView.getKeyX(x);
final int keyY = mainKeyboardView.getKeyY(y);
- final int codeToSend;
- if (Constants.CODE_SHIFT == codePoint) {
- // TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
- // alphabetic shift and shift while in symbol layout.
- final Keyboard currentKeyboard = mKeyboardSwitcher.getKeyboard();
- if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
- codeToSend = codePoint;
- } else {
- codeToSend = Constants.CODE_SYMBOL_SHIFT;
- }
- } else {
- codeToSend = codePoint;
- }
- if (Constants.CODE_SHORTCUT == codePoint) {
+ final Event event = createSoftwareKeypressEvent(getCodePointForKeyboard(codePoint),
+ keyX, keyY, isKeyRepeat);
+ onEvent(event);
+ }
+
+ // This method is public for testability of LatinIME, but also in the future it should
+ // completely replace #onCodeInput.
+ public void onEvent(final Event event) {
+ if (Constants.CODE_SHORTCUT == event.mCodePoint) {
mSubtypeSwitcher.switchToShortcutIME(this);
- // Still call the *#onCodeInput methods for readability.
}
- final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat);
final InputTransaction completeInputTransaction =
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
mKeyboardSwitcher.getKeyboardShiftMode(),
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
updateStateAfterInputTransaction(completeInputTransaction);
- mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(),
+ mKeyboardSwitcher.onCodeInput(event.mCodePoint, getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
}
// A helper method to split the code point and the key code. Ultimately, they should not be
// squashed into the same variable, and this method should be removed.
- private static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
+ // public for testing, as we don't want to copy the same logic into test code
+ public static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
final int keyY, final boolean isKeyRepeat) {
final int keyCode;
final int codePoint;
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index ea63cef02..035557610 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -16,9 +16,13 @@
package com.android.inputmethod.latin;
+import android.graphics.Color;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
import android.text.TextUtils;
+import android.text.style.BackgroundColorSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
@@ -81,6 +85,18 @@ public final class RichInputConnection {
*/
private final StringBuilder mComposingText = new StringBuilder();
+ /**
+ * This variable is a temporary object used in
+ * {@link #commitTextWithBackgroundColor(CharSequence, int, int)} to avoid object creation.
+ */
+ private SpannableStringBuilder mTempObjectForCommitText = new SpannableStringBuilder();
+ /**
+ * This variable is used to track whether the last committed text had the background color or
+ * not.
+ * TODO: Omit this flag if possible.
+ */
+ private boolean mLastCommittedTextHasBackgroundColor = false;
+
private final InputMethodService mParent;
InputConnection mIC;
int mNestLevel;
@@ -219,12 +235,37 @@ public final class RichInputConnection {
// it works, but it's wrong and should be fixed.
mCommittedTextBeforeComposingText.append(mComposingText);
mComposingText.setLength(0);
+ // TODO: Clear this flag in setComposingRegion() and setComposingText() as well if needed.
+ mLastCommittedTextHasBackgroundColor = false;
if (null != mIC) {
mIC.finishComposingText();
}
}
- public void commitText(final CharSequence text, final int i) {
+ /**
+ * Synonym of {@code commitTextWithBackgroundColor(text, newCursorPosition, Color.TRANSPARENT}.
+ * @param text The text to commit. This may include styles.
+ * See {@link InputConnection#commitText(CharSequence, int)}.
+ * @param newCursorPosition The new cursor position around the text.
+ * See {@link InputConnection#commitText(CharSequence, int)}.
+ */
+ public void commitText(final CharSequence text, final int newCursorPosition) {
+ commitTextWithBackgroundColor(text, newCursorPosition, Color.TRANSPARENT);
+ }
+
+ /**
+ * Calls {@link InputConnection#commitText(CharSequence, int)} with the given background color.
+ * @param text The text to commit. This may include styles.
+ * See {@link InputConnection#commitText(CharSequence, int)}.
+ * @param newCursorPosition The new cursor position around the text.
+ * See {@link InputConnection#commitText(CharSequence, int)}.
+ * @param color The background color to be attached. Set {@link Color#TRANSPARENT} to disable
+ * the background color. Note that this method specifies {@link BackgroundColorSpan} with
+ * {@link Spanned#SPAN_COMPOSING} flag, meaning that the background color persists until
+ * {@link #finishComposingText()} is called.
+ */
+ public void commitTextWithBackgroundColor(final CharSequence text, final int newCursorPosition,
+ final int color) {
if (DEBUG_BATCH_NESTING) checkBatchEdit();
if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
mCommittedTextBeforeComposingText.append(text);
@@ -234,11 +275,43 @@ public final class RichInputConnection {
mExpectedSelStart += text.length() - mComposingText.length();
mExpectedSelEnd = mExpectedSelStart;
mComposingText.setLength(0);
+ mLastCommittedTextHasBackgroundColor = false;
if (null != mIC) {
- mIC.commitText(text, i);
+ if (color == Color.TRANSPARENT) {
+ mIC.commitText(text, newCursorPosition);
+ } else {
+ mTempObjectForCommitText.clear();
+ mTempObjectForCommitText.append(text);
+ final BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(color);
+ mTempObjectForCommitText.setSpan(backgroundColorSpan, 0, text.length(),
+ Spanned.SPAN_COMPOSING | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ mIC.commitText(mTempObjectForCommitText, newCursorPosition);
+ mLastCommittedTextHasBackgroundColor = true;
+ }
}
}
+ /**
+ * Removes the background color from the highlighted text if necessary. Should be called while
+ * there is no on-going composing text.
+ *
+ * <p>CAVEAT: This method internally calls {@link InputConnection#finishComposingText()}.
+ * Be careful of any unexpected side effects.</p>
+ */
+ public void removeBackgroundColorFromHighlightedTextIfNecessary() {
+ // TODO: We haven't yet full tested if we really need to check this flag or not. Omit this
+ // flag if everything works fine without this condition.
+ if (!mLastCommittedTextHasBackgroundColor) {
+ return;
+ }
+ if (mComposingText.length() > 0) {
+ Log.e(TAG, "clearSpansWithComposingFlags should be called when composing text is " +
+ "empty. mComposingText=" + mComposingText);
+ return;
+ }
+ finishComposingText();
+ }
+
public CharSequence getSelectedText(final int flags) {
return (null == mIC) ? null : mIC.getSelectedText(flags);
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index c39c2542c..45d67ff88 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -315,9 +315,12 @@ public final class SubtypeSwitcher {
public RichInputMethodSubtype getEmojiSubtype() {
if (mEmojiSubtype == null) {
- mEmojiSubtype = new RichInputMethodSubtype(
+ final InputMethodSubtype rawEmojiSubtype =
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI));
+ SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI);
+ if (null != rawEmojiSubtype) {
+ mEmojiSubtype = new RichInputMethodSubtype(rawEmojiSubtype);
+ }
}
if (mEmojiSubtype != null) {
return mEmojiSubtype;
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index d7693af41..38fcb683d 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo;
+import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.StringUtils;
@@ -420,4 +421,18 @@ public class SuggestedWords {
mWillAutoCorrect, mIsObsoleteSuggestions, mIsPrediction,
INPUT_STYLE_TAIL_BATCH);
}
+
+ /**
+ * @return the {@link SuggestedWordInfo} which corresponds to the word that is originally
+ * typed by the user. Otherwise returns {@code null}. Note that gesture input is not
+ * considered to be a typed word.
+ */
+ @UsedForTesting
+ public SuggestedWordInfo getTypedWordInfoOrNull() {
+ if (this == EMPTY) {
+ return null;
+ }
+ final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD);
+ return (info.getKind() == SuggestedWordInfo.KIND_TYPED) ? info : null;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 348bae63a..616828efe 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.latin.inputlogic;
+import android.graphics.Color;
import android.os.SystemClock;
import android.text.SpannableString;
import android.text.TextUtils;
@@ -232,6 +233,20 @@ public final class InputLogic {
}
/**
+ * Determines whether "Touch again to save" should be shown or not.
+ * @param suggestionInfo the suggested word chosen by the user.
+ * @return {@code true} if we should show the "Touch again to save" hint.
+ */
+ private boolean shouldShowAddToDictionaryHint(final SuggestedWordInfo suggestionInfo) {
+ // We should show the "Touch again to save" hint if the user pressed the first entry
+ // AND it's in none of our current dictionaries (main, user or otherwise).
+ return (suggestionInfo.isKindOf(SuggestedWordInfo.KIND_TYPED)
+ || suggestionInfo.isKindOf(SuggestedWordInfo.KIND_OOV_CORRECTION))
+ && !mDictionaryFacilitator.isValidWord(suggestionInfo.mWord, true /* ignoreCase */)
+ && mDictionaryFacilitator.isUserDictionaryEnabled();
+ }
+
+ /**
* A suggestion was picked from the suggestion strip.
* @param settingsValues the current values of the settings.
* @param suggestionInfo the suggestion info.
@@ -297,14 +312,7 @@ public final class InputLogic {
mSpaceState = SpaceState.PHANTOM;
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
- // We should show the "Touch again to save" hint if the user pressed the first entry
- // AND it's in none of our current dictionaries (main, user or otherwise).
- final boolean showingAddToDictionaryHint =
- (suggestionInfo.isKindOf(SuggestedWordInfo.KIND_TYPED)
- || suggestionInfo.isKindOf(SuggestedWordInfo.KIND_OOV_CORRECTION))
- && !mDictionaryFacilitator.isValidWord(suggestion, true /* ignoreCase */);
-
- if (showingAddToDictionaryHint && mDictionaryFacilitator.isUserDictionaryEnabled()) {
+ if (shouldShowAddToDictionaryHint(suggestionInfo)) {
mSuggestionStripViewAccessor.showAddToDictionaryHint(suggestion);
} else {
// If we're not showing the "Touch again to save", then update the suggestion strip.
@@ -743,6 +751,13 @@ public final class InputLogic {
final InputTransaction inputTransaction,
// TODO: remove this argument
final LatinIME.UIHandler handler) {
+ // In case the "add to dictionary" hint was still displayed.
+ // TODO: Do we really need to check if we have composing text here?
+ if (!mWordComposer.isComposingWord() &&
+ mSuggestionStripViewAccessor.isShowingAddToDictionaryHint()) {
+ mSuggestionStripViewAccessor.dismissAddToDictionaryHint();
+ }
+
final int codePoint = event.mCodePoint;
mSpaceState = SpaceState.NONE;
if (inputTransaction.mSettingsValues.isWordSeparator(codePoint)
@@ -838,8 +853,6 @@ public final class InputLogic {
} else {
sendKeyCodePoint(settingsValues, codePoint);
}
- // In case the "add to dictionary" hint was still displayed.
- mSuggestionStripViewAccessor.dismissAddToDictionaryHint();
}
inputTransaction.setRequiresUpdateSuggestions();
}
@@ -1994,7 +2007,9 @@ public final class InputLogic {
}
/**
- * Commits the chosen word to the text field and saves it for later retrieval.
+ * Commits the chosen word to the text field and saves it for later retrieval. This is a
+ * synonym of {@code commitChosenWordWithBackgroundColor(settingsValues, chosenWord,
+ * commitType, separatorString, Color.TRANSPARENT}.
*
* @param settingsValues the current values of the settings.
* @param chosenWord the word we want to commit.
@@ -2003,6 +2018,23 @@ public final class InputLogic {
*/
private void commitChosenWord(final SettingsValues settingsValues, final String chosenWord,
final int commitType, final String separatorString) {
+ commitChosenWordWithBackgroundColor(settingsValues, chosenWord, commitType, separatorString,
+ Color.TRANSPARENT);
+ }
+
+ /**
+ * Commits the chosen word to the text field and saves it for later retrieval.
+ *
+ * @param settingsValues the current values of the settings.
+ * @param chosenWord the word we want to commit.
+ * @param commitType the type of the commit, as one of LastComposedWord.COMMIT_TYPE_*
+ * @param separatorString the separator that's causing the commit, or NOT_A_SEPARATOR if none.
+ * @param backgroundColor the background color to be specified with the committed text. Pass
+ * {@link Color#TRANSPARENT} to not specify the background color.
+ */
+ private void commitChosenWordWithBackgroundColor(final SettingsValues settingsValues,
+ final String chosenWord, final int commitType, final String separatorString,
+ final int backgroundColor) {
final SuggestedWords suggestedWords = mSuggestedWords;
final CharSequence chosenWordWithSuggestions =
SuggestionSpanUtils.getTextWithSuggestionSpan(mLatinIME, chosenWord,
@@ -2012,7 +2044,7 @@ public final class InputLogic {
// information from the 1st previous word.
final PrevWordsInfo prevWordsInfo = mConnection.getPrevWordsInfoFromNthPreviousWord(
settingsValues.mSpacingAndPunctuations, mWordComposer.isComposingWord() ? 2 : 1);
- mConnection.commitText(chosenWordWithSuggestions, 1);
+ mConnection.commitTextWithBackgroundColor(chosenWordWithSuggestions, 1, backgroundColor);
// Add the word to the user history dictionary
performAdditionToUserHistoryDictionary(settingsValues, chosenWord, prevWordsInfo);
// TODO: figure out here if this is an auto-correct or if the best word is actually
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index c12474b3d..a9789d888 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -51,7 +51,7 @@ public class SettingsValues {
// From resources:
public final SpacingAndPunctuations mSpacingAndPunctuations;
- public final int mDelayUpdateOldSuggestions;
+ public final int mDelayInMillisecondsToUpdateOldSuggestions;
public final long mDoubleSpacePeriodTimeout;
// From preferences, in the same order as xml/prefs.xml:
@@ -107,7 +107,8 @@ public class SettingsValues {
final InputAttributes inputAttributes) {
mLocale = res.getConfiguration().locale;
// Get the resources
- mDelayUpdateOldSuggestions = res.getInteger(R.integer.config_delay_update_old_suggestions);
+ mDelayInMillisecondsToUpdateOldSuggestions =
+ res.getInteger(R.integer.config_delay_in_milliseconds_to_update_old_suggestions);
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
// Store the input attributes
@@ -337,8 +338,8 @@ public class SettingsValues {
final StringBuilder sb = new StringBuilder("Current settings :");
sb.append("\n mSpacingAndPunctuations = ");
sb.append("" + mSpacingAndPunctuations.dump());
- sb.append("\n mDelayUpdateOldSuggestions = ");
- sb.append("" + mDelayUpdateOldSuggestions);
+ sb.append("\n mDelayInMillisecondsToUpdateOldSuggestions = ");
+ sb.append("" + mDelayInMillisecondsToUpdateOldSuggestions);
sb.append("\n mAutoCap = ");
sb.append("" + mAutoCap);
sb.append("\n mVibrateOn = ");