aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java2
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java12
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java30
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java9
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java2
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java6
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java4
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java13
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java49
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripViewAccessor.java1
-rw-r--r--java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java6
13 files changed, 84 insertions, 66 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index afaf2cc57..816a94300 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -716,10 +716,14 @@ public class Key implements Comparable<Key> {
return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
}
+ public int getIconId() {
+ return mIconId;
+ }
+
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
final OptionalAttributes attrs = mOptionalAttributes;
final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED;
- final int iconId = mEnabled ? mIconId : disabledIconId;
+ final int iconId = mEnabled ? getIconId() : disabledIconId;
final Drawable icon = iconSet.getIconDrawable(iconId);
if (icon != null) {
icon.setAlpha(alpha);
@@ -731,7 +735,7 @@ public class Key implements Comparable<Key> {
final OptionalAttributes attrs = mOptionalAttributes;
final int previewIconId = (attrs != null) ? attrs.mPreviewIconId : ICON_UNDEFINED;
return previewIconId != ICON_UNDEFINED
- ? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(mIconId);
+ ? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(getIconId());
}
public int getWidth() {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index f9758634e..573c60552 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -340,10 +340,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState());
}
- private boolean isShowingMainKeyboard() {
- return null != mKeyboardView && mKeyboardView.isShown();
- }
-
public boolean isShowingEmojiPalettes() {
return mEmojiPalettesView != null && mEmojiPalettesView.isShown();
}
@@ -376,10 +372,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
}
}
- public boolean isShowingMainKeyboardOrEmojiPalettes() {
- return isShowingMainKeyboard() || isShowingEmojiPalettes();
- }
-
public View onCreateInputView(final boolean isHardwareAcceleratedDrawingEnabled) {
if (mKeyboardView != null) {
mKeyboardView.closing();
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index da8bf7d69..79d088f2e 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -102,7 +102,7 @@ public final class KeyboardIconsSet {
return isValidIconId(iconId) ? ICON_NAMES[iconId] : "unknown<" + iconId + ">";
}
- static int getIconId(final String name) {
+ public static int getIconId(final String name) {
Integer iconId = sNameToIdsMap.get(name);
if (iconId != null) {
return iconId;
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
index 2dba7131e..cd18a6ba5 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
@@ -36,6 +36,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
@@ -142,7 +143,8 @@ public class DictionaryFacilitatorForSuggest {
@UsedForTesting
public DictionaryFacilitatorForSuggest(final Context context, final Locale locale,
- final ArrayList<String> dictionaryTypes, final HashMap<String, File> dictionaryFiles) {
+ final ArrayList<String> dictionaryTypes, final HashMap<String, File> dictionaryFiles,
+ final Map<String, Map<String, String>> additionalDictAttributes) {
mContext = context;
mLocale = locale;
mLatchForWaitingLoadingMainDictionary = new CountDownLatch(0);
@@ -159,6 +161,10 @@ public class DictionaryFacilitatorForSuggest {
userHistoryDictionary.reloadDictionaryIfRequired();
userHistoryDictionary.waitAllTasksForTests();
setUserHistoryDictionary(userHistoryDictionary);
+ if (additionalDictAttributes.containsKey(dictType)) {
+ userHistoryDictionary.clearAndFlushDictionaryWithAdditionalAttributes(
+ additionalDictAttributes.get(dictType));
+ }
} else if (dictType.equals(Dictionary.TYPE_PERSONALIZATION)) {
final PersonalizationDictionary personalizationDictionary =
PersonalizationHelper.getPersonalizationDictionary(context, locale);
@@ -167,6 +173,10 @@ public class DictionaryFacilitatorForSuggest {
personalizationDictionary.reloadDictionaryIfRequired();
personalizationDictionary.waitAllTasksForTests();
setPersonalizationDictionary(personalizationDictionary);
+ if (additionalDictAttributes.containsKey(dictType)) {
+ personalizationDictionary.clearAndFlushDictionaryWithAdditionalAttributes(
+ additionalDictAttributes.get(dictType));
+ }
} else if (dictType.equals(Dictionary.TYPE_USER)) {
final File file = dictionaryFiles.get(dictType);
final UserBinaryDictionary userDictionary = new UserBinaryDictionary(
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 44282a492..8ab1bb6a1 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -853,7 +853,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
// This will set the punctuation suggestions if next word suggestion is off;
// otherwise it will clear the suggestion strip.
- setNeutralSuggestionStripInternal(false /* needsInputViewShown */);
+ setNeutralSuggestionStripInternal();
mHandler.cancelUpdateSuggestionStrip();
mHandler.cancelDoubleSpacePeriodTimer();
@@ -1018,23 +1018,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isPrediction */);
// When in fullscreen mode, show completions generated by the application forcibly
- setSuggestedWords(suggestedWords, true /* isSuggestionStripVisible */,
- true /* needsInputViewShown */);
+ setSuggestedWords(suggestedWords, true /* isSuggestionStripVisible */);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
}
}
- private void setSuggestionStripShownInternal(final boolean isSuggestionStripVisible,
- final boolean needsInputViewShown) {
+ private void setSuggestionStripShownInternal(final boolean isSuggestionStripVisible) {
// TODO: Modify this if we support suggestions with hard keyboard
if (!onEvaluateInputViewShown() || !hasSuggestionStripView()) {
return;
}
- final boolean inputViewShown = mKeyboardSwitcher.isShowingMainKeyboardOrEmojiPalettes();
- final boolean shouldShowSuggestions = isSuggestionStripVisible
- && (needsInputViewShown ? inputViewShown : true);
- if (shouldShowSuggestions) {
+ if (isSuggestionStripVisible) {
mSuggestionStripView.setVisibility(View.VISIBLE);
} else {
mSuggestionStripView.setVisibility(isFullscreenMode() ? View.GONE : View.INVISIBLE);
@@ -1321,8 +1316,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Nothing to do so far.
}
- // TODO[IL]: Define a clear interface for this
- public boolean isSuggestionStripVisible() {
+ private boolean isSuggestionStripVisible() {
if (!hasSuggestionStripView()) {
return false;
}
@@ -1346,7 +1340,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return currentSettings.isSuggestionsRequested();
}
- @Override
public boolean hasSuggestionStripView() {
return null != mSuggestionStripView;
}
@@ -1366,7 +1359,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO[IL]: Define a clear interface for this
public void setSuggestedWords(final SuggestedWords suggestedWords,
- final boolean isSuggestionStripVisible, final boolean needsInputViewShown) {
+ final boolean isSuggestionStripVisible) {
mInputLogic.setSuggestedWords(suggestedWords);
if (!hasSuggestionStripView()) {
return;
@@ -1386,7 +1379,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
}
mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
- setSuggestionStripShownInternal(isSuggestionStripVisible, needsInputViewShown);
+ setSuggestionStripShownInternal(isSuggestionStripVisible);
}
// TODO[IL]: Move this out of LatinIME.
@@ -1472,8 +1465,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
setNeutralSuggestionStrip();
} else {
mInputLogic.mWordComposer.setAutoCorrection(autoCorrection);
- setSuggestedWords(
- suggestedWords, isSuggestionStripVisible(), true /* needsInputViewShown */);
+ setSuggestedWords(suggestedWords, isSuggestionStripVisible());
}
// Cache the auto-correction in accessibility code so we can speak it if the user
// touches a key that will insert it.
@@ -1502,14 +1494,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// punctuation suggestions (if it's disabled).
@Override
public void setNeutralSuggestionStrip() {
- setNeutralSuggestionStripInternal(true /* needsInputViewShown */);
+ setNeutralSuggestionStripInternal();
}
- private void setNeutralSuggestionStripInternal(final boolean needsInputViewShown) {
+ private void setNeutralSuggestionStripInternal() {
final SettingsValues currentSettings = mSettings.getCurrent();
final SuggestedWords neutralSuggestions = currentSettings.mBigramPredictionEnabled
? SuggestedWords.EMPTY : currentSettings.mSpacingAndPunctuations.mSuggestPuncList;
- setSuggestedWords(neutralSuggestions, isSuggestionStripVisible(), needsInputViewShown);
+ setSuggestedWords(neutralSuggestions, isSuggestionStripVisible());
}
// TODO: Make this private
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index abf831a28..5e144106f 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -147,6 +147,8 @@ public final class Suggest {
}
}
+ final boolean isPrediction = !wordComposer.isComposingWord();
+
// We allow auto-correction if we have a whitelisted word, or if the word is not a valid
// word of more than 1 char, except if the first suggestion is the same as the typed string
// because in this case if it's strong enough to auto-correct that will mistakenly designate
@@ -165,7 +167,7 @@ public final class Suggest {
// same time, it feels wrong that the SuggestedWord object includes information about
// the current settings. It may also be useful to know, when the setting is off, whether
// the word *would* have been auto-corrected.
- if (!isCorrectionEnabled || !allowsToBeAutoCorrected || !wordComposer.isComposingWord()
+ if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction
|| suggestionsSet.isEmpty() || wordComposer.hasDigits()
|| wordComposer.isMostlyCaps() || wordComposer.isResumed()
|| !mDictionaryFacilitator.hasMainDictionary()
@@ -225,10 +227,9 @@ public final class Suggest {
// TODO: this first argument is lying. If this is a whitelisted word which is an
// actual word, it says typedWordValid = false, which looks wrong. We should either
// rename the attribute or change the value.
- !allowsToBeAutoCorrected /* typedWordValid */,
+ !isPrediction && !allowsToBeAutoCorrected /* typedWordValid */,
hasAutoCorrection, /* willAutoCorrect */
- false /* isObsoleteSuggestions */,
- !wordComposer.isComposingWord() /* isPrediction */, sequenceNumber));
+ false /* isObsoleteSuggestions */, isPrediction, sequenceNumber));
}
// Retrieves suggestions for the batch input
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 46df3e88c..06bc90c97 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -69,7 +69,7 @@ public class SuggestedWords {
final boolean isPrediction,
final int sequenceNumber) {
this(suggestedWordInfoList, rawSuggestions,
- suggestedWordInfoList.isEmpty() ? null
+ (suggestedWordInfoList.isEmpty() || isPrediction) ? null
: suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
typedWordValid, willAutoCorrect, isObsoleteSuggestions, isPrediction,
sequenceNumber);
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 045d06f0e..f2f9f1e68 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1360,10 +1360,12 @@ public final class InputLogic {
}});
} else {
// We found suggestion spans in the word. We'll create the SuggestedWords out of
- // them, and make willAutoCorrect false.
+ // them, and make willAutoCorrect false. We make typedWordValid false, because the
+ // color of the word in the suggestion strip changes according to this parameter,
+ // and false gives the correct color.
final SuggestedWords suggestedWords = new SuggestedWords(suggestions,
null /* rawSuggestions */, typedWord,
- true /* typedWordValid */, false /* willAutoCorrect */,
+ false /* typedWordValid */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isPrediction */,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
mIsAutoCorrectionIndicatorOn = false;
diff --git a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java
index b99e281da..ed9c39602 100644
--- a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java
+++ b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java
@@ -38,6 +38,10 @@ public final class DictionaryHeader {
public static final String DICTIONARY_DATE_KEY = "date";
public static final String HAS_HISTORICAL_INFO_KEY = "HAS_HISTORICAL_INFO";
public static final String USES_FORGETTING_CURVE_KEY = "USES_FORGETTING_CURVE";
+ public static final String FORGETTING_CURVE_OCCURRENCES_TO_LEVEL_UP_KEY =
+ "FORGETTING_CURVE_OCCURRENCES_TO_LEVEL_UP";
+ public static final String FORGETTING_CURVE_PROBABILITY_VALUES_TABLE_ID_KEY =
+ "FORGETTING_CURVE_PROBABILITY_VALUES_TABLE_ID";
public static final String ATTRIBUTE_VALUE_TRUE = "1";
public DictionaryHeader(final int headerSize, final DictionaryOptions dictionaryOptions,
diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
index d3734d693..8c358cd50 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
@@ -50,6 +50,7 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
public final Locale mLocale;
private final String mDictName;
+ private Map<String, String> mAdditionalAttributeMap = null;
protected DecayingExpandableBinaryDictionaryBase(final Context context,
final String dictName, final Locale locale, final String dictionaryType,
@@ -78,7 +79,10 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
@Override
protected Map<String, String> getHeaderAttributeMap() {
- HashMap<String, String> attributeMap = new HashMap<String, String>();
+ final Map<String, String> attributeMap = new HashMap<String, String>();
+ if (mAdditionalAttributeMap != null) {
+ attributeMap.putAll(mAdditionalAttributeMap);
+ }
attributeMap.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY,
DictionaryHeader.ATTRIBUTE_VALUE_TRUE);
attributeMap.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY,
@@ -152,6 +156,13 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
asyncFlushBinaryDictionary();
}
+ @UsedForTesting
+ public void clearAndFlushDictionaryWithAdditionalAttributes(
+ final Map<String, String> attributeMap) {
+ mAdditionalAttributeMap = attributeMap;
+ clearAndFlushDictionary();
+ }
+
/* package */ void decayIfNeeded() {
runGCIfRequired(false /* mindsBlockByGC */);
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
index 8ea712835..afa8fe3a8 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
@@ -95,9 +95,9 @@ final class SuggestionStripLayoutHelper {
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
- private final int mSuggestionStripOption;
+ private final int mSuggestionStripOptions;
// These constants are the flag values of
- // {@link R.styleable#SuggestionStripView_suggestionStripOption} attribute.
+ // {@link R.styleable#SuggestionStripView_suggestionStripOptions} attribute.
private static final int AUTO_CORRECT_BOLD = 0x01;
private static final int AUTO_CORRECT_UNDERLINE = 0x02;
private static final int VALID_TYPED_WORD_BOLD = 0x04;
@@ -122,8 +122,8 @@ final class SuggestionStripLayoutHelper {
final TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView);
- mSuggestionStripOption = a.getInt(
- R.styleable.SuggestionStripView_suggestionStripOption, 0);
+ mSuggestionStripOptions = a.getInt(
+ R.styleable.SuggestionStripView_suggestionStripOptions, 0);
mAlphaObsoleted = ResourceUtils.getFraction(a,
R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
@@ -200,22 +200,24 @@ final class SuggestionStripLayoutHelper {
return null;
}
final String word = suggestedWords.getLabel(indexInSuggestedWords);
- final boolean isAutoCorrect = indexInSuggestedWords == 1
- && suggestedWords.mWillAutoCorrect;
- final boolean isTypedWordValid = indexInSuggestedWords == 0
- && suggestedWords.mTypedWordValid;
- if (!isAutoCorrect && !isTypedWordValid) {
+ // TODO: don't use the index to decide whether this is the auto-correction/typed word, as
+ // this is brittle
+ final boolean isAutoCorrection = suggestedWords.mWillAutoCorrect
+ && indexInSuggestedWords == SuggestedWords.INDEX_OF_AUTO_CORRECTION;
+ final boolean isTypedWordValid = suggestedWords.mTypedWordValid
+ && indexInSuggestedWords == SuggestedWords.INDEX_OF_TYPED_WORD;
+ if (!isAutoCorrection && !isTypedWordValid) {
return word;
}
final int len = word.length();
final Spannable spannedWord = new SpannableString(word);
- final int option = mSuggestionStripOption;
- if ((isAutoCorrect && (option & AUTO_CORRECT_BOLD) != 0)
- || (isTypedWordValid && (option & VALID_TYPED_WORD_BOLD) != 0)) {
+ final int options = mSuggestionStripOptions;
+ if ((isAutoCorrection && (options & AUTO_CORRECT_BOLD) != 0)
+ || (isTypedWordValid && (options & VALID_TYPED_WORD_BOLD) != 0)) {
spannedWord.setSpan(BOLD_SPAN, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
- if (isAutoCorrect && (option & AUTO_CORRECT_UNDERLINE) != 0) {
+ if (isAutoCorrection && (options & AUTO_CORRECT_UNDERLINE) != 0) {
spannedWord.setSpan(UNDERLINE_SPAN, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
return spannedWord;
@@ -242,22 +244,23 @@ final class SuggestionStripLayoutHelper {
return indexInSuggestedWords;
}
- private int getSuggestionTextColor(final int indexInSuggestedWords,
- final SuggestedWords suggestedWords) {
+ private int getSuggestionTextColor(final SuggestedWords suggestedWords,
+ final int indexInSuggestedWords) {
final int positionInStrip =
getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords);
- // TODO: Need to revisit this logic with bigram suggestions
- final boolean isSuggested = (indexInSuggestedWords != SuggestedWords.INDEX_OF_TYPED_WORD);
+ // Use identity for strings, not #equals : it's the typed word if it's the same object
+ final boolean isTypedWord =
+ suggestedWords.getWord(indexInSuggestedWords) == suggestedWords.mTypedWord;
final int color;
if (positionInStrip == mCenterPositionInStrip && suggestedWords.mWillAutoCorrect) {
color = mColorAutoCorrect;
- } else if (positionInStrip == mCenterPositionInStrip && suggestedWords.mTypedWordValid) {
+ } else if (isTypedWord && suggestedWords.mTypedWordValid) {
color = mColorValidTypedWord;
- } else if (isSuggested) {
- color = mColorSuggested;
- } else {
+ } else if (isTypedWord) {
color = mColorTypedWord;
+ } else {
+ color = mColorSuggested;
}
if (LatinImeLogger.sDBG && suggestedWords.size() > 1) {
// If we auto-correct, then the autocorrection is in slot 0 and the typed word
@@ -270,7 +273,7 @@ final class SuggestionStripLayoutHelper {
}
}
- if (suggestedWords.mIsObsoleteSuggestions && isSuggested) {
+ if (suggestedWords.mIsObsoleteSuggestions && !isTypedWord) {
return applyAlpha(color, mAlphaObsoleted);
}
return color;
@@ -438,7 +441,7 @@ final class SuggestionStripLayoutHelper {
// {@link SuggestionStripView#onClick(View)}.
wordView.setTag(indexInSuggestedWords);
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
- wordView.setTextColor(getSuggestionTextColor(positionInStrip, suggestedWords));
+ wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
if (SuggestionStripView.DBG) {
mDebugInfoViews.get(positionInStrip).setText(
suggestedWords.getDebugString(indexInSuggestedWords));
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripViewAccessor.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripViewAccessor.java
index 60f1c7a4e..52708455e 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripViewAccessor.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripViewAccessor.java
@@ -22,7 +22,6 @@ import com.android.inputmethod.latin.SuggestedWords;
* An object that gives basic control of a suggestion strip and some info on it.
*/
public interface SuggestionStripViewAccessor {
- public boolean hasSuggestionStripView();
public void showAddToDictionaryHint(final String word);
public boolean isShowingAddToDictionaryHint();
public void dismissAddToDictionaryHint();
diff --git a/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java b/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
index a1d641508..562ff9e8d 100644
--- a/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
+++ b/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
@@ -37,9 +37,9 @@ public final class LanguageModelParam {
// non-0. Thus, it's not meaningful to compare 10, 100, and so on.
// TODO: Revise the logic in ForgettingCurveUtils in native code.
private static final int UNIGRAM_PROBABILITY_FOR_VALID_WORD = 100;
- private static final int UNIGRAM_PROBABILITY_FOR_OOV_WORD = 10;
- private static final int BIGRAM_PROBABILITY_FOR_VALID_WORD = 0;
- private static final int BIGRAM_PROBABILITY_FOR_OOV_WORD = 0;
+ private static final int UNIGRAM_PROBABILITY_FOR_OOV_WORD = Dictionary.NOT_A_PROBABILITY;
+ private static final int BIGRAM_PROBABILITY_FOR_VALID_WORD = 10;
+ private static final int BIGRAM_PROBABILITY_FOR_OOV_WORD = Dictionary.NOT_A_PROBABILITY;
public final String mTargetWord;
public final int[] mWord0;