aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java113
1 files changed, 57 insertions, 56 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 46b735ab2..a34d883ba 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -63,6 +63,7 @@ import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
+import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -119,7 +120,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private View mCandidateViewContainer;
private CandidateView mCandidateView;
private Suggest mSuggest;
- private CompletionInfo[] mCompletions;
+ private CompletionInfo[] mApplicationSpecifiedCompletions;
private AlertDialog mOptionsDialog;
@@ -141,7 +142,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private CharSequence mBestWord;
private boolean mPredicting;
private boolean mPredictionOn;
- private boolean mCompletionOn;
+ private boolean mApplicationSpecifiedCompletionOn;
private boolean mHasDictionary;
private boolean mAutoSpace;
private boolean mJustAddedAutoSpace;
@@ -393,7 +394,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
int[] dictionaries = getDictionary(orig);
mSuggest = new Suggest(this, dictionaries);
- loadAndSetAutoCompletionThreshold(prefs);
+ loadAndSetAutoCorrectionThreshold(prefs);
if (mUserDictionary != null) mUserDictionary.close();
mUserDictionary = new UserDictionary(this, locale);
if (mContactsDictionary == null) {
@@ -519,8 +520,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mVoiceConnector.resetVoiceStates(isPasswordVariation(variation));
mInputTypeNoAutoCorrect = false;
mPredictionOn = false;
- mCompletionOn = false;
- mCompletions = null;
+ mApplicationSpecifiedCompletionOn = false;
+ mApplicationSpecifiedCompletions = null;
mEnteredText = null;
final int mode;
@@ -579,7 +580,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
mPredictionOn = false;
- mCompletionOn = isFullscreenMode();
+ mApplicationSpecifiedCompletionOn = isFullscreenMode();
}
break;
default:
@@ -654,7 +655,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
super.onFinishInput();
LatinImeLogger.commit();
- mKeyboardSwitcher.onAutoCompletionStateChanged(false);
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(false);
mVoiceConnector.flushVoiceInputLogs(mConfigurationChanging);
@@ -789,7 +790,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void hideWindow() {
LatinImeLogger.commit();
- mKeyboardSwitcher.onAutoCompletionStateChanged(false);
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(false);
if (TRACE) Debug.stopMethodTracing();
if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
@@ -803,22 +804,24 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
- public void onDisplayCompletions(CompletionInfo[] completions) {
+ public void onDisplayCompletions(CompletionInfo[] applicationSpecifiedCompletions) {
if (DEBUG) {
Log.i("foo", "Received completions:");
- for (int i=0; i<(completions != null ? completions.length : 0); i++) {
- Log.i("foo", " #" + i + ": " + completions[i]);
+ final int count = (applicationSpecifiedCompletions != null)
+ ? applicationSpecifiedCompletions.length : 0;
+ for (int i = 0; i < count; i++) {
+ Log.i("foo", " #" + i + ": " + applicationSpecifiedCompletions[i]);
}
}
- if (mCompletionOn) {
- mCompletions = completions;
- if (completions == null) {
+ if (mApplicationSpecifiedCompletionOn) {
+ mApplicationSpecifiedCompletions = applicationSpecifiedCompletions;
+ if (applicationSpecifiedCompletions == null) {
clearSuggestions();
return;
}
SuggestedWords.Builder builder = new SuggestedWords.Builder()
- .setApplicationSpecifiedCompletions(completions)
+ .setApplicationSpecifiedCompletions(applicationSpecifiedCompletions)
.setTypedWordValid(true)
.setHasMinimalSuggestion(true);
// When in fullscreen mode, show completions generated by the application
@@ -1291,7 +1294,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
boolean pickedDefault = false;
// Handle separator
- InputConnection ic = getCurrentInputConnection();
+ final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ic.beginBatchEdit();
abortCorrection(false);
@@ -1392,8 +1395,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean isCandidateStripVisible() {
boolean forceVisible = mCandidateView.isShowingAddToDictionaryHint()
|| TextEntryState.isCorrecting();
- return forceVisible || (isSuggestionShown()
- && (isPredictionOn() || mCompletionOn || isShowingPunctuationList()));
+ return forceVisible || (
+ isSuggestionShown() && (isPredictionOn() || mApplicationSpecifiedCompletionOn
+ || isShowingPunctuationList()));
}
public void switchToKeyboardView() {
@@ -1431,7 +1435,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mCandidateView != null) {
mCandidateView.setSuggestions(words);
if (mCandidateView.isConfigCandidateHighlightFontColorEnabled())
- mKeyboardSwitcher.onAutoCompletionStateChanged(words.hasAutoCorrectionWord());
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(words.hasAutoCorrectionWord());
}
}
@@ -1537,9 +1541,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ic != null) {
ic.beginBatchEdit();
}
- if (mCompletionOn && mCompletions != null && index >= 0
- && index < mCompletions.length) {
- CompletionInfo ci = mCompletions[index];
+ if (mApplicationSpecifiedCompletionOn && mApplicationSpecifiedCompletions != null
+ && index >= 0 && index < mApplicationSpecifiedCompletions.length) {
+ CompletionInfo ci = mApplicationSpecifiedCompletions[index];
if (ic != null) {
ic.commitCompletion(ci);
}
@@ -1650,7 +1654,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
break;
}
}
- // If we didn't find a match, at least suggest completions
+ // If we didn't find a match, at least suggest corrections.
if (foundWord == null
&& (mSuggest.isValidWord(touching.mWord)
|| mSuggest.isValidWord(touching.mWord.toString().toLowerCase()))) {
@@ -2038,7 +2042,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs);
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs);
- loadAndSetAutoCompletionThreshold(prefs);
+ loadAndSetAutoCorrectionThreshold(prefs);
mVoiceConnector.loadSettings(attribute, prefs);
@@ -2049,50 +2053,47 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
/**
- * load Auto completion threshold from SharedPreferences,
- * and modify mSuggest's threshold.
+ * Load Auto correction threshold from SharedPreferences, and modify mSuggest's threshold.
*/
- private void loadAndSetAutoCompletionThreshold(SharedPreferences sp) {
+ private void loadAndSetAutoCorrectionThreshold(SharedPreferences sp) {
// When mSuggest is not initialized, cannnot modify mSuggest's threshold.
if (mSuggest == null) return;
- // When auto completion setting is turned off, the threshold is ignored.
+ // When auto correction setting is turned off, the threshold is ignored.
if (!isAutoCorrectEnabled(sp)) return;
- final String currentAutoCompletionSetting = sp.getString(
- Settings.PREF_AUTO_COMPLETION_THRESHOLD,
- mResources.getString(R.string.auto_completion_threshold_mode_value_modest));
- final String[] autoCompletionThresholdValues = mResources.getStringArray(
- R.array.auto_complete_threshold_values);
- // When autoCompletionThreshold is greater than 1.0,
- // auto completion is virtually turned off.
- double autoCompletionThreshold = Double.MAX_VALUE;
+ final String currentAutoCorrectionSetting = sp.getString(
+ Settings.PREF_AUTO_CORRECTION_THRESHOLD,
+ mResources.getString(R.string.auto_correction_threshold_mode_value_modest));
+ final String[] autoCorrectionThresholdValues = mResources.getStringArray(
+ R.array.auto_correction_threshold_mode_values);
+ // When autoCrrectionThreshold is greater than 1.0, auto correction is virtually turned off.
+ double autoCorrectionThreshold = Double.MAX_VALUE;
try {
- final int arrayIndex = Integer.valueOf(currentAutoCompletionSetting);
- if (arrayIndex >= 0 && arrayIndex < autoCompletionThresholdValues.length) {
- autoCompletionThreshold = Double.parseDouble(
- autoCompletionThresholdValues[arrayIndex]);
+ final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting);
+ if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) {
+ autoCorrectionThreshold = Double.parseDouble(
+ autoCorrectionThresholdValues[arrayIndex]);
}
} catch (NumberFormatException e) {
- // Whenever the threshold settings are correct,
- // never come here.
- autoCompletionThreshold = Double.MAX_VALUE;
- Log.w(TAG, "Cannot load auto completion threshold setting."
- + " currentAutoCompletionSetting: " + currentAutoCompletionSetting
- + ", autoCompletionThresholdValues: "
- + Arrays.toString(autoCompletionThresholdValues));
+ // Whenever the threshold settings are correct, never come here.
+ autoCorrectionThreshold = Double.MAX_VALUE;
+ Log.w(TAG, "Cannot load auto correction threshold setting."
+ + " currentAutoCorrectionSetting: " + currentAutoCorrectionSetting
+ + ", autoCorrectionThresholdValues: "
+ + Arrays.toString(autoCorrectionThresholdValues));
}
// TODO: This should be refactored :
- // setAutoCompleteThreshold should be called outside of this method.
- mSuggest.setAutoCompleteThreshold(autoCompletionThreshold);
+ // setAutoCorrectionThreshold should be called outside of this method.
+ mSuggest.setAutoCorrectionThreshold(autoCorrectionThreshold);
}
private boolean isAutoCorrectEnabled(SharedPreferences sp) {
- final String currentAutoCompletionSetting = sp.getString(
- Settings.PREF_AUTO_COMPLETION_THRESHOLD,
- mResources.getString(R.string.auto_completion_threshold_mode_value_modest));
- final String autoCompletionOff = mResources.getString(
- R.string.auto_completion_threshold_mode_value_off);
- return !currentAutoCompletionSetting.equals(autoCompletionOff);
+ final String currentAutoCorrectionSetting = sp.getString(
+ Settings.PREF_AUTO_CORRECTION_THRESHOLD,
+ mResources.getString(R.string.auto_correction_threshold_mode_value_modest));
+ final String autoCorrectionOff = mResources.getString(
+ R.string.auto_correction_threshold_mode_value_off);
+ return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
}
private boolean isBigramSuggestionEnabled(SharedPreferences sp) {
@@ -2166,7 +2167,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
p.println(" mPredicting=" + mPredicting);
p.println(" mAutoCorrectOn=" + mAutoCorrectOn);
p.println(" mAutoSpace=" + mAutoSpace);
- p.println(" mCompletionOn=" + mCompletionOn);
+ p.println(" mApplicationSpecifiedCompletionOn=" + mApplicationSpecifiedCompletionOn);
p.println(" TextEntryState.state=" + TextEntryState.getState());
p.println(" mSoundOn=" + mSoundOn);
p.println(" mVibrateOn=" + mVibrateOn);