Turn off the Settings key by default

bug:5094401
Change-Id: Ieb42fdfa79be2afcfa6634e7404c17737ef6927d
main
Ken Wakasa 2011-07-30 10:19:51 +09:00
parent 97c35650ad
commit 2ba975afb9
6 changed files with 50 additions and 120 deletions

View File

@ -50,26 +50,6 @@
<!-- Character for close candidates pane (BLACK UP-POINTING TRIANGLE) -->
<string name="label_close_candidates_pane">\u25b2</string>
<!-- Option values to show/hide the settings key in onscreen keyboard -->
<!-- Automatically decide to show or hide the settings key -->
<string name="settings_key_mode_auto">0</string>
<!-- Always show the settings key -->
<string name="settings_key_mode_always_show">1</string>
<!-- Always hide the settings key -->
<string name="settings_key_mode_always_hide">2</string>
<!-- Array of the settings key mode values -->
<string-array name="settings_key_modes_values">
<item>@string/settings_key_mode_auto</item>
<item>@string/settings_key_mode_always_show</item>
<item>@string/settings_key_mode_always_hide</item>
</string-array>
<!-- Array of the settings key modes -->
<string-array name="settings_key_modes">
<item>@string/settings_key_mode_auto_name</item>
<item>@string/settings_key_mode_always_show_name</item>
<item>@string/settings_key_mode_always_hide_name</item>
</string-array>
<!-- Always show the suggestion strip -->
<string name="prefs_suggestion_visibility_show_value">0</string>
<!-- Show the suggestion strip only on portrait mode -->

View File

@ -82,12 +82,6 @@
<!-- Option to show/hide the settings key -->
<string name="prefs_settings_key">Show settings key</string>
<!-- Option to automatically decide to show/hide the settings key -->
<string name="settings_key_mode_auto_name">Automatic</string>
<!-- Option to always show the settings key -->
<string name="settings_key_mode_always_show_name">Always show</string>
<!-- Option to always hide the settings key -->
<string name="settings_key_mode_always_hide_name">Always hide</string>
<!-- Option to decide the auto correction threshold score -->
<!-- Option to enable auto correction [CHAR LIMIT=20]-->

View File

@ -49,13 +49,11 @@
android:summary="@string/prefs_enable_recorrection_summary"
android:persistent="true"
android:defaultValue="@bool/config_default_recorrection_enabled" />
<ListPreference
android:key="settings_key"
<CheckBoxPreference
android:key="show_settings_key"
android:title="@string/prefs_settings_key"
android:persistent="true"
android:entryValues="@array/settings_key_modes_values"
android:entries="@array/settings_key_modes"
android:defaultValue="@string/settings_key_mode_auto" />
android:defaultValue="false" />
<ListPreference
android:key="voice_mode"
android:title="@string/voice_input"

View File

@ -99,14 +99,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private static final int SWITCH_STATE_CHORDING_SYMBOL = 6;
private int mSwitchState = SWITCH_STATE_ALPHA;
private static final int SETTINGS_KEY_MODE_AUTO = R.string.settings_key_mode_auto;
private static final int SETTINGS_KEY_MODE_ALWAYS_SHOW =
R.string.settings_key_mode_always_show;
// NOTE: No need to have SETTINGS_KEY_MODE_ALWAYS_HIDE here because it's not being referred to
// in the source code now.
// Default is SETTINGS_KEY_MODE_AUTO.
private static final int DEFAULT_SETTINGS_KEY_MODE = SETTINGS_KEY_MODE_AUTO;
private int mThemeIndex = -1;
private Context mThemeContext;
@ -228,21 +220,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
public void loadKeyboard(EditorInfo attribute, Settings.Values settings) {
public void loadKeyboard(EditorInfo editorInfo, Settings.Values settingsValues) {
mSwitchState = SWITCH_STATE_ALPHA;
try {
final Locale locale = mSubtypeSwitcher.getInputLocale();
final Configuration conf = mResources.getConfiguration();
final int width = mWindowWidthCache.getWidth(conf);
final int orientation = conf.orientation;
final boolean voiceKeyEnabled = settings.isVoiceKeyEnabled(attribute);
final boolean voiceKeyOnMain = settings.isVoiceKeyOnMain();
mMainKeyboardId = getKeyboardId(attribute, locale, orientation, width,
false, false, voiceKeyEnabled, voiceKeyOnMain);
mSymbolsKeyboardId = getKeyboardId(attribute, locale, orientation, width,
true, false, voiceKeyEnabled, voiceKeyOnMain);
mSymbolsShiftedKeyboardId = getKeyboardId(attribute, locale, orientation, width,
true, true, voiceKeyEnabled, voiceKeyOnMain);
mMainKeyboardId = getKeyboardId(editorInfo, false, false, settingsValues);
mSymbolsKeyboardId = getKeyboardId(editorInfo, true, false, settingsValues);
mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues);
setKeyboard(getKeyboard(mMainKeyboardId));
} catch (RuntimeException e) {
Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e);
@ -309,10 +292,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
return keyboard;
}
private KeyboardId getKeyboardId(EditorInfo attribute, Locale locale, final int orientation,
final int width, final boolean isSymbols, final boolean isShift,
final boolean voiceKeyEnabled, final boolean voiceKeyOnMain) {
final int mode = Utils.getKeyboardMode(attribute);
private KeyboardId getKeyboardId(EditorInfo editorInfo, final boolean isSymbols,
final boolean isShift, Settings.Values settingsValues) {
final int mode = Utils.getKeyboardMode(editorInfo);
final int xmlId;
switch (mode) {
case KeyboardId.MODE_PHONE:
@ -330,16 +312,20 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
break;
}
final boolean settingsKeyEnabled = settingsValues.isSettingsKeyEnabled(editorInfo);
final boolean voiceKeyEnabled = settingsValues.isVoiceKeyEnabled(editorInfo);
final boolean voiceKeyOnMain = settingsValues.isVoiceKeyOnMain();
final boolean noSettingsKey = Utils.inPrivateImeOptions(
mPackageName, LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute);
final boolean hasSettingsKey = getSettingsKeyMode(mPrefs, mResources) && !noSettingsKey;
final int f2KeyMode = getF2KeyMode(mPrefs, mResources, mPackageName, attribute);
mPackageName, LatinIME.IME_OPTION_NO_SETTINGS_KEY, editorInfo);
final boolean hasSettingsKey = settingsKeyEnabled && !noSettingsKey;
final int f2KeyMode = getF2KeyMode(settingsKeyEnabled, noSettingsKey);
final boolean hasVoiceKey = voiceKeyEnabled && (isSymbols != voiceKeyOnMain);
final Configuration conf = mResources.getConfiguration();
return new KeyboardId(
mResources.getResourceEntryName(xmlId), xmlId, locale,
orientation, width, mode, attribute, hasSettingsKey, f2KeyMode, noSettingsKey,
voiceKeyEnabled, hasVoiceKey);
mResources.getResourceEntryName(xmlId), xmlId, mSubtypeSwitcher.getInputLocale(),
conf.orientation, mWindowWidthCache.getWidth(conf), mode, editorInfo,
hasSettingsKey, f2KeyMode, noSettingsKey, voiceKeyEnabled, hasVoiceKey);
}
public int getKeyboardMode() {
@ -828,9 +814,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (PREF_KEYBOARD_LAYOUT.equals(key)) {
final int layoutId = getKeyboardThemeIndex(mInputMethodService, sharedPreferences);
postSetInputView(createInputView(layoutId, false));
} else if (Settings.PREF_SETTINGS_KEY.equals(key)) {
final int themeIndex = getKeyboardThemeIndex(mInputMethodService, sharedPreferences);
postSetInputView(createInputView(themeIndex, false));
} else if (Settings.PREF_SHOW_SETTINGS_KEY.equals(key)) {
postSetInputView(createInputView(mThemeIndex, true));
}
}
@ -848,39 +834,18 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
private static boolean getSettingsKeyMode(SharedPreferences prefs, Resources res) {
final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option);
if (showSettingsKeyOption) {
final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
res.getString(DEFAULT_SETTINGS_KEY_MODE));
// We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or
// 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system
if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))
|| (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))
&& Utils.hasMultipleEnabledIMEsOrSubtypes(
(InputMethodManagerCompatWrapper.getInstance())))) {
return true;
}
return false;
}
// If the show settings key option is disabled, we always try showing the settings key.
return true;
}
private static int getF2KeyMode(SharedPreferences prefs, Resources res, String packageName,
EditorInfo attribute) {
final boolean clobberSettingsKey = Utils.inPrivateImeOptions(
packageName, LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute);
final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
res.getString(DEFAULT_SETTINGS_KEY_MODE));
if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))) {
return clobberSettingsKey ? KeyboardId.F2KEY_MODE_SHORTCUT_IME
: KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
} else if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))) {
return clobberSettingsKey ? KeyboardId.F2KEY_MODE_NONE : KeyboardId.F2KEY_MODE_SETTINGS;
} else { // SETTINGS_KEY_MODE_ALWAYS_HIDE
private static int getF2KeyMode(boolean settingsKeyEnabled, boolean noSettingsKey) {
if (noSettingsKey) {
// Never shows the Settings key
return KeyboardId.F2KEY_MODE_SHORTCUT_IME;
}
if (settingsKeyEnabled) {
return KeyboardId.F2KEY_MODE_SETTINGS;
} else {
// It should be alright to fall back to the Settings key on 7-inch layouts
// even when the Settings key is not explicitly enabled.
return KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
}
}
}

View File

@ -61,7 +61,7 @@ public class Settings extends InputMethodSettingsActivity
public static final String PREF_KEY_PREVIEW_POPUP_ON = "popup_on";
public static final String PREF_RECORRECTION_ENABLED = "recorrection_enabled";
public static final String PREF_AUTO_CAP = "auto_cap";
public static final String PREF_SETTINGS_KEY = "settings_key";
public static final String PREF_SHOW_SETTINGS_KEY = "show_settings_key";
public static final String PREF_VOICE_SETTINGS_KEY = "voice_mode";
public static final String PREF_INPUT_LANGUAGE = "input_language";
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
@ -118,6 +118,7 @@ public class Settings extends InputMethodSettingsActivity
public final boolean mBigramPredictionEnabled;
public final boolean mUseContactsDict;
private final boolean mShowSettingsKey;
private final boolean mVoiceKeyEnabled;
private final boolean mVoiceKeyOnMain;
@ -165,21 +166,17 @@ public class Settings extends InputMethodSettingsActivity
mVibrateOn = hasVibrator && prefs.getBoolean(Settings.PREF_VIBRATE_ON, false);
mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON,
res.getBoolean(R.bool.config_default_sound_enabled));
mKeyPreviewPopupOn = isKeyPreviewPopupEnabled(prefs, res);
mKeyPreviewPopupDismissDelay = getKeyPreviewPopupDismissDelay(prefs, res);
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs, res);
mBigramSuggestionEnabled = mAutoCorrectEnabled
&& isBigramSuggestionEnabled(prefs, res, mAutoCorrectEnabled);
mBigramPredictionEnabled = mBigramSuggestionEnabled
&& isBigramPredictionEnabled(prefs, res);
mAutoCorrectionThreshold = getAutoCorrectionThreshold(prefs, res);
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mShowSettingsKey = prefs.getBoolean(Settings.PREF_SHOW_SETTINGS_KEY, false);
final String voiceModeMain = res.getString(R.string.voice_mode_main);
final String voiceModeOff = res.getString(R.string.voice_mode_off);
final String voiceMode = prefs.getString(PREF_VOICE_SETTINGS_KEY, voiceModeMain);
@ -284,6 +281,10 @@ public class Settings extends InputMethodSettingsActivity
return builder.setIsPunctuationSuggestions().build();
}
public boolean isSettingsKeyEnabled(EditorInfo attribute) {
return mShowSettingsKey;
}
public boolean isVoiceKeyEnabled(EditorInfo attribute) {
final boolean shortcutImeEnabled = SubtypeSwitcher.getInstance().isShortcutImeEnabled();
final int inputType = (attribute != null) ? attribute.inputType : 0;
@ -298,7 +299,7 @@ public class Settings extends InputMethodSettingsActivity
private PreferenceScreen mInputLanguageSelection;
private ListPreference mVoicePreference;
private ListPreference mSettingsKeyPreference;
private CheckBoxPreference mShowSettingsKeyPreference;
private ListPreference mShowCorrectionSuggestionsPreference;
private ListPreference mAutoCorrectionThreshold;
private ListPreference mKeyPreviewPopupDismissDelay;
@ -345,7 +346,7 @@ public class Settings extends InputMethodSettingsActivity
mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES);
mInputLanguageSelection.setOnPreferenceClickListener(this);
mVoicePreference = (ListPreference) findPreference(PREF_VOICE_SETTINGS_KEY);
mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
mShowSettingsKeyPreference = (CheckBoxPreference) findPreference(PREF_SHOW_SETTINGS_KEY);
mShowCorrectionSuggestionsPreference =
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
@ -376,7 +377,7 @@ public class Settings extends InputMethodSettingsActivity
final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option);
if (!showSettingsKeyOption) {
generalSettings.removePreference(mSettingsKeyPreference);
generalSettings.removePreference(mShowSettingsKeyPreference);
}
final boolean showVoiceKeyOption = res.getBoolean(
@ -457,7 +458,6 @@ public class Settings extends InputMethodSettingsActivity
} else {
getPreferenceScreen().removePreference(mVoicePreference);
}
updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
}
@ -489,7 +489,6 @@ public class Settings extends InputMethodSettingsActivity
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
.equals(mVoiceModeOff));
updateVoiceModeSummary();
updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
}
@ -513,12 +512,6 @@ public class Settings extends InputMethodSettingsActivity
mShowCorrectionSuggestionsPreference.getValue())]);
}
private void updateSettingsKeySummary() {
mSettingsKeyPreference.setSummary(
getResources().getStringArray(R.array.settings_key_modes)
[mSettingsKeyPreference.findIndexOfValue(mSettingsKeyPreference.getValue())]);
}
private void updateKeyPreviewPopupDelaySummary() {
final ListPreference lp = mKeyPreviewPopupDismissDelay;
lp.setSummary(lp.getEntries()[lp.findIndexOfValue(lp.getValue())]);

View File

@ -546,11 +546,11 @@ public class Utils {
}
}
public static int getKeyboardMode(EditorInfo attribute) {
if (attribute == null)
public static int getKeyboardMode(EditorInfo editorInfo) {
if (editorInfo == null)
return KeyboardId.MODE_TEXT;
final int inputType = attribute.inputType;
final int inputType = editorInfo.inputType;
final int variation = inputType & InputType.TYPE_MASK_VARIATION;
switch (inputType & InputType.TYPE_MASK_CLASS) {
@ -587,11 +587,11 @@ public class Utils {
}
public static boolean inPrivateImeOptions(String packageName, String key,
EditorInfo attribute) {
if (attribute == null)
EditorInfo editorInfo) {
if (editorInfo == null)
return false;
return containsInCsv(packageName != null ? packageName + "." + key : key,
attribute.privateImeOptions);
editorInfo.privateImeOptions);
}
/**