Skip to content

Commit

Permalink
Setting for switching to other IMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
rkkr committed Mar 29, 2021
1 parent 101dc24 commit 1cba021
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,9 @@ public boolean shouldSwitchToOtherInputMethods() {
if (token == null) {
return false;
}
final boolean overrideValue = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
return mRichImm.shouldOfferSwitchingToNextInputMethod(token) && overrideValue;
final boolean languageKeyEnabled = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
final boolean imeSwitchEnabled = mSettings.getCurrent().mImeSwitchEnabled;
return mRichImm.shouldOfferSwitchingToNextInputMethod(token) && languageKeyEnabled && imeSwitchEnabled;
}

public boolean shouldShowLanguageSwitchKey() {
Expand All @@ -1090,8 +1091,8 @@ public boolean shouldShowLanguageSwitchKey() {
if (token == null) {
return false;
}
final boolean overrideValue = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
return mRichImm.shouldOfferSwitchingToNextInputMethod(token) && overrideValue;
final boolean languageKeyEnabled = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
return mRichImm.shouldOfferSwitchingToNextInputMethod(token) && languageKeyEnabled;
}

private void setNavigationBarColor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void onCreate(final Bundle icicle) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
removePreference(Settings.PREF_MATCHING_NAVBAR_COLOR);
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
removePreference(Settings.PREF_ENABLE_IME_SWITCH);
}
refreshEnablingsOfSettings();

setupKeypressVibrationDurationSettings();
Expand All @@ -83,10 +86,12 @@ private void refreshEnablingsOfSettings() {
Settings.readVibrationEnabled(prefs, res));
setPreferenceEnabled(Settings.PREF_KEYPRESS_SOUND_VOLUME,
Settings.readKeypressSoundEnabled(prefs, res));
setPreferenceEnabled(Settings.PREF_ENABLE_IME_SWITCH,
Settings.readShowLanguageSwitchKey(prefs));
final KeyboardTheme theme = KeyboardTheme.getKeyboardTheme(prefs);
setPreferenceEnabled(Settings.PREF_KEYBOARD_COLOR,
theme.mThemeId != KeyboardTheme.THEME_ID_SYSTEM
&& theme.mThemeId != KeyboardTheme.THEME_ID_SYSTEM_BORDER);
final boolean isSystemTheme = theme.mThemeId != KeyboardTheme.THEME_ID_SYSTEM
&& theme.mThemeId != KeyboardTheme.THEME_ID_SYSTEM_BORDER;
setPreferenceEnabled(Settings.PREF_KEYBOARD_COLOR, isSystemTheme);
}

private void setupKeypressVibrationDurationSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_VIBRATE_ON = "vibrate_on";
public static final String PREF_SOUND_ON = "sound_on";
public static final String PREF_POPUP_ON = "popup_on";
//public static final boolean SHOULD_SHOW_LXX_SUGGESTION_UI =
// Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
public static final String PREF_HIDE_LANGUAGE_SWITCH_KEY =
"pref_hide_language_switch_key";
public static final String PREF_HIDE_LANGUAGE_SWITCH_KEY = "pref_hide_language_switch_key";
public static final String PREF_ENABLE_IME_SWITCH = "pref_enable_ime_switch";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
public static final String PREF_VIBRATION_DURATION_SETTINGS =
"pref_vibration_duration_settings";
public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings";
public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume";
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
public static final String PREF_KEYBOARD_HEIGHT = "pref_keyboard_height";
Expand Down Expand Up @@ -156,10 +153,14 @@ public static boolean readKeyPreviewPopupEnabled(final SharedPreferences prefs,
return prefs.getBoolean(PREF_POPUP_ON, defaultKeyPreviewPopup);
}

public static boolean readShowsLanguageSwitchKey(final SharedPreferences prefs) {
public static boolean readShowLanguageSwitchKey(final SharedPreferences prefs) {
return !prefs.getBoolean(PREF_HIDE_LANGUAGE_SWITCH_KEY, false);
}

public static boolean readEnableImeSwitch(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_ENABLE_IME_SWITCH, false);
}

public static boolean readHideSpecialChars(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_HIDE_SPECIAL_CHARS, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class SettingsValues {
public final boolean mSoundOn;
public final boolean mKeyPreviewPopupOn;
public final boolean mShowsLanguageSwitchKey;
public final boolean mImeSwitchEnabled;
public final int mKeyLongpressTimeout;
//public final boolean mShouldShowLxxSuggestionUi;
public final boolean mHideSpecialChars;
public final boolean mShowNumberRow;
public final boolean mSpaceSwipeEnabled;
Expand Down Expand Up @@ -80,7 +80,8 @@ public SettingsValues(final SharedPreferences prefs, final Resources res,
mVibrateOn = Settings.readVibrationEnabled(prefs, res);
mSoundOn = Settings.readKeypressSoundEnabled(prefs, res);
mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res);
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs);
mShowsLanguageSwitchKey = Settings.readShowLanguageSwitchKey(prefs);
mImeSwitchEnabled = Settings.readEnableImeSwitch(prefs);
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());

// Compute other readable settings
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<string name="keyboard_color">Keisti klaviatūros spalvą</string>
<string name="hide_special_chars">Paslėpti specialius simbolius</string>
<string name="hide_language_switch_key">Paslėpti kalbos pasirinkimą</string>
<string name="pref_enable_ime_switch">Perjungti į kitas klaviatūras</string>
<string name="show_number_row">Rodyti skaičių eilutę</string>
<string name="space_swipe">Judinti kursorių tarpo klavišu</string>
<string name="delete_swipe">Trynimo klavišo braukimas</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<string name="keyboard_color">Set custom keyboard color</string>
<string name="hide_special_chars">Hide special characters</string>
<string name="hide_language_switch_key">Hide language switch key</string>
<string name="pref_enable_ime_switch">Switch to other keyboards</string>
<string name="show_number_row">Show separate number row</string>
<string name="space_swipe">Space swipe cursor move</string>
<string name="delete_swipe">Delete swipe</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/prefs_screen_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
android:key="pref_hide_language_switch_key"
android:title="@string/hide_language_switch_key"
android:defaultValue="false" />
<CheckBoxPreference
android:key="pref_enable_ime_switch"
android:title="@string/pref_enable_ime_switch"
android:defaultValue="false" />
<CheckBoxPreference
android:key="pref_show_number_row"
android:title="@string/show_number_row"
Expand Down

0 comments on commit 1cba021

Please sign in to comment.