stick to language key setting

don't show langauge switch key in comma popups when there is nothing to switch
fixes #897
This commit is contained in:
Helium314 2024-06-24 20:48:34 +02:00
parent 6e520bf84c
commit d0983e6c3b
4 changed files with 17 additions and 6 deletions

View file

@ -18,6 +18,7 @@ import helium314.keyboard.keyboard.internal.KeyboardParams
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode.checkAndConvertCode import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode.checkAndConvertCode
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyLabel.convertFlorisLabel import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyLabel.convertFlorisLabel
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyLabel.rtlLabel import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyLabel.rtlLabel
import helium314.keyboard.latin.RichInputMethodManager
import helium314.keyboard.latin.common.Constants import helium314.keyboard.latin.common.Constants
import helium314.keyboard.latin.common.LocaleUtils.constructLocale import helium314.keyboard.latin.common.LocaleUtils.constructLocale
import helium314.keyboard.latin.common.StringUtils import helium314.keyboard.latin.common.StringUtils
@ -121,7 +122,7 @@ sealed interface KeyData : AbstractKeyData {
keys.add("!icon/clipboard_normal_key|!code/key_clipboard") keys.add("!icon/clipboard_normal_key|!code/key_clipboard")
if (!params.mId.mEmojiKeyEnabled && !params.mId.isNumberLayout) if (!params.mId.mEmojiKeyEnabled && !params.mId.isNumberLayout)
keys.add("!icon/emoji_normal_key|!code/key_emoji") keys.add("!icon/emoji_normal_key|!code/key_emoji")
if (!params.mId.mLanguageSwitchKeyEnabled && !params.mId.isNumberLayout) if (!params.mId.mLanguageSwitchKeyEnabled && !params.mId.isNumberLayout && RichInputMethodManager.getInstance().canSwitchLanguage())
keys.add("!icon/language_switch_key|!code/key_language_switch") keys.add("!icon/language_switch_key|!code/key_language_switch")
if (!params.mId.mOneHandedModeEnabled) if (!params.mId.mOneHandedModeEnabled)
keys.add("!icon/start_onehanded_mode_key|!code/key_start_onehanded") keys.add("!icon/start_onehanded_mode_key|!code/key_start_onehanded")

View file

@ -1412,8 +1412,9 @@ public class LatinIME extends InputMethodService implements
if (switchIme && !switchSubtype && switchInputMethod()) if (switchIme && !switchSubtype && switchInputMethod())
return; return;
final boolean hasMoreThanOneSubtype = mRichImm.getMyEnabledInputMethodSubtypeList(false).size() > 1; final boolean hasMoreThanOneSubtype = mRichImm.getMyEnabledInputMethodSubtypeList(false).size() > 1;
// switch subtype if wanted and possible // switch subtype if wanted, do nothing if no other subtype is available
if (switchSubtype && !switchIme && hasMoreThanOneSubtype) { if (switchSubtype && !switchIme) {
if (hasMoreThanOneSubtype)
// switch to previous subtype if current one was used, otherwise cycle through list // switch to previous subtype if current one was used, otherwise cycle through list
mSubtypeState.switchSubtype(mRichImm); mSubtypeState.switchSubtype(mRichImm);
return; return;

View file

@ -360,6 +360,14 @@ public class RichInputMethodManager {
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype); mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
} }
public boolean canSwitchLanguage() {
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherSubtypes && hasMultipleEnabledSubtypesInThisIme(false))
return true;
if (Settings.getInstance().getCurrent().mLanguageSwitchKeyToOtherImes && mImm.getEnabledInputMethodList().size() > 1)
return true;
return false;
}
// todo: is shortcutIme only voice input, or can it be something else? // todo: is shortcutIme only voice input, or can it be something else?
// if always voice input, rename it and other things like mHasShortcutKey // if always voice input, rename it and other things like mHasShortcutKey
private void updateShortcutIme() { private void updateShortcutIme() {

View file

@ -77,7 +77,8 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
if (key == null) return; if (key == null) return;
switch (key) { switch (key) {
case Settings.PREF_POPUP_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW, case Settings.PREF_POPUP_KEYS_ORDER, Settings.PREF_SHOW_POPUP_HINTS, Settings.PREF_SHOW_NUMBER_ROW,
Settings.PREF_POPUP_KEYS_LABELS_ORDER -> mReloadKeyboard = true; Settings.PREF_POPUP_KEYS_LABELS_ORDER, Settings.PREF_LANGUAGE_SWITCH_KEY,
Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY -> mReloadKeyboard = true;
case Settings.PREF_LOCALIZED_NUMBER_ROW -> KeyboardLayoutSet.onSystemLocaleChanged(); case Settings.PREF_LOCALIZED_NUMBER_ROW -> KeyboardLayoutSet.onSystemLocaleChanged();
case Settings.PREF_SHOW_HINTS case Settings.PREF_SHOW_HINTS
-> findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(prefs.getBoolean(Settings.PREF_SHOW_HINTS, false)); -> findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(prefs.getBoolean(Settings.PREF_SHOW_HINTS, false));