aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/InputTypeUtils.java13
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java3
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java28
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java8
5 files changed, 32 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/InputTypeUtils.java b/java/src/com/android/inputmethod/latin/InputTypeUtils.java
index 9a4503bf4..55414b809 100644
--- a/java/src/com/android/inputmethod/latin/InputTypeUtils.java
+++ b/java/src/com/android/inputmethod/latin/InputTypeUtils.java
@@ -17,6 +17,7 @@
package com.android.inputmethod.latin;
import android.text.InputType;
+import android.view.inputmethod.EditorInfo;
public final class InputTypeUtils implements InputType {
private static final int WEB_TEXT_PASSWORD_INPUT_TYPE =
@@ -35,6 +36,7 @@ public final class InputTypeUtils implements InputType {
InputType.TYPE_TEXT_VARIATION_URI,
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD };
+ public static final int IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1;
private InputTypeUtils() {
// This utility class is not publicly instantiable.
@@ -102,4 +104,15 @@ public final class InputTypeUtils implements InputType {
}
return true;
}
+
+ public static int getActionIdFromEditorInfo(final EditorInfo editorInfo) {
+ final int actionId = editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
+ if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
+ return EditorInfo.IME_ACTION_NONE;
+ } else if (editorInfo.actionLabel != null) {
+ return IME_ACTION_CUSTOM_LABEL;
+ } else {
+ return actionId;
+ }
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index f1f50fe8f..df733c55a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1588,10 +1588,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final boolean dismissGestureFloatingPreviewText) {
showSuggestionStrip(suggestedWords, null);
final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
+ mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
if (dismissGestureFloatingPreviewText) {
mainKeyboardView.dismissGestureFloatingPreviewText();
- } else {
- mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
}
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index f592a2515..c5930a935 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -135,7 +135,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static int readKeyPreviewPopupDismissDelay(final SharedPreferences prefs,
final Resources res) {
- // TODO: use mKeyPreviewPopupDismissDelayRawValue instead of reading it again here.
return Integer.parseInt(prefs.getString(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout))));
@@ -186,7 +185,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
}
public static boolean readUsabilityStudyMode(final SharedPreferences prefs) {
- // TODO: use mUsabilityStudyMode instead of reading it again here
return prefs.getBoolean(DebugSettings.PREF_USABILITY_STUDY_MODE, true);
}
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index fac85a8cc..9a2024618 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -51,14 +51,8 @@ public final class SettingsValues {
public final boolean mSoundOn;
public final boolean mKeyPreviewPopupOn;
private final String mVoiceMode;
- private final String mAutoCorrectionThresholdRawValue;
- public final String mShowSuggestionsSetting;
- @SuppressWarnings("unused") // TODO: Use this
- private final boolean mUsabilityStudyMode;
public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsLanguageSwitchKey;
- @SuppressWarnings("unused") // TODO: Use this
- private final String mKeyPreviewPopupDismissDelayRawValue;
public final boolean mUseContactsDict;
public final boolean mUseDoubleSpacePeriod;
// Use bigrams to predict the next word when there is no input for it yet
@@ -122,20 +116,15 @@ public final class SettingsValues {
final String voiceModeMain = res.getString(R.string.voice_mode_main);
final String voiceModeOff = res.getString(R.string.voice_mode_off);
mVoiceMode = prefs.getString(Settings.PREF_VOICE_MODE, voiceModeMain);
- mAutoCorrectionThresholdRawValue = prefs.getString(Settings.PREF_AUTO_CORRECTION_THRESHOLD,
+ final String autoCorrectionThresholdRawValue = prefs.getString(
+ Settings.PREF_AUTO_CORRECTION_THRESHOLD,
res.getString(R.string.auto_correction_threshold_mode_index_modest));
- mShowSuggestionsSetting = prefs.getString(Settings.PREF_SHOW_SUGGESTIONS_SETTING,
- res.getString(R.string.prefs_suggestion_visibility_default_value));
- mUsabilityStudyMode = Settings.readUsabilityStudyMode(prefs);
mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean(
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false);
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs);
- mKeyPreviewPopupDismissDelayRawValue = prefs.getString(
- Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
- Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout)));
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true);
- mAutoCorrectEnabled = readAutoCorrectEnabled(res, mAutoCorrectionThresholdRawValue);
+ mAutoCorrectEnabled = readAutoCorrectEnabled(res, autoCorrectionThresholdRawValue);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
// Compute other readable settings
@@ -143,7 +132,7 @@ public final class SettingsValues {
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
mAutoCorrectionThreshold = readAutoCorrectionThreshold(res,
- mAutoCorrectionThresholdRawValue);
+ autoCorrectionThresholdRawValue);
mVoiceKeyEnabled = mVoiceMode != null && !mVoiceMode.equals(voiceModeOff);
mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain);
final boolean gestureInputEnabledByBuildConfig = res.getBoolean(
@@ -154,7 +143,10 @@ public final class SettingsValues {
mGestureFloatingPreviewTextEnabled = prefs.getBoolean(
Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
- mSuggestionVisibility = createSuggestionVisibility(res);
+ final String showSuggestionsSetting = prefs.getString(
+ Settings.PREF_SHOW_SUGGESTIONS_SETTING,
+ res.getString(R.string.prefs_suggestion_visibility_default_value));
+ mSuggestionVisibility = createSuggestionVisibility(res, showSuggestionsSetting);
}
public boolean isApplicationSpecifiedCompletionsOn() {
@@ -271,8 +263,8 @@ public final class SettingsValues {
SUGGESTION_VISIBILITY_HIDE_VALUE
};
- private int createSuggestionVisibility(final Resources res) {
- final String suggestionVisiblityStr = mShowSuggestionsSetting;
+ private static int createSuggestionVisibility(final Resources res,
+ final String suggestionVisiblityStr) {
for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) {
if (suggestionVisiblityStr.equals(res.getString(visibility))) {
return visibility;
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index fe2908428..eb0ec3990 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -31,6 +31,7 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import java.util.List;
@@ -239,7 +240,14 @@ public final class SubtypeSwitcher {
return mNeedsToDisplayLanguage.getValue();
}
+ private static Locale sForcedLocaleForTesting = null;
+ @UsedForTesting
+ void forceLocale(final Locale locale) {
+ sForcedLocaleForTesting = locale;
+ }
+
public Locale getCurrentSubtypeLocale() {
+ if (null != sForcedLocaleForTesting) return sForcedLocaleForTesting;
return SubtypeLocale.getSubtypeLocale(getCurrentSubtype());
}