aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java78
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java8
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/FormatSpec.java3
-rw-r--r--java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java3
-rw-r--r--java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java6
5 files changed, 17 insertions, 81 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 6a0d6be9c..660b64cdf 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -147,18 +147,6 @@ public final class Suggest {
return firstSuggestedWordInfo;
}
- // Quality constants for dictionary match
- // In increasing order of quality
- // This source dictionary does not match the typed word.
- private static final int QUALITY_NO_MATCH = 0;
- // This source dictionary has a null locale, and the preferred locale is also null.
- private static final int QUALITY_MATCH_NULL = 1;
- // This source dictionary has a non-null locale different from the preferred locale. The
- // preferred locale may be null : this is still better than MATCH_NULL.
- private static final int QUALITY_MATCH_OTHER_LOCALE = 2;
- // This source dictionary matches the preferred locale.
- private static final int QUALITY_MATCH_PREFERRED_LOCALE = 3;
-
// Retrieves suggestions for non-batch input (typing, recorrection, predictions...)
// and calls the callback function with the suggestions.
private void getSuggestedWordsForNonBatchInput(final WordComposer wordComposer,
@@ -179,34 +167,18 @@ public final class Suggest {
final Locale locale = mDictionaryFacilitator.getLocale();
final ArrayList<SuggestedWordInfo> suggestionsContainer =
getTransformedSuggestedWordInfoList(wordComposer, suggestionResults,
- trailingSingleQuotesCount,
- // For transforming suggestions that don't come for any dictionary, we
- // use the currently most probable locale as it's our best bet.
- locale);
-
- boolean typedWordExistsInAnotherLanguage = false;
- int qualityOfFoundSourceDictionary = QUALITY_NO_MATCH;
- @Nullable Dictionary sourceDictionaryOfRemovedWord = null;
+ trailingSingleQuotesCount, locale);
+
+ boolean foundInDictionary = false;
+ Dictionary sourceDictionaryOfRemovedWord = null;
for (final SuggestedWordInfo info : suggestionsContainer) {
// Search for the best dictionary, defined as the first one with the highest match
// quality we can find.
- if (typedWordString.equals(info.mWord)) {
- if (locale.equals(info.mSourceDict.mLocale)) {
- if (qualityOfFoundSourceDictionary < QUALITY_MATCH_PREFERRED_LOCALE) {
- // Use this source if the old match had lower quality than this match
- sourceDictionaryOfRemovedWord = info.mSourceDict;
- qualityOfFoundSourceDictionary = QUALITY_MATCH_PREFERRED_LOCALE;
- }
- } else {
- final int matchQuality = (null == info.mSourceDict.mLocale)
- ? QUALITY_MATCH_NULL : QUALITY_MATCH_OTHER_LOCALE;
- if (qualityOfFoundSourceDictionary < matchQuality) {
- // Use this source if the old match had lower quality than this match
- sourceDictionaryOfRemovedWord = info.mSourceDict;
- qualityOfFoundSourceDictionary = matchQuality;
- }
- typedWordExistsInAnotherLanguage = true;
- }
+ if (!foundInDictionary && typedWordString.equals(info.mWord)) {
+ // Use this source if the old match had lower quality than this match
+ sourceDictionaryOfRemovedWord = info.mSourceDict;
+ foundInDictionary = true;
+ break;
}
}
@@ -215,22 +187,8 @@ public final class Suggest {
final SuggestedWordInfo whitelistedWordInfo =
getWhitelistedWordInfoOrNull(suggestionsContainer);
- final String whitelistedWord;
- if (null != whitelistedWordInfo &&
- (mDictionaryFacilitator.isForLocale(whitelistedWordInfo.mSourceDict.mLocale)
- || (!typedWordExistsInAnotherLanguage
- && !hasPlausibleCandidateInAnyOtherLanguage(suggestionsContainer,
- consideredWord, whitelistedWordInfo)))) {
- // We'll use the whitelist candidate if we are confident the user is typing in the
- // language of the dictionary it's coming from, or if there is no plausible candidate
- // coming from another language.
- whitelistedWord = whitelistedWordInfo.mWord;
- } else {
- // If on the contrary we are not confident in the current language and we have
- // at least a plausible candidate in any other language, then we don't use this
- // whitelist candidate.
- whitelistedWord = null;
- }
+ final String whitelistedWord = whitelistedWordInfo == null
+ ? null : whitelistedWordInfo.mWord;
final boolean resultsArePredictions = !wordComposer.isComposingWord();
// We allow auto-correction if whitelisting is not required or the word is whitelisted,
@@ -325,20 +283,6 @@ public final class Suggest {
false /* isObsoleteSuggestions */, inputStyle, sequenceNumber));
}
- private boolean hasPlausibleCandidateInAnyOtherLanguage(
- final ArrayList<SuggestedWordInfo> suggestionsContainer, final String consideredWord,
- final SuggestedWordInfo whitelistedWordInfo) {
- for (final SuggestedWordInfo info : suggestionsContainer) {
- if (whitelistedWordInfo.mSourceDict.mLocale.equals(info.mSourceDict.mLocale)) {
- continue;
- }
- return AutoCorrectionUtils.suggestionExceedsThreshold(info, consideredWord,
- mPlausibilityThreshold);
- }
- // No candidate in another language
- return false;
- }
-
// Retrieves suggestions for the batch input
// and calls the callback function with the suggestions.
private void getSuggestedWordsForBatchInput(final WordComposer wordComposer,
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 7e513e5c3..f02a63e57 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1607,15 +1607,11 @@ public final class InputLogic {
// First, add the committed word to the list of suggestions.
suggestions.add(committedWordString);
for (final Object span : spans) {
- // If this is a suggestion span, we check that the locale is the right one, and
- // that the word is not the committed word. That should mostly be the case.
+ // If this is a suggestion span, we check that the word is not the committed word.
+ // That should mostly be the case.
// Given this, we add it to the list of suggestions, otherwise we discard it.
if (span instanceof SuggestionSpan) {
final SuggestionSpan suggestionSpan = (SuggestionSpan)span;
- if (!suggestionSpan.getLocale().equals(
- inputTransaction.mSettingsValues.mLocale.toString())) {
- continue;
- }
for (final String suggestion : suggestionSpan.getSuggestions()) {
if (!suggestion.equals(committedWordString)) {
suggestions.add(suggestion);
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index 32a746d37..288261bf0 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -180,11 +180,10 @@ public final class FormatSpec {
public static final int VERSION402 = 402;
public static final int VERSION403 = 403;
public static final int VERSION4 = VERSION403;
- public static final int VERSION4_DEV = VERSION403;
public static final int MINIMUM_SUPPORTED_STATIC_VERSION = VERSION202;
public static final int MAXIMUM_SUPPORTED_STATIC_VERSION = VERSION_DELIGHT3;
static final int MINIMUM_SUPPORTED_DYNAMIC_VERSION = VERSION4;
- static final int MAXIMUM_SUPPORTED_DYNAMIC_VERSION = VERSION4_DEV;
+ static final int MAXIMUM_SUPPORTED_DYNAMIC_VERSION = VERSION403;
// TODO: Make this value adaptative to content data, store it in the header, and
// use it in the reading code.
diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
index 9a8a7b9e0..fe52cfe6a 100644
--- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
@@ -27,16 +27,13 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.SwitchPreference;
import android.preference.TwoStatePreference;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.widget.ListView;
import android.widget.TextView;
-import android.widget.Toast;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.R;
diff --git a/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java
index 24c39ebc4..f7c5f6760 100644
--- a/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java
@@ -24,8 +24,8 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
-import android.preference.CheckBoxPreference;
import android.preference.Preference;
+import android.preference.TwoStatePreference;
import com.android.inputmethod.dictionarypack.DictionarySettingsActivity;
import com.android.inputmethod.latin.R;
@@ -88,8 +88,8 @@ public final class CorrectionSettingsFragment extends SubScreenFragment {
}
private void ensureConsistencyOfAutoCorrectionSettings() {
- final CheckBoxPreference autoCorrectionPref = (CheckBoxPreference) findPreference(
- Settings.PREF_AUTO_CORRECTION);
+ final TwoStatePreference autoCorrectionPref = (TwoStatePreference)
+ findPreference(Settings.PREF_AUTO_CORRECTION);
if (!autoCorrectionPref.isChecked()) {
setPreferenceEnabled(Settings.PREF_BIGRAM_PREDICTIONS, false);
}