aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-07-22 10:18:38 -0700
committerTadashi G. Takaoka <takaoka@google.com>2014-07-27 14:47:07 +0900
commitab661e3ef886a36b02fe094864ae4be6a3260f71 (patch)
tree7a2c8175549d184938d4769c73685673e2d2ad5b /java/src/com/android/inputmethod/latin/settings/SettingsValues.java
parent825243bfdd6fb63c2ef8bf99024bb06e6f52e946 (diff)
downloadlatinime-ab661e3ef886a36b02fe094864ae4be6a3260f71.tar.gz
latinime-ab661e3ef886a36b02fe094864ae4be6a3260f71.tar.xz
latinime-ab661e3ef886a36b02fe094864ae4be6a3260f71.zip
Make "Show correction suggestions" as a binary option
Formerly "Show correction suggestions" had three options, "always show", "show in portrait mode", and "always hide". The reason behind "show in portrait mode" was that there may not be enough screen estate in landscape mode to show suggestions. Because recent phone devices have relatively large screen, we decide to remove "show in portrait mode" option. Bug: 15780939 Change-Id: I896d737452c3893d43ce20bd88127f10c1eb3d83
Diffstat (limited to 'java/src/com/android/inputmethod/latin/settings/SettingsValues.java')
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java63
1 files changed, 24 insertions, 39 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index 8de5fed07..39e834f84 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -85,9 +85,8 @@ public final class SettingsValues {
public final int mKeyPreviewPopupDismissDelay;
private final boolean mAutoCorrectEnabled;
public final float mAutoCorrectionThreshold;
- // TODO: Rename this to mAutoCorrectionEnabledPerUserSettings.
- public final boolean mAutoCorrectionEnabled;
- public final int mSuggestionVisibility;
+ public final boolean mAutoCorrectionEnabledPerUserSettings;
+ private final boolean mSuggestionsEnabledPerUserSettings;
public final int mDisplayOrientation;
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
@@ -155,11 +154,9 @@ public final class SettingsValues {
mGestureFloatingPreviewTextEnabled = prefs.getBoolean(
Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
mPhraseGestureEnabled = Settings.readPhraseGestureEnabled(prefs, res);
- mAutoCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
- final String showSuggestionsSetting = prefs.getString(
- Settings.PREF_SHOW_SUGGESTIONS_SETTING,
- res.getString(R.string.prefs_suggestion_visibility_default_value));
- mSuggestionVisibility = createSuggestionVisibility(res, showSuggestionsSetting);
+ mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled
+ && !mInputAttributes.mInputTypeNoAutoCorrect;
+ mSuggestionsEnabledPerUserSettings = readSuggestionsEnabled(prefs);
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
prefs, mAdditionalFeaturesSettingValues);
mIsInternal = Settings.isInternal(prefs);
@@ -193,17 +190,13 @@ public final class SettingsValues {
return mInputAttributes.mApplicationSpecifiedCompletionOn;
}
- // TODO: Rename this to needsToLookupSuggestions().
- public boolean isSuggestionsRequested() {
+ public boolean needsToLookupSuggestions() {
return mInputAttributes.mShouldShowSuggestions
- && (mAutoCorrectionEnabled
- || isCurrentOrientationAllowingSuggestionsPerUserSettings());
+ && (mAutoCorrectionEnabledPerUserSettings || isSuggestionsEnabledPerUserSettings());
}
- public boolean isCurrentOrientationAllowingSuggestionsPerUserSettings() {
- return (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_VALUE)
- || (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_ONLY_PORTRAIT_VALUE
- && mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT);
+ public boolean isSuggestionsEnabledPerUserSettings() {
+ return mSuggestionsEnabledPerUserSettings;
}
public boolean isWordSeparator(final int code) {
@@ -263,26 +256,18 @@ public final class SettingsValues {
return null == appWorkaroundUtils ? false : appWorkaroundUtils.isBrokenByRecorrection();
}
- private static final int SUGGESTION_VISIBILITY_SHOW_VALUE =
- R.string.prefs_suggestion_visibility_show_value;
- private static final int SUGGESTION_VISIBILITY_SHOW_ONLY_PORTRAIT_VALUE =
- R.string.prefs_suggestion_visibility_show_only_portrait_value;
- private static final int SUGGESTION_VISIBILITY_HIDE_VALUE =
- R.string.prefs_suggestion_visibility_hide_value;
- private static final int[] SUGGESTION_VISIBILITY_VALUE_ARRAY = new int[] {
- SUGGESTION_VISIBILITY_SHOW_VALUE,
- SUGGESTION_VISIBILITY_SHOW_ONLY_PORTRAIT_VALUE,
- SUGGESTION_VISIBILITY_HIDE_VALUE
- };
-
- 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;
- }
+ private static final String SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE = "2";
+
+ private static boolean readSuggestionsEnabled(final SharedPreferences prefs) {
+ if (prefs.contains(Settings.PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE)) {
+ final boolean alwaysHide = SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE.equals(
+ prefs.getString(Settings.PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE, null));
+ prefs.edit()
+ .remove(Settings.PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE)
+ .putBoolean(Settings.PREF_SHOW_SUGGESTIONS, !alwaysHide)
+ .apply();
}
- throw new RuntimeException("Bug: visibility string is not configured correctly");
+ return prefs.getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true);
}
private static boolean readBigramPredictionEnabled(final SharedPreferences prefs,
@@ -396,10 +381,10 @@ public final class SettingsValues {
sb.append("" + mAutoCorrectEnabled);
sb.append("\n mAutoCorrectionThreshold = ");
sb.append("" + mAutoCorrectionThreshold);
- sb.append("\n mAutoCorrectionEnabled = ");
- sb.append("" + mAutoCorrectionEnabled);
- sb.append("\n mSuggestionVisibility = ");
- sb.append("" + mSuggestionVisibility);
+ sb.append("\n mAutoCorrectionEnabledPerUserSettings = ");
+ sb.append("" + mAutoCorrectionEnabledPerUserSettings);
+ sb.append("\n mSuggestionsEnabledPerUserSettings = ");
+ sb.append("" + mSuggestionsEnabledPerUserSettings);
sb.append("\n mDisplayOrientation = ");
sb.append("" + mDisplayOrientation);
sb.append("\n mAppWorkarounds = ");