add setting to remove redundant popup keys

This commit is contained in:
Helium314 2024-07-13 09:13:14 +02:00
parent 544132974c
commit c0c11d75b2
8 changed files with 19 additions and 7 deletions

View file

@ -355,6 +355,8 @@ public class Key implements Comparable<Key> {
@NonNull
public static Key removeRedundantPopupKeys(@NonNull final Key key,
@NonNull final PopupKeySpec.LettersOnBaseLayout lettersOnBaseLayout) {
if ((key.mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_FIXED_COLUMN) != 0)
return key; // don't remove anything for fixed column popup keys
final PopupKeySpec[] popupKeys = key.getPopupKeys();
final PopupKeySpec[] filteredPopupKeys = PopupKeySpec.removeRedundantPopupKeys(
popupKeys, lettersOnBaseLayout);

View file

@ -65,14 +65,11 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
}
private fun setupParams() {
// previously was false for nordic and serbian_qwertz, true for all others
// todo: add setting? maybe users want it in a custom layout
mParams.mAllowRedundantPopupKeys = mParams.mId.mElementId != KeyboardId.ELEMENT_SYMBOLS
val sv = Settings.getInstance().current
mParams.mAllowRedundantPopupKeys = !sv.mRemoveRedundantPopups
mParams.mProximityCharsCorrectionEnabled = mParams.mId.mElementId == KeyboardId.ELEMENT_ALPHABET
|| (mParams.mId.isAlphabetKeyboard && !mParams.mId.mSubtype.hasExtraValue(Constants.Subtype.ExtraValue.NO_SHIFT_PROXIMITY_CORRECTION))
val sv = Settings.getInstance().current
addLocaleKeyTextsToParams(mContext, mParams, sv.mShowMorePopupKeys)
mParams.mPopupKeyTypes.addAll(sv.mPopupKeyTypes)
// add label source only if popup key type enabled

View file

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

View file

@ -159,6 +159,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_ABC_AFTER_EMOJI = "abc_after_emoji";
public static final String PREF_ABC_AFTER_CLIP = "abc_after_clip";
public static final String PREF_ABC_AFTER_SYMBOL_SPACE = "abc_after_symbol_space";
public static final String PREF_REMOVE_REDUNDANT_POPUPS = "remove_redundant_popups";
// Emoji
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";

View file

@ -114,6 +114,7 @@ public class SettingsValues {
public final boolean mAlphaAfterEmojiInEmojiView;
public final boolean mAlphaAfterClipHistoryEntry;
public final boolean mAlphaAfterSymbolAndSpace;
public final boolean mRemoveRedundantPopups;
// From the input box
@NonNull
@ -258,6 +259,7 @@ public class SettingsValues {
mAlphaAfterEmojiInEmojiView = prefs.getBoolean(Settings.PREF_ABC_AFTER_EMOJI, false);
mAlphaAfterClipHistoryEntry = prefs.getBoolean(Settings.PREF_ABC_AFTER_CLIP, false);
mAlphaAfterSymbolAndSpace = prefs.getBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, true);
mRemoveRedundantPopups = prefs.getBoolean(Settings.PREF_REMOVE_REDUNDANT_POPUPS, true);
}
public boolean isApplicationSpecifiedCompletionsOn() {