diff --git a/java/res/values-xlarge/donottranslate.xml b/java/res/values-xlarge/donottranslate.xml new file mode 100644 index 000000000..6f4e9b1f0 --- /dev/null +++ b/java/res/values-xlarge/donottranslate.xml @@ -0,0 +1,23 @@ + + + + + 1 + diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index a7c1fcd18..ffd6cce0d 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -32,4 +32,14 @@ 1 2 + + + 0 + + 1 + + 2 + + 0 + diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index a1a811274..005fe5e67 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -82,10 +82,24 @@ Corrects commonly typed mistakes - Show suggestions + Show suggestions - Display suggested words while typing - + Display suggested words while typing + + + @string/prefs_suggestion_visibility_show_value + @string/prefs_suggestion_visibility_show_only_portrait_value + @string/prefs_suggestion_visibility_hide_value + + Always show + Show on portrait mode + Always hide + + @string/prefs_suggestion_visibility_show_name + @string/prefs_suggestion_visibility_show_only_portrait_name + @string/prefs_suggestion_visibility_hide_name + + Show settings key diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index af1396c13..2ca1af9ee 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -90,12 +90,14 @@ android:defaultValue="true" /> - 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();