separate language switch key behavior from key enablement

This commit is contained in:
Helium314 2024-06-01 22:27:41 +02:00
parent 4dc0e98321
commit a1d32b84fd
6 changed files with 19 additions and 6 deletions

View file

@ -88,6 +88,10 @@ fun checkVersionUpgrade(context: Context) {
.distinctBy { it.split(",").first() }
.joinToString(";")
prefs.edit { putString(Settings.PREF_PINNED_TOOLBAR_KEYS, newPinnedKeysPref) }
// enable language switch key if it was enabled previously
if (prefs.contains(Settings.PREF_LANGUAGE_SWITCH_KEY) && prefs.getString(Settings.PREF_LANGUAGE_SWITCH_KEY, "") != "off")
prefs.edit { putBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, true) }
}
upgradeToolbarPrefs(prefs)
onCustomLayoutFileListChanged() // just to be sure

View file

@ -92,6 +92,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "use_personalized_dicts";
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "use_double_space_period";
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "block_potentially_offensive";
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY = "show_language_switch_key";
public static final String PREF_LANGUAGE_SWITCH_KEY = "language_switch_key";
public static final String PREF_SHOW_EMOJI_KEY = "show_emoji_key";
public static final String PREF_VARIABLE_TOOLBAR_DIRECTION = "var_toolbar_direction";

View file

@ -65,6 +65,7 @@ public class SettingsValues {
public final boolean mShowsVoiceInputKey;
public final boolean mLanguageSwitchKeyToOtherImes;
public final boolean mLanguageSwitchKeyToOtherSubtypes;
private final boolean mShowsLanguageSwitchKey;
public final boolean mShowsNumberRow;
public final boolean mLocalizedNumberRow;
public final boolean mShowsHints;
@ -150,9 +151,10 @@ public class SettingsValues {
mSlidingKeyInputPreviewEnabled = prefs.getBoolean(
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true);
mShowsVoiceInputKey = mInputAttributes.mShouldShowVoiceInputKey;
final String languagePref = prefs.getString(Settings.PREF_LANGUAGE_SWITCH_KEY, "off");
final String languagePref = prefs.getString(Settings.PREF_LANGUAGE_SWITCH_KEY, "internal");
mLanguageSwitchKeyToOtherImes = languagePref.equals("input_method") || languagePref.equals("both");
mLanguageSwitchKeyToOtherSubtypes = languagePref.equals("internal") || languagePref.equals("both");
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false); // only relevant for default functional key layout
mShowsNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false);
mLocalizedNumberRow = prefs.getBoolean(Settings.PREF_LOCALIZED_NUMBER_ROW, true);
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true);
@ -287,7 +289,7 @@ public class SettingsValues {
}
public boolean isLanguageSwitchKeyEnabled() {
if (!mLanguageSwitchKeyToOtherImes && !mLanguageSwitchKeyToOtherSubtypes) {
if (!mShowsLanguageSwitchKey) {
return false;
}
final RichInputMethodManager imm = RichInputMethodManager.getInstance();