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

@ -1,6 +1,5 @@
[popup_keys] [popup_keys]
a ä a ä
e
o ö o ö
u ü u ü
s ß s ß

View file

@ -355,6 +355,8 @@ public class Key implements Comparable<Key> {
@NonNull @NonNull
public static Key removeRedundantPopupKeys(@NonNull final Key key, public static Key removeRedundantPopupKeys(@NonNull final Key key,
@NonNull final PopupKeySpec.LettersOnBaseLayout lettersOnBaseLayout) { @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[] popupKeys = key.getPopupKeys();
final PopupKeySpec[] filteredPopupKeys = PopupKeySpec.removeRedundantPopupKeys( final PopupKeySpec[] filteredPopupKeys = PopupKeySpec.removeRedundantPopupKeys(
popupKeys, lettersOnBaseLayout); popupKeys, lettersOnBaseLayout);

View file

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

View file

@ -78,7 +78,7 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
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, Settings.PREF_LANGUAGE_SWITCH_KEY, 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_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));

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_EMOJI = "abc_after_emoji";
public static final String PREF_ABC_AFTER_CLIP = "abc_after_clip"; 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_ABC_AFTER_SYMBOL_SPACE = "abc_after_symbol_space";
public static final String PREF_REMOVE_REDUNDANT_POPUPS = "remove_redundant_popups";
// Emoji // Emoji
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys"; 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 mAlphaAfterEmojiInEmojiView;
public final boolean mAlphaAfterClipHistoryEntry; public final boolean mAlphaAfterClipHistoryEntry;
public final boolean mAlphaAfterSymbolAndSpace; public final boolean mAlphaAfterSymbolAndSpace;
public final boolean mRemoveRedundantPopups;
// From the input box // From the input box
@NonNull @NonNull
@ -258,6 +259,7 @@ public class SettingsValues {
mAlphaAfterEmojiInEmojiView = prefs.getBoolean(Settings.PREF_ABC_AFTER_EMOJI, false); mAlphaAfterEmojiInEmojiView = prefs.getBoolean(Settings.PREF_ABC_AFTER_EMOJI, false);
mAlphaAfterClipHistoryEntry = prefs.getBoolean(Settings.PREF_ABC_AFTER_CLIP, false); mAlphaAfterClipHistoryEntry = prefs.getBoolean(Settings.PREF_ABC_AFTER_CLIP, false);
mAlphaAfterSymbolAndSpace = prefs.getBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, true); mAlphaAfterSymbolAndSpace = prefs.getBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, true);
mRemoveRedundantPopups = prefs.getBoolean(Settings.PREF_REMOVE_REDUNDANT_POPUPS, true);
} }
public boolean isApplicationSpecifiedCompletionsOn() { public boolean isApplicationSpecifiedCompletionsOn() {

View file

@ -283,6 +283,10 @@
<string name="show_popup_hints">Show functional hints</string> <string name="show_popup_hints">Show functional hints</string>
<!-- Description of the show_popup_hints setting --> <!-- Description of the show_popup_hints setting -->
<string name="show_popup_hints_summary">Show hints if long-pressing a key triggers additional functionality</string> <string name="show_popup_hints_summary">Show hints if long-pressing a key triggers additional functionality</string>
<!-- Option to remove popup keys that already exist on the base keyboard -->
<string name="remove_redundant_popups">Remove redundant popups</string>
<!-- Description of the remove_redundant_popups setting -->
<string name="remove_redundant_popups_summary">Suppress popup keys that are present on the base layout</string>
<!-- Title of the setting enabling long press on space key to change IME --> <!-- Title of the setting enabling long press on space key to change IME -->
<string name="prefs_long_press_keyboard_to_change_lang">Change input method with space key</string> <string name="prefs_long_press_keyboard_to_change_lang">Change input method with space key</string>
<!-- Description of the settings to change IME indicating long press triggers change. --> <!-- Description of the settings to change IME indicating long press triggers change. -->

View file

@ -101,6 +101,13 @@
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<SwitchPreference
android:key="remove_redundant_popups"
android:title="@string/remove_redundant_popups"
android:summary="@string/remove_redundant_popups_summary"
android:defaultValue="true"
android:persistent="true" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/settings_category_clipboard_history"> <PreferenceCategory android:title="@string/settings_category_clipboard_history">