Merge "Enable "show language switch key" settings on K and before"

main
Tadashi G. Takaoka 2014-05-23 16:43:36 +00:00 committed by Android (Google) Code Review
commit 7a76350b7b
4 changed files with 19 additions and 10 deletions

View File

@ -153,6 +153,7 @@
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
android:key="pref_include_other_imes_in_language_switch_list" android:key="pref_include_other_imes_in_language_switch_list"
android:dependency="pref_show_language_switch_key"
android:title="@string/include_other_imes_in_language_switch_list" android:title="@string/include_other_imes_in_language_switch_list"
android:summary="@string/include_other_imes_in_language_switch_list_summary" android:summary="@string/include_other_imes_in_language_switch_list_summary"
android:persistent="true" android:persistent="true"

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -60,6 +61,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
"pref_key_use_double_space_period"; "pref_key_use_double_space_period";
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE =
"pref_key_block_potentially_offensive"; "pref_key_block_potentially_offensive";
public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|| (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT
&& Build.VERSION.CODENAME.equals("REL"));
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY = public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
"pref_show_language_switch_key"; "pref_show_language_switch_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST = public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =

View File

@ -59,7 +59,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false; private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false;
private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTIGS = private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTIGS =
DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS
|| Build.VERSION.SDK_INT <= 18 /* Build.VERSION.JELLY_BEAN_MR2 */; || Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2;
private void setPreferenceEnabled(final String preferenceKey, final boolean enabled) { private void setPreferenceEnabled(final String preferenceKey, final boolean enabled) {
final Preference preference = findPreference(preferenceKey); final Preference preference = findPreference(preferenceKey);
@ -169,6 +169,13 @@ public final class SettingsFragment extends InputMethodSettingsFragment
removePreference(Settings.PREF_VIBRATE_ON, generalSettings); removePreference(Settings.PREF_VIBRATE_ON, generalSettings);
removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS, advancedSettings); removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS, advancedSettings);
} }
if (!Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS) {
removePreference(
Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, advancedSettings);
removePreference(
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, advancedSettings);
}
// TODO: consolidate key preview dismiss delay with the key preview animation parameters. // TODO: consolidate key preview dismiss delay with the key preview animation parameters.
if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
@ -199,9 +206,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment
removePreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON, advancedSettings); removePreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON, advancedSettings);
} }
setPreferenceEnabled(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST,
Settings.readShowsLanguageSwitchKey(prefs));
final PreferenceGroup textCorrectionGroup = final PreferenceGroup textCorrectionGroup =
(PreferenceGroup) findPreference(Settings.PREF_CORRECTION_SETTINGS); (PreferenceGroup) findPreference(Settings.PREF_CORRECTION_SETTINGS);
final PreferenceScreen dictionaryLink = final PreferenceScreen dictionaryLink =
@ -299,9 +303,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment
if (key.equals(Settings.PREF_POPUP_ON)) { if (key.equals(Settings.PREF_POPUP_ON)) {
setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Settings.readKeyPreviewPopupEnabled(prefs, res)); Settings.readKeyPreviewPopupEnabled(prefs, res));
} else if (key.equals(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY)) {
setPreferenceEnabled(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST,
Settings.readShowsLanguageSwitchKey(prefs));
} else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) { } else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) {
LauncherIconVisibilityManager.updateSetupWizardIconVisibility(getActivity()); LauncherIconVisibilityManager.updateSetupWizardIconVisibility(getActivity());
} }

View File

@ -125,9 +125,11 @@ public final class SettingsValues {
final String autoCorrectionThresholdRawValue = prefs.getString( final String autoCorrectionThresholdRawValue = prefs.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD, Settings.PREF_AUTO_CORRECTION_THRESHOLD,
res.getString(R.string.auto_correction_threshold_mode_index_modest)); res.getString(R.string.auto_correction_threshold_mode_index_modest));
mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean( mIncludesOtherImesInLanguageSwitchList = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false); ? prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false)
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs); : true /* forcibly */;
mShowsLanguageSwitchKey = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
? Settings.readShowsLanguageSwitchKey(prefs) : true /* forcibly */;
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true); mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true); mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true); mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true);