Add showing suggestion only on portrait mode and fixing the state of suggestion strip
Change-Id: I7babd1400a3516c87506a3ea4bd46ddaf89e19b4main
parent
71c353aa87
commit
7599cfea4a
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2010, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<!-- Default value of the visibility of the suggestion strip -->
|
||||||
|
<string name="prefs_suggestion_visibility_default_value" translatable="false">1</string>
|
||||||
|
</resources>
|
|
@ -32,4 +32,14 @@
|
||||||
<string name="settings_key_mode_always_show" translatable="false">1</string>
|
<string name="settings_key_mode_always_show" translatable="false">1</string>
|
||||||
<!-- Always hide the settings key -->
|
<!-- Always hide the settings key -->
|
||||||
<string name="settings_key_mode_always_hide" translatable="false">2</string>
|
<string name="settings_key_mode_always_hide" translatable="false">2</string>
|
||||||
|
|
||||||
|
<!-- Always show the suggestion strip -->
|
||||||
|
<string name="prefs_suggestion_visibility_show_value" translatable="false">0</string>
|
||||||
|
<!-- Show the suggestion strip only on portrait mode -->
|
||||||
|
<string name="prefs_suggestion_visibility_show_only_portrait_value" translatable="false">1</string>
|
||||||
|
<!-- Always hide the suggestion strip -->
|
||||||
|
<string name="prefs_suggestion_visibility_hide_value" translatable="false">2</string>
|
||||||
|
<!-- Default value of the visibility of the suggestion strip -->
|
||||||
|
<string name="prefs_suggestion_visibility_default_value" translatable="false">0</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -82,10 +82,24 @@
|
||||||
<string name="quick_fixes_summary">Corrects commonly typed mistakes</string>
|
<string name="quick_fixes_summary">Corrects commonly typed mistakes</string>
|
||||||
|
|
||||||
<!-- Option to enable showing suggestions -->
|
<!-- Option to enable showing suggestions -->
|
||||||
<string name="show_suggestions">Show suggestions</string>
|
<string name="prefs_show_suggestions">Show suggestions</string>
|
||||||
<!-- Description for show suggestions -->
|
<!-- Description for show suggestions -->
|
||||||
<string name="show_suggestions_summary">Display suggested words while typing</string>
|
<string name="prefs_show_suggestions_summary">Display suggested words while typing</string>
|
||||||
|
<!-- Option to show/hide the suggestion strip -->
|
||||||
|
<string-array name="prefs_suggestion_visibility_values" translatable="false">
|
||||||
|
<item>@string/prefs_suggestion_visibility_show_value</item>
|
||||||
|
<item>@string/prefs_suggestion_visibility_show_only_portrait_value</item>
|
||||||
|
<item>@string/prefs_suggestion_visibility_hide_value</item>
|
||||||
|
</string-array>
|
||||||
|
<string name="prefs_suggestion_visibility_show_name">Always show</string>
|
||||||
|
<string name="prefs_suggestion_visibility_show_only_portrait_name">Show on portrait mode</string>
|
||||||
|
<string name="prefs_suggestion_visibility_hide_name">Always hide</string>
|
||||||
|
<string-array name="prefs_suggestion_visibilities" translatable="false">
|
||||||
|
<item>@string/prefs_suggestion_visibility_show_name</item>
|
||||||
|
<item>@string/prefs_suggestion_visibility_show_only_portrait_name</item>
|
||||||
|
<item>@string/prefs_suggestion_visibility_hide_name</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<!-- Option to show/hide the settings key -->
|
<!-- Option to show/hide the settings key -->
|
||||||
<string name="prefs_settings_key">Show settings key</string>
|
<string name="prefs_settings_key">Show settings key</string>
|
||||||
<!-- Array of the settings key mode values -->
|
<!-- Array of the settings key mode values -->
|
||||||
|
|
|
@ -90,12 +90,14 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<ListPreference
|
||||||
android:key="show_suggestions"
|
android:key="show_suggestions_setting"
|
||||||
android:title="@string/show_suggestions"
|
android:summary="@string/prefs_show_suggestions_summary"
|
||||||
android:summary="@string/show_suggestions_summary"
|
android:title="@string/prefs_show_suggestions"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:defaultValue="true"
|
android:entryValues="@array/prefs_suggestion_visibility_values"
|
||||||
|
android:entries="@array/prefs_suggestion_visibilities"
|
||||||
|
android:defaultValue="@string/prefs_suggestion_visibility_default_value"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class LatinIME extends InputMethodService
|
||||||
private static final String PREF_POPUP_ON = "popup_on";
|
private static final String PREF_POPUP_ON = "popup_on";
|
||||||
private static final String PREF_AUTO_CAP = "auto_cap";
|
private static final String PREF_AUTO_CAP = "auto_cap";
|
||||||
private static final String PREF_QUICK_FIXES = "quick_fixes";
|
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_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold";
|
||||||
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
|
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
|
||||||
private static final String PREF_VOICE_MODE = "voice_mode";
|
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_METHOD = 0;
|
||||||
private static final int POS_SETTINGS = 1;
|
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 LinearLayout mCandidateViewContainer;
|
||||||
private CandidateView mCandidateView;
|
private CandidateView mCandidateView;
|
||||||
private Suggest mSuggest;
|
private Suggest mSuggest;
|
||||||
|
@ -206,7 +220,6 @@ public class LatinIME extends InputMethodService
|
||||||
private boolean mHasUsedVoiceInput;
|
private boolean mHasUsedVoiceInput;
|
||||||
private boolean mHasUsedVoiceInputUnsupportedLocale;
|
private boolean mHasUsedVoiceInputUnsupportedLocale;
|
||||||
private boolean mLocaleSupportedForVoiceInput;
|
private boolean mLocaleSupportedForVoiceInput;
|
||||||
private boolean mShowSuggestions;
|
|
||||||
private boolean mIsShowingHint;
|
private boolean mIsShowingHint;
|
||||||
private int mCorrectionMode;
|
private int mCorrectionMode;
|
||||||
private boolean mVoiceButtonEnabled;
|
private boolean mVoiceButtonEnabled;
|
||||||
|
@ -674,7 +687,7 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
inputView.setPreviewEnabled(mPopupOn);
|
inputView.setPreviewEnabled(mPopupOn);
|
||||||
inputView.setProximityCorrectionEnabled(true);
|
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
|
// If we just entered a text field, maybe it has some old text that requires correction
|
||||||
checkReCorrectionOnStart();
|
checkReCorrectionOnStart();
|
||||||
checkTutorial(attribute.privateImeOptions);
|
checkTutorial(attribute.privateImeOptions);
|
||||||
|
@ -819,9 +832,8 @@ public class LatinIME extends InputMethodService
|
||||||
abortCorrection(false);
|
abortCorrection(false);
|
||||||
// Show the punctuation suggestions list if the current one is not
|
// Show the punctuation suggestions list if the current one is not
|
||||||
// and if not showing "Touch again to save".
|
// and if not showing "Touch again to save".
|
||||||
if (mCandidateView != null
|
if (mCandidateView != null && !isShowingPunctuationList()
|
||||||
&& !mSuggestPuncList.equals(mCandidateView.getSuggestions())
|
&& !mCandidateView.isShowingAddToDictionaryHint()) {
|
||||||
&& !mCandidateView.isShowingAddToDictionaryHint()) {
|
|
||||||
setPunctuationSuggestions();
|
setPunctuationSuggestions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1574,9 +1586,21 @@ public class LatinIME extends InputMethodService
|
||||||
return mPredictionOn;
|
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() {
|
private boolean isCandidateStripVisible() {
|
||||||
return (isPredictionOn() && mShowSuggestions) || mCompletionOn
|
boolean forceVisible = mCandidateView.isShowingAddToDictionaryHint()
|
||||||
|| mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isCorrecting();
|
|| TextEntryState.isCorrecting();
|
||||||
|
return forceVisible || (isSuggestionShown()
|
||||||
|
&& (isPredictionOn() || mCompletionOn || isShowingPunctuationList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelVoice() {
|
public void onCancelVoice() {
|
||||||
|
@ -2470,6 +2494,18 @@ public class LatinIME extends InputMethodService
|
||||||
mSuggest.setAutoTextEnabled(!different && mQuickFixes);
|
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() {
|
protected void launchSettings() {
|
||||||
launchSettings(LatinIMESettings.class);
|
launchSettings(LatinIMESettings.class);
|
||||||
}
|
}
|
||||||
|
@ -2515,8 +2551,7 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
mLocaleSupportedForVoiceInput = voiceInputSupportedLocales.contains(mInputLocale);
|
mLocaleSupportedForVoiceInput = voiceInputSupportedLocales.contains(mInputLocale);
|
||||||
|
|
||||||
mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true);
|
mAutoCorrectEnabled = isAutoCorrectEnabled(sp);
|
||||||
mAutoCorrectEnabled = mShowSuggestions && isAutoCorrectEnabled(sp);
|
|
||||||
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(sp);
|
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(sp);
|
||||||
loadAndSetAutoCompletionThreshold(sp);
|
loadAndSetAutoCompletionThreshold(sp);
|
||||||
|
|
||||||
|
@ -2529,6 +2564,7 @@ public class LatinIME extends InputMethodService
|
||||||
}
|
}
|
||||||
updateCorrectionMode();
|
updateCorrectionMode();
|
||||||
updateAutoTextEnabled(mResources.getConfiguration().locale);
|
updateAutoTextEnabled(mResources.getConfiguration().locale);
|
||||||
|
updateSuggestionVisibility(sp);
|
||||||
mLanguageSwitcher.loadLocales(sp);
|
mLanguageSwitcher.loadLocales(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
private static final String QUICK_FIXES_KEY = "quick_fixes";
|
private static final String QUICK_FIXES_KEY = "quick_fixes";
|
||||||
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
||||||
private static final String VOICE_SETTINGS_KEY = "voice_mode";
|
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_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold";
|
||||||
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
|
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
|
||||||
/* package */ static final String PREF_SETTINGS_KEY = "settings_key";
|
/* package */ static final String PREF_SETTINGS_KEY = "settings_key";
|
||||||
|
@ -58,7 +57,6 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
private CheckBoxPreference mQuickFixes;
|
private CheckBoxPreference mQuickFixes;
|
||||||
private ListPreference mVoicePreference;
|
private ListPreference mVoicePreference;
|
||||||
private ListPreference mSettingsKeyPreference;
|
private ListPreference mSettingsKeyPreference;
|
||||||
private CheckBoxPreference mShowSuggestions;
|
|
||||||
private ListPreference mAutoCompletionThreshold;
|
private ListPreference mAutoCompletionThreshold;
|
||||||
private CheckBoxPreference mBigramSuggestion;
|
private CheckBoxPreference mBigramSuggestion;
|
||||||
private boolean mVoiceOn;
|
private boolean mVoiceOn;
|
||||||
|
@ -69,16 +67,10 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
private String mVoiceModeOff;
|
private String mVoiceModeOff;
|
||||||
|
|
||||||
private void ensureConsistencyOfAutoCompletionSettings() {
|
private void ensureConsistencyOfAutoCompletionSettings() {
|
||||||
if (mShowSuggestions.isChecked()) {
|
final String autoCompletionOff = getResources().getString(
|
||||||
mAutoCompletionThreshold.setEnabled(true);
|
R.string.auto_completion_threshold_mode_value_off);
|
||||||
final String autoCompletionOff = getResources().getString(
|
final String currentSetting = mAutoCompletionThreshold.getValue();
|
||||||
R.string.auto_completion_threshold_mode_value_off);
|
mBigramSuggestion.setEnabled(!currentSetting.equals(autoCompletionOff));
|
||||||
final String currentSetting = mAutoCompletionThreshold.getValue();
|
|
||||||
mBigramSuggestion.setEnabled(!currentSetting.equals(autoCompletionOff));
|
|
||||||
} else {
|
|
||||||
mAutoCompletionThreshold.setEnabled(false);
|
|
||||||
mBigramSuggestion.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
|
@ -94,7 +86,6 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
||||||
mLogger = VoiceInputLogger.getLogger(this);
|
mLogger = VoiceInputLogger.getLogger(this);
|
||||||
|
|
||||||
mShowSuggestions = (CheckBoxPreference) findPreference(PREF_SHOW_SUGGESTIONS);
|
|
||||||
mAutoCompletionThreshold = (ListPreference) findPreference(PREF_AUTO_COMPLETION_THRESHOLD);
|
mAutoCompletionThreshold = (ListPreference) findPreference(PREF_AUTO_COMPLETION_THRESHOLD);
|
||||||
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS);
|
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS);
|
||||||
ensureConsistencyOfAutoCompletionSettings();
|
ensureConsistencyOfAutoCompletionSettings();
|
||||||
|
|
Loading…
Reference in New Issue