aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java24
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java2
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java30
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java6
4 files changed, 31 insertions, 31 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 010473f05..5a1232064 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1438,8 +1438,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mCandidateView != null) {
mCandidateView.setSuggestions(words);
- if (mCandidateView.isConfigCandidateHighlightFontColorEnabled())
- mKeyboardSwitcher.onAutoCorrectionStateChanged(words.hasAutoCorrectionWord());
+ if (mCandidateView.isConfigCandidateHighlightFontColorEnabled()) {
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(
+ words.hasWordAboveAutoCorrectionScoreThreshold());
+ }
}
}
@@ -1460,8 +1462,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private SuggestedWords.Builder getTypedSuggestions(WordComposer word) {
- return mSuggest.getSuggestedWordBuilder(
- mKeyboardSwitcher.getInputView(), word, false, null);
+ return mSuggest.getSuggestedWordBuilder(mKeyboardSwitcher.getInputView(), word, null);
}
private void showCorrections(WordAlternatives alternatives) {
@@ -1477,9 +1478,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
CharSequence prevWord = EditingUtils.getPreviousWord(getCurrentInputConnection(),
mWordSeparators);
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
- mKeyboardSwitcher.getInputView(), word, false, prevWord);
- // long stopTime = System.currentTimeMillis(); // TIME MEASUREMENT!
- // Log.d("LatinIME","Suggest Total Time - " + (stopTime - startTime));
+ mKeyboardSwitcher.getInputView(), word, prevWord);
int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
mKeyboardSwitcher.setPreferredLetters(nextLettersFrequencies);
@@ -1506,8 +1505,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void showSuggestions(SuggestedWords suggestedWords, CharSequence typedWord) {
setSuggestions(suggestedWords);
if (suggestedWords.size() > 0) {
- if (suggestedWords.mHasMinimalSuggestion
- && !suggestedWords.mTypedWordValid && suggestedWords.size() > 1) {
+ if (suggestedWords.hasAutoCorrectionWord()) {
mBestWord = suggestedWords.getWord(1);
} else {
mBestWord = typedWord;
@@ -2067,9 +2065,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final String currentAutoCorrectionSetting = sp.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
- mResources.getString(R.string.auto_correction_threshold_mode_value_modest));
+ mResources.getString(R.string.auto_correction_threshold_mode_index_modest));
final String[] autoCorrectionThresholdValues = mResources.getStringArray(
- R.array.auto_correction_threshold_mode_values);
+ R.array.auto_correction_threshold_values);
// When autoCrrectionThreshold is greater than 1.0, auto correction is virtually turned off.
double autoCorrectionThreshold = Double.MAX_VALUE;
try {
@@ -2094,9 +2092,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean isAutoCorrectEnabled(SharedPreferences sp) {
final String currentAutoCorrectionSetting = sp.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
- mResources.getString(R.string.auto_correction_threshold_mode_value_modest));
+ mResources.getString(R.string.auto_correction_threshold_mode_index_modest));
final String autoCorrectionOff = mResources.getString(
- R.string.auto_correction_threshold_mode_value_off);
+ R.string.auto_correction_threshold_mode_index_off);
return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index d2ec917d0..b8590a76e 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -79,7 +79,7 @@ public class Settings extends PreferenceActivity
private void ensureConsistencyOfAutoCorrectionSettings() {
final String autoCorrectionOff = getResources().getString(
- R.string.auto_correction_threshold_mode_value_off);
+ R.string.auto_correction_threshold_mode_index_off);
final String currentSetting = mAutoCorrectionThreshold.getValue();
mBigramSuggestion.setEnabled(!currentSetting.equals(autoCorrectionOff));
}
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 77e0a3dde..a30ec1587 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -95,7 +95,6 @@ public class Suggest implements Dictionary.WordCallback {
ArrayList<CharSequence> mBigramSuggestions = new ArrayList<CharSequence>();
private ArrayList<CharSequence> mStringPool = new ArrayList<CharSequence>();
private boolean mHaveCorrection;
- private CharSequence mOriginalWord;
private String mLowerOriginalWord;
// TODO: Remove these member variables by passing more context to addWord() callback method
@@ -197,14 +196,13 @@ public class Suggest implements Dictionary.WordCallback {
* @return suggested words object.
*/
public SuggestedWords getSuggestions(View view, WordComposer wordComposer,
- boolean includeTypedWordIfValid, CharSequence prevWordForBigram) {
- return getSuggestedWordBuilder(view, wordComposer, includeTypedWordIfValid,
- prevWordForBigram).build();
+ CharSequence prevWordForBigram) {
+ return getSuggestedWordBuilder(view, wordComposer, prevWordForBigram).build();
}
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
public SuggestedWords.Builder getSuggestedWordBuilder(View view, WordComposer wordComposer,
- boolean includeTypedWordIfValid, CharSequence prevWordForBigram) {
+ CharSequence prevWordForBigram) {
LatinImeLogger.onStartSuggestion(prevWordForBigram);
mHaveCorrection = false;
mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized();
@@ -214,13 +212,13 @@ public class Suggest implements Dictionary.WordCallback {
Arrays.fill(mNextLettersFrequencies, 0);
// Save a lowercase version of the original word
- mOriginalWord = wordComposer.getTypedWord();
- if (mOriginalWord != null) {
- final String mOriginalWordString = mOriginalWord.toString();
- mOriginalWord = mOriginalWordString;
- mLowerOriginalWord = mOriginalWordString.toLowerCase();
+ CharSequence typedWord = wordComposer.getTypedWord();
+ if (typedWord != null) {
+ final String typedWordString = typedWord.toString();
+ typedWord = typedWordString;
+ mLowerOriginalWord = typedWordString.toLowerCase();
// Treating USER_TYPED as UNIGRAM suggestion for logging now.
- LatinImeLogger.onAddSuggestedWord(mOriginalWordString, Suggest.DIC_USER_TYPED,
+ LatinImeLogger.onAddSuggestedWord(typedWordString, Suggest.DIC_USER_TYPED,
Dictionary.DataType.UNIGRAM);
} else {
mLowerOriginalWord = "";
@@ -278,7 +276,7 @@ public class Suggest implements Dictionary.WordCallback {
mContactsDictionary.getWords(wordComposer, this, mNextLettersFrequencies);
}
- if (mSuggestions.size() > 0 && isValidWord(mOriginalWord)
+ if (mSuggestions.size() > 0 && isValidWord(typedWord)
&& (mCorrectionMode == CORRECTION_FULL
|| mCorrectionMode == CORRECTION_FULL_BIGRAM)) {
mHaveCorrection = true;
@@ -290,9 +288,9 @@ public class Suggest implements Dictionary.WordCallback {
// TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive.
final double normalizedScore = Utils.calcNormalizedScore(
- mOriginalWord, mSuggestions.get(0), mPriorities[0]);
+ typedWord, mSuggestions.get(0), mPriorities[0]);
if (LatinImeLogger.sDBG) {
- Log.d(TAG, "Normalized " + mOriginalWord + "," + mSuggestions.get(0) + ","
+ Log.d(TAG, "Normalized " + typedWord + "," + mSuggestions.get(0) + ","
+ mPriorities[0] + normalizedScore
+ "(" + mAutoCorrectionThreshold + ")");
}
@@ -301,8 +299,8 @@ public class Suggest implements Dictionary.WordCallback {
}
}
}
- if (mOriginalWord != null) {
- mSuggestions.add(0, mOriginalWord.toString());
+ if (typedWord != null) {
+ mSuggestions.add(0, typedWord.toString());
}
if (mAutoTextEnabled) {
int i = 0;
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 3a3176e54..0bb7c66d1 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -53,7 +53,11 @@ public class SuggestedWords {
}
public boolean hasAutoCorrectionWord() {
- return mHasMinimalSuggestion && ((size() >= 1 && !mTypedWordValid) || mTypedWordValid);
+ return mHasMinimalSuggestion && size() > 1 && !mTypedWordValid;
+ }
+
+ public boolean hasWordAboveAutoCorrectionScoreThreshold() {
+ return mHasMinimalSuggestion && ((size() > 1 && !mTypedWordValid) || mTypedWordValid);
}
public static class Builder {