Skip to content

Commit

Permalink
add setting to remove redundant popup keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Jul 13, 2024
1 parent 5441329 commit c0c11d7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/src/main/assets/locale_key_texts/de.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[popup_keys]
a ä
e
o ö
u ü
s ß
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/helium314/keyboard/keyboard/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ private Key(@NonNull final Key key, @Nullable final PopupKeySpec[] popupKeys) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onSharedPreferenceChanged(final SharedPreferences prefs, final Strin
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -258,6 +259,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
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() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@
<string name="show_popup_hints">Show functional hints</string>
<!-- Description of the show_popup_hints setting -->
<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 -->
<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. -->
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs_screen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
android:defaultValue="false"
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 android:title="@string/settings_category_clipboard_history">
Expand Down

0 comments on commit c0c11d7

Please sign in to comment.