Change to "Show language switch key" option

This change deprecates "Suppress language switch key".

Bug: 7037410
Change-Id: I1bc90877b4d2ee9364728959fd680dcb5b22ecbf
main
Tadashi G. Takaoka 2012-09-20 10:32:56 +09:00
parent c7dc673cf0
commit 1a4aa7e307
4 changed files with 39 additions and 23 deletions

View File

@ -61,8 +61,10 @@
<string name="include_other_imes_in_language_switch_list">Switch to other input methods</string> <string name="include_other_imes_in_language_switch_list">Switch to other input methods</string>
<!-- Option summary for including other IMEs in the language switch list [CHAR LIMIT=65] --> <!-- Option summary for including other IMEs in the language switch list [CHAR LIMIT=65] -->
<string name="include_other_imes_in_language_switch_list_summary">Language switch key covers other input methods too</string> <string name="include_other_imes_in_language_switch_list_summary">Language switch key covers other input methods too</string>
<!-- Option to suppress language switch key [CHAR LIMIT=30] --> <!-- Option to show language switch key [CHAR LIMIT=30] -->
<string name="suppress_language_switch_key">Suppress language switch key</string> <string name="show_language_switch_key">Language switch key</string>
<!-- Option summary for showing language switch key [CHAR LIMIT=65] -->
<string name="show_language_switch_key_summary">Show when multiple input languages are enabled</string>
<!-- Option for the dismiss delay of the key popup [CHAR LIMIT=25] --> <!-- Option for the dismiss delay of the key popup [CHAR LIMIT=25] -->
<string name="key_preview_popup_dismiss_delay">Key popup dismiss delay</string> <string name="key_preview_popup_dismiss_delay">Key popup dismiss delay</string>

View File

@ -108,10 +108,11 @@
android:persistent="true" android:persistent="true"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
android:key="pref_suppress_language_switch_key" android:key="pref_show_language_switch_key"
android:title="@string/suppress_language_switch_key" android:title="@string/show_language_switch_key"
android:summary="@string/show_language_switch_key_summary"
android:persistent="true" android:persistent="true"
android:defaultValue="false" /> 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:title="@string/include_other_imes_in_language_switch_list" android:title="@string/include_other_imes_in_language_switch_list"

View File

@ -42,7 +42,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
import com.android.inputmethodcommon.InputMethodSettingsFragment; import com.android.inputmethodcommon.InputMethodSettingsFragment;
public class Settings extends InputMethodSettingsFragment public final class Settings extends InputMethodSettingsFragment
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final boolean ENABLE_INTERNAL_SETTINGS = ProductionFlag.IS_INTERNAL; public static final boolean ENABLE_INTERNAL_SETTINGS = ProductionFlag.IS_INTERNAL;
@ -63,8 +63,8 @@ public class Settings extends InputMethodSettingsFragment
"last_user_dictionary_write_time"; "last_user_dictionary_write_time";
public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings"; public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings";
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
public static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY = public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
"pref_suppress_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 =
"pref_include_other_imes_in_language_switch_list"; "pref_include_other_imes_in_language_switch_list";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles"; public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
@ -97,7 +97,7 @@ public class Settings extends InputMethodSettingsFragment
private TextView mKeypressVibrationDurationSettingsTextView; private TextView mKeypressVibrationDurationSettingsTextView;
private TextView mKeypressSoundVolumeSettingsTextView; private TextView mKeypressSoundVolumeSettingsTextView;
private static void setPreferenceEnabled(Preference preference, boolean enabled) { private static void setPreferenceEnabled(final Preference preference, final boolean enabled) {
if (preference != null) { if (preference != null) {
preference.setEnabled(enabled); preference.setEnabled(enabled);
} }
@ -111,7 +111,7 @@ public class Settings extends InputMethodSettingsFragment
} }
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(final Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setInputMethodSettingsCategoryTitle(R.string.language_selection_title); setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
setSubtypeEnablerTitle(R.string.select_language); setSubtypeEnablerTitle(R.string.select_language);
@ -192,7 +192,7 @@ public class Settings extends InputMethodSettingsFragment
} }
setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST), setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST),
!SettingsValues.isLanguageSwitchKeySupressed(prefs)); SettingsValues.showsLanguageSwitchKey(prefs));
final PreferenceScreen dictionaryLink = final PreferenceScreen dictionaryLink =
(PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY); (PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
@ -288,14 +288,14 @@ public class Settings extends InputMethodSettingsFragment
} }
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
(new BackupManager(getActivity())).dataChanged(); (new BackupManager(getActivity())).dataChanged();
if (key.equals(PREF_POPUP_ON)) { if (key.equals(PREF_POPUP_ON)) {
setPreferenceEnabled(findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY), setPreferenceEnabled(findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY),
prefs.getBoolean(PREF_POPUP_ON, true)); prefs.getBoolean(PREF_POPUP_ON, true));
} else if (key.equals(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) { } else if (key.equals(PREF_SHOW_LANGUAGE_SWITCH_KEY)) {
setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST), setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST),
!SettingsValues.isLanguageSwitchKeySupressed(prefs)); SettingsValues.showsLanguageSwitchKey(prefs));
} else if (key.equals(PREF_GESTURE_INPUT)) { } else if (key.equals(PREF_GESTURE_INPUT)) {
final boolean gestureInputEnabledByConfig = getResources().getBoolean( final boolean gestureInputEnabledByConfig = getResources().getBoolean(
R.bool.config_gesture_input_enabled_by_build_config); R.bool.config_gesture_input_enabled_by_build_config);
@ -352,7 +352,7 @@ public class Settings extends InputMethodSettingsFragment
} }
private void refreshEnablingsOfKeypressSoundAndVibrationSettings( private void refreshEnablingsOfKeypressSoundAndVibrationSettings(
SharedPreferences sp, Resources res) { final SharedPreferences sp, final Resources res) {
if (mKeypressVibrationDurationSettingsPref != null) { if (mKeypressVibrationDurationSettingsPref != null) {
final boolean hasVibratorHardware = VibratorUtils.getInstance(getActivity()) final boolean hasVibratorHardware = VibratorUtils.getInstance(getActivity())
.hasVibrator(); .hasVibrator();
@ -370,7 +370,7 @@ public class Settings extends InputMethodSettingsFragment
} }
private void updateKeypressVibrationDurationSettingsSummary( private void updateKeypressVibrationDurationSettingsSummary(
SharedPreferences sp, Resources res) { final SharedPreferences sp, final Resources res) {
if (mKeypressVibrationDurationSettingsPref != null) { if (mKeypressVibrationDurationSettingsPref != null) {
mKeypressVibrationDurationSettingsPref.setSummary( mKeypressVibrationDurationSettingsPref.setSummary(
SettingsValues.getCurrentVibrationDuration(sp, res) SettingsValues.getCurrentVibrationDuration(sp, res)
@ -428,7 +428,7 @@ public class Settings extends InputMethodSettingsFragment
builder.create().show(); builder.create().show();
} }
private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) { private void updateKeypressSoundVolumeSummary(final SharedPreferences sp, final Resources res) {
if (mKeypressSoundVolumeSettingsPref != null) { if (mKeypressSoundVolumeSettingsPref != null) {
mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf( mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf(
(int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100))); (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100)));

View File

@ -72,7 +72,7 @@ public final class SettingsValues {
@SuppressWarnings("unused") // TODO: Use this @SuppressWarnings("unused") // TODO: Use this
private final boolean mUsabilityStudyMode; private final boolean mUsabilityStudyMode;
public final boolean mIncludesOtherImesInLanguageSwitchList; public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mIsLanguageSwitchKeySuppressed; public final boolean mShowsLanguageSwitchKey;
@SuppressWarnings("unused") // TODO: Use this @SuppressWarnings("unused") // TODO: Use this
private final String mKeyPreviewPopupDismissDelayRawValue; private final String mKeyPreviewPopupDismissDelayRawValue;
public final boolean mUseContactsDict; public final boolean mUseContactsDict;
@ -151,7 +151,7 @@ public final class SettingsValues {
mUsabilityStudyMode = getUsabilityStudyMode(prefs); mUsabilityStudyMode = getUsabilityStudyMode(prefs);
mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean( mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean(
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false); Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false);
mIsLanguageSwitchKeySuppressed = isLanguageSwitchKeySupressed(prefs); mShowsLanguageSwitchKey = showsLanguageSwitchKey(prefs);
mKeyPreviewPopupDismissDelayRawValue = prefs.getString( mKeyPreviewPopupDismissDelayRawValue = prefs.getString(
Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout))); Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout)));
@ -336,12 +336,25 @@ public final class SettingsValues {
return mVoiceKeyOnMain; return mVoiceKeyOnMain;
} }
public static boolean isLanguageSwitchKeySupressed(final SharedPreferences prefs) { // This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
return prefs.getBoolean(Settings.PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false); // This is being used only for the backward compatibility.
private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
"pref_suppress_language_switch_key";
public static boolean showsLanguageSwitchKey(final SharedPreferences prefs) {
if (prefs.contains(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) {
final boolean suppressLanguageSwitchKey = prefs.getBoolean(
PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
final SharedPreferences.Editor editor = prefs.edit();
editor.remove(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY);
editor.putBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, !suppressLanguageSwitchKey);
editor.apply();
}
return prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, true);
} }
public boolean isLanguageSwitchKeyEnabled(final Context context) { public boolean isLanguageSwitchKeyEnabled(final Context context) {
if (mIsLanguageSwitchKeySuppressed) { if (!mShowsLanguageSwitchKey) {
return false; return false;
} }
if (mIncludesOtherImesInLanguageSwitchList) { if (mIncludesOtherImesInLanguageSwitchList) {
@ -353,7 +366,7 @@ public final class SettingsValues {
} }
} }
public boolean isFullscreenModeAllowed(final Resources res) { public static boolean isFullscreenModeAllowed(final Resources res) {
return res.getBoolean(R.bool.config_use_fullscreen_mode); return res.getBoolean(R.bool.config_use_fullscreen_mode);
} }