diff options
Diffstat (limited to 'java/src/com')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 56 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIMESettings.java | 17 |
2 files changed, 50 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4614df988..b3ac17b07 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -95,7 +95,7 @@ public class LatinIME extends InputMethodService private static final String PREF_POPUP_ON = "popup_on"; private static final String PREF_AUTO_CAP = "auto_cap"; private static final String PREF_QUICK_FIXES = "quick_fixes"; - private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions"; + private static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting"; private static final String PREF_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold"; private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion"; private static final String PREF_VOICE_MODE = "voice_mode"; @@ -155,6 +155,20 @@ public class LatinIME extends InputMethodService private static final int POS_METHOD = 0; private static final int POS_SETTINGS = 1; + private int mSuggestionVisibility; + private static final int SUGGESTION_VISIBILILTY_SHOW_VALUE + = R.string.prefs_suggestion_visibility_show_value; + private static final int SUGGESTION_VISIBILILTY_SHOW_ONLY_PORTRAIT_VALUE + = R.string.prefs_suggestion_visibility_show_only_portrait_value; + private static final int SUGGESTION_VISIBILILTY_HIDE_VALUE + = R.string.prefs_suggestion_visibility_hide_value; + + private static final int[] SUGGESTION_VISIBILITY_VALUE_ARRAY = new int[] { + SUGGESTION_VISIBILILTY_SHOW_VALUE, + SUGGESTION_VISIBILILTY_SHOW_ONLY_PORTRAIT_VALUE, + SUGGESTION_VISIBILILTY_HIDE_VALUE + }; + private LinearLayout mCandidateViewContainer; private CandidateView mCandidateView; private Suggest mSuggest; @@ -206,7 +220,6 @@ public class LatinIME extends InputMethodService private boolean mHasUsedVoiceInput; private boolean mHasUsedVoiceInputUnsupportedLocale; private boolean mLocaleSupportedForVoiceInput; - private boolean mShowSuggestions; private boolean mIsShowingHint; private int mCorrectionMode; private boolean mVoiceButtonEnabled; @@ -674,7 +687,7 @@ public class LatinIME extends InputMethodService inputView.setPreviewEnabled(mPopupOn); inputView.setProximityCorrectionEnabled(true); - mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || mShowSuggestions); + mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || isSuggestionShown()); // If we just entered a text field, maybe it has some old text that requires correction checkReCorrectionOnStart(); checkTutorial(attribute.privateImeOptions); @@ -819,9 +832,8 @@ public class LatinIME extends InputMethodService abortCorrection(false); // Show the punctuation suggestions list if the current one is not // and if not showing "Touch again to save". - if (mCandidateView != null - && !mSuggestPuncList.equals(mCandidateView.getSuggestions()) - && !mCandidateView.isShowingAddToDictionaryHint()) { + if (mCandidateView != null && !isShowingPunctuationList() + && !mCandidateView.isShowingAddToDictionaryHint()) { setPunctuationSuggestions(); } } @@ -1574,9 +1586,21 @@ public class LatinIME extends InputMethodService return mPredictionOn; } + private boolean isShowingPunctuationList() { + return mSuggestPuncList.equals(mCandidateView.getSuggestions()); + } + + private boolean isSuggestionShown() { + return (mSuggestionVisibility == SUGGESTION_VISIBILILTY_SHOW_VALUE) + || (mSuggestionVisibility == SUGGESTION_VISIBILILTY_SHOW_ONLY_PORTRAIT_VALUE + && mOrientation == Configuration.ORIENTATION_PORTRAIT); + } + private boolean isCandidateStripVisible() { - return (isPredictionOn() && mShowSuggestions) || mCompletionOn - || mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isCorrecting(); + boolean forceVisible = mCandidateView.isShowingAddToDictionaryHint() + || TextEntryState.isCorrecting(); + return forceVisible || (isSuggestionShown() + && (isPredictionOn() || mCompletionOn || isShowingPunctuationList())); } public void onCancelVoice() { @@ -2470,6 +2494,18 @@ public class LatinIME extends InputMethodService mSuggest.setAutoTextEnabled(!different && mQuickFixes); } + private void updateSuggestionVisibility(SharedPreferences prefs) { + final String suggestionVisiblityStr = prefs.getString( + PREF_SHOW_SUGGESTIONS_SETTING, mResources.getString( + R.string.prefs_suggestion_visibility_default_value)); + for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) { + if (suggestionVisiblityStr.equals(mResources.getString(visibility))) { + mSuggestionVisibility = visibility; + break; + } + } + } + protected void launchSettings() { launchSettings(LatinIMESettings.class); } @@ -2515,8 +2551,7 @@ public class LatinIME extends InputMethodService mLocaleSupportedForVoiceInput = voiceInputSupportedLocales.contains(mInputLocale); - mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true); - mAutoCorrectEnabled = mShowSuggestions && isAutoCorrectEnabled(sp); + mAutoCorrectEnabled = isAutoCorrectEnabled(sp); mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(sp); loadAndSetAutoCompletionThreshold(sp); @@ -2529,6 +2564,7 @@ public class LatinIME extends InputMethodService } updateCorrectionMode(); updateAutoTextEnabled(mResources.getConfiguration().locale); + updateSuggestionVisibility(sp); mLanguageSwitcher.loadLocales(sp); } diff --git a/java/src/com/android/inputmethod/latin/LatinIMESettings.java b/java/src/com/android/inputmethod/latin/LatinIMESettings.java index d8f3ebc51..0f0fe1ea2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIMESettings.java +++ b/java/src/com/android/inputmethod/latin/LatinIMESettings.java @@ -44,7 +44,6 @@ public class LatinIMESettings extends PreferenceActivity private static final String QUICK_FIXES_KEY = "quick_fixes"; private static final String PREDICTION_SETTINGS_KEY = "prediction_settings"; private static final String VOICE_SETTINGS_KEY = "voice_mode"; - private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions"; private static final String PREF_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold"; private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion"; /* package */ static final String PREF_SETTINGS_KEY = "settings_key"; @@ -58,7 +57,6 @@ public class LatinIMESettings extends PreferenceActivity private CheckBoxPreference mQuickFixes; private ListPreference mVoicePreference; private ListPreference mSettingsKeyPreference; - private CheckBoxPreference mShowSuggestions; private ListPreference mAutoCompletionThreshold; private CheckBoxPreference mBigramSuggestion; private boolean mVoiceOn; @@ -69,16 +67,10 @@ public class LatinIMESettings extends PreferenceActivity private String mVoiceModeOff; private void ensureConsistencyOfAutoCompletionSettings() { - if (mShowSuggestions.isChecked()) { - mAutoCompletionThreshold.setEnabled(true); - final String autoCompletionOff = getResources().getString( - R.string.auto_completion_threshold_mode_value_off); - final String currentSetting = mAutoCompletionThreshold.getValue(); - mBigramSuggestion.setEnabled(!currentSetting.equals(autoCompletionOff)); - } else { - mAutoCompletionThreshold.setEnabled(false); - mBigramSuggestion.setEnabled(false); - } + final String autoCompletionOff = getResources().getString( + R.string.auto_completion_threshold_mode_value_off); + final String currentSetting = mAutoCompletionThreshold.getValue(); + mBigramSuggestion.setEnabled(!currentSetting.equals(autoCompletionOff)); } @Override protected void onCreate(Bundle icicle) { @@ -94,7 +86,6 @@ public class LatinIMESettings extends PreferenceActivity mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff)); mLogger = VoiceInputLogger.getLogger(this); - mShowSuggestions = (CheckBoxPreference) findPreference(PREF_SHOW_SUGGESTIONS); mAutoCompletionThreshold = (ListPreference) findPreference(PREF_AUTO_COMPLETION_THRESHOLD); mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS); ensureConsistencyOfAutoCompletionSettings(); |