am bfcd2b3f
: Merge "Change to "Show language switch key" option" into jb-mr1-dev
* commit 'bfcd2b3fc0ae7269396d4f694827928630b89d59': Change to "Show language switch key" option
This commit is contained in:
commit
d839242c95
4 changed files with 39 additions and 23 deletions
|
@ -61,8 +61,10 @@
|
|||
<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] -->
|
||||
<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] -->
|
||||
<string name="suppress_language_switch_key">Suppress language switch key</string>
|
||||
<!-- Option to show language switch key [CHAR LIMIT=30] -->
|
||||
<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] -->
|
||||
<string name="key_preview_popup_dismiss_delay">Key popup dismiss delay</string>
|
||||
|
|
|
@ -108,10 +108,11 @@
|
|||
android:persistent="true"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="pref_suppress_language_switch_key"
|
||||
android:title="@string/suppress_language_switch_key"
|
||||
android:key="pref_show_language_switch_key"
|
||||
android:title="@string/show_language_switch_key"
|
||||
android:summary="@string/show_language_switch_key_summary"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false" />
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="pref_include_other_imes_in_language_switch_list"
|
||||
android:title="@string/include_other_imes_in_language_switch_list"
|
||||
|
|
|
@ -42,7 +42,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
|
|||
import com.android.inputmethod.research.ResearchLogger;
|
||||
import com.android.inputmethodcommon.InputMethodSettingsFragment;
|
||||
|
||||
public class Settings extends InputMethodSettingsFragment
|
||||
public final class Settings extends InputMethodSettingsFragment
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public static final boolean ENABLE_INTERNAL_SETTINGS = ProductionFlag.IS_INTERNAL;
|
||||
|
||||
|
@ -63,8 +63,8 @@ public class Settings extends InputMethodSettingsFragment
|
|||
"last_user_dictionary_write_time";
|
||||
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_SUPPRESS_LANGUAGE_SWITCH_KEY =
|
||||
"pref_suppress_language_switch_key";
|
||||
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
|
||||
"pref_show_language_switch_key";
|
||||
public static final String 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";
|
||||
|
@ -97,7 +97,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
private TextView mKeypressVibrationDurationSettingsTextView;
|
||||
private TextView mKeypressSoundVolumeSettingsTextView;
|
||||
|
||||
private static void setPreferenceEnabled(Preference preference, boolean enabled) {
|
||||
private static void setPreferenceEnabled(final Preference preference, final boolean enabled) {
|
||||
if (preference != null) {
|
||||
preference.setEnabled(enabled);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
public void onCreate(final Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
|
||||
setSubtypeEnablerTitle(R.string.select_language);
|
||||
|
@ -192,7 +192,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
}
|
||||
|
||||
setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST),
|
||||
!SettingsValues.isLanguageSwitchKeySupressed(prefs));
|
||||
SettingsValues.showsLanguageSwitchKey(prefs));
|
||||
|
||||
final PreferenceScreen dictionaryLink =
|
||||
(PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
|
||||
|
@ -288,14 +288,14 @@ public class Settings extends InputMethodSettingsFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
||||
(new BackupManager(getActivity())).dataChanged();
|
||||
if (key.equals(PREF_POPUP_ON)) {
|
||||
setPreferenceEnabled(findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY),
|
||||
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),
|
||||
!SettingsValues.isLanguageSwitchKeySupressed(prefs));
|
||||
SettingsValues.showsLanguageSwitchKey(prefs));
|
||||
} else if (key.equals(PREF_GESTURE_INPUT)) {
|
||||
final boolean gestureInputEnabledByConfig = getResources().getBoolean(
|
||||
R.bool.config_gesture_input_enabled_by_build_config);
|
||||
|
@ -352,7 +352,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
}
|
||||
|
||||
private void refreshEnablingsOfKeypressSoundAndVibrationSettings(
|
||||
SharedPreferences sp, Resources res) {
|
||||
final SharedPreferences sp, final Resources res) {
|
||||
if (mKeypressVibrationDurationSettingsPref != null) {
|
||||
final boolean hasVibratorHardware = VibratorUtils.getInstance(getActivity())
|
||||
.hasVibrator();
|
||||
|
@ -370,7 +370,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
}
|
||||
|
||||
private void updateKeypressVibrationDurationSettingsSummary(
|
||||
SharedPreferences sp, Resources res) {
|
||||
final SharedPreferences sp, final Resources res) {
|
||||
if (mKeypressVibrationDurationSettingsPref != null) {
|
||||
mKeypressVibrationDurationSettingsPref.setSummary(
|
||||
SettingsValues.getCurrentVibrationDuration(sp, res)
|
||||
|
@ -428,7 +428,7 @@ public class Settings extends InputMethodSettingsFragment
|
|||
builder.create().show();
|
||||
}
|
||||
|
||||
private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) {
|
||||
private void updateKeypressSoundVolumeSummary(final SharedPreferences sp, final Resources res) {
|
||||
if (mKeypressSoundVolumeSettingsPref != null) {
|
||||
mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf(
|
||||
(int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100)));
|
||||
|
|
|
@ -72,7 +72,7 @@ public final class SettingsValues {
|
|||
@SuppressWarnings("unused") // TODO: Use this
|
||||
private final boolean mUsabilityStudyMode;
|
||||
public final boolean mIncludesOtherImesInLanguageSwitchList;
|
||||
public final boolean mIsLanguageSwitchKeySuppressed;
|
||||
public final boolean mShowsLanguageSwitchKey;
|
||||
@SuppressWarnings("unused") // TODO: Use this
|
||||
private final String mKeyPreviewPopupDismissDelayRawValue;
|
||||
public final boolean mUseContactsDict;
|
||||
|
@ -151,7 +151,7 @@ public final class SettingsValues {
|
|||
mUsabilityStudyMode = getUsabilityStudyMode(prefs);
|
||||
mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean(
|
||||
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false);
|
||||
mIsLanguageSwitchKeySuppressed = isLanguageSwitchKeySupressed(prefs);
|
||||
mShowsLanguageSwitchKey = showsLanguageSwitchKey(prefs);
|
||||
mKeyPreviewPopupDismissDelayRawValue = prefs.getString(
|
||||
Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
|
||||
Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout)));
|
||||
|
@ -336,12 +336,25 @@ public final class SettingsValues {
|
|||
return mVoiceKeyOnMain;
|
||||
}
|
||||
|
||||
public static boolean isLanguageSwitchKeySupressed(final SharedPreferences prefs) {
|
||||
return prefs.getBoolean(Settings.PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
|
||||
// This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
|
||||
// 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) {
|
||||
if (mIsLanguageSwitchKeySuppressed) {
|
||||
if (!mShowsLanguageSwitchKey) {
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue