add setting to show first popup key as hint label

This commit is contained in:
Helium314 2023-12-10 18:31:03 +01:00
parent c5f3d4bfcf
commit bb7c1f5242
9 changed files with 23 additions and 5 deletions

View file

@ -1246,10 +1246,12 @@ public class Key implements Comparable<Key> {
mHintLabel = null; mHintLabel = null;
} else { } else {
// maybe also always null for comma and period keys // maybe also always null for comma and period keys
final boolean hintLabelAlwaysFromFirstLongPressKey = false; // todo (later): add the setting, and use it (store in params?)
String hintLabel; String hintLabel;
if (hintLabelAlwaysFromFirstLongPressKey) { if (mKeyboardParams.mHintLabelFromFirstMoreKey) {
hintLabel = mMoreKeys == null ? null : mMoreKeys[0].mLabel; hintLabel = mMoreKeys == null ? null : mMoreKeys[0].mLabel;
if (hintLabel != null && backgroundType == BACKGROUND_TYPE_FUNCTIONAL && mKeyboardParams.mId.isAlphabetKeyboard())
// bad workaround for the ugly comma label on period key, todo: do it better when re-working moreKey stuff
hintLabel = null;
} else { } else {
hintLabel = layoutMoreKeys == null ? null : KeySpecParser.getLabel(layoutMoreKeys[0]); // note that some entries may have been changed to other string or null hintLabel = layoutMoreKeys == null ? null : KeySpecParser.getLabel(layoutMoreKeys[0]); // note that some entries may have been changed to other string or null
// todo: this should be adjusted when re-working moreKey stuff... also KeySpecParser.getLabel may throw, which is bad when users do uncommon things // todo: this should be adjusted when re-working moreKey stuff... also KeySpecParser.getLabel may throw, which is bad when users do uncommon things

View file

@ -67,11 +67,11 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
return this return this
// todo: further plan // todo: further plan
// re-check the LayoutInfos, they should really to the right things!
// some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils // some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils
// that's one more reason for using language tags... // that's one more reason for using language tags...
// currently it's still read from xml outside the keyboard parser, but should still go to some other place // currently it's still read from xml outside the keyboard parser, but should still go to some other place
// maybe use scriptUtils to determine, just make sure it's correct (also for hindi and serbian!) // maybe use scriptUtils to determine, just make sure it's correct (also for hindi and serbian!)
// next release, and possibly don't continue working here for a while (should allow finding more regressions)
// remove the old parser // remove the old parser
// then finally the spanish/german/swiss/nordic layouts can be removed and replaced by some hasExtraKeys parameter // then finally the spanish/german/swiss/nordic layouts can be removed and replaced by some hasExtraKeys parameter
// also the eo check could then be removed // also the eo check could then be removed

View file

@ -89,6 +89,7 @@ public class KeyboardParams {
@NonNull @NonNull
private final UniqueKeysCache mUniqueKeysCache; private final UniqueKeysCache mUniqueKeysCache;
public boolean mAllowRedundantMoreKeys; public boolean mAllowRedundantMoreKeys;
public final boolean mHintLabelFromFirstMoreKey = Settings.getInstance().getCurrent().mHintLabelFromFirstMoreKey;
@NonNull @NonNull
public LocaleKeyTexts mLocaleKeyTexts; public LocaleKeyTexts mLocaleKeyTexts;

View file

@ -820,7 +820,7 @@ data class LayoutInfos(
val allowRedundantMoreKeys: Boolean = true, // only false for nordic and serbian_qwertz val allowRedundantMoreKeys: Boolean = true, // only false for nordic and serbian_qwertz
// there is holo, default and null // there is holo, default and null
// null only for moreKeys keyboard // null only for moreKeys keyboard
// currently read as part of readAttributes, and thus wrong with the new parser // currently read as part of readAttributes, and thus wrong with the new parser (but we set it correctly in parser)
val touchPositionCorrectionData: Int? = null, val touchPositionCorrectionData: Int? = null,
val hasZwnjKey: Boolean = false, val hasZwnjKey: Boolean = false,
val hasShiftKey: Boolean = true, val hasShiftKey: Boolean = true,

View file

@ -67,6 +67,7 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
setupHistoryRetentionTimeSettings(); setupHistoryRetentionTimeSettings();
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings(); refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
setLocalizedNumberRowVisibility(); setLocalizedNumberRowVisibility();
findPreference(Settings.PREF_HINT_LABEL_FROM_FIRST_MORE_KEY).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
} }
@Override @Override
@ -77,10 +78,13 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
@Override @Override
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings(); refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
if (Settings.PREF_SHOW_POPUP_HINTS.equals(key)) if (Settings.PREF_SHOW_POPUP_HINTS.equals(key) || Settings.PREF_HINT_LABEL_FROM_FIRST_MORE_KEY.equals(key))
mReloadKeyboard = true; mReloadKeyboard = true;
if (key.equals(Settings.PREF_LOCALIZED_NUMBER_ROW)) if (key.equals(Settings.PREF_LOCALIZED_NUMBER_ROW))
KeyboardLayoutSet.onSystemLocaleChanged(); KeyboardLayoutSet.onSystemLocaleChanged();
if (Settings.PREF_SHOW_HINTS.equals(key)) {
findPreference(Settings.PREF_HINT_LABEL_FROM_FIRST_MORE_KEY).setVisible(prefs.getBoolean(Settings.PREF_SHOW_HINTS, false));
}
} }
@Override @Override

View file

@ -112,6 +112,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_LOCALIZED_NUMBER_ROW = "pref_localized_number_row"; public static final String PREF_LOCALIZED_NUMBER_ROW = "pref_localized_number_row";
public static final String PREF_SHOW_HINTS = "pref_show_hints"; public static final String PREF_SHOW_HINTS = "pref_show_hints";
public static final String PREF_HINT_LABEL_FROM_FIRST_MORE_KEY = "pref_hint_label_from_first_more_key";
public static final String PREF_SHOW_POPUP_HINTS = "pref_show_popup_hints"; public static final String PREF_SHOW_POPUP_HINTS = "pref_show_popup_hints";
public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang"; public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang";

View file

@ -66,6 +66,7 @@ public class SettingsValues {
public final boolean mShowsNumberRow; public final boolean mShowsNumberRow;
public final boolean mLocalizedNumberRow; public final boolean mLocalizedNumberRow;
public final boolean mShowsHints; public final boolean mShowsHints;
public final boolean mHintLabelFromFirstMoreKey;
public final boolean mShowsPopupHints; public final boolean mShowsPopupHints;
public final boolean mSpaceForLangChange; public final boolean mSpaceForLangChange;
public final boolean mSpaceLanguageSlide; public final boolean mSpaceLanguageSlide;
@ -151,6 +152,7 @@ public class SettingsValues {
mShowsNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false); mShowsNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false);
mLocalizedNumberRow = prefs.getBoolean(Settings.PREF_LOCALIZED_NUMBER_ROW, true); mLocalizedNumberRow = prefs.getBoolean(Settings.PREF_LOCALIZED_NUMBER_ROW, true);
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true); mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true);
mHintLabelFromFirstMoreKey = mShowsHints && prefs.getBoolean(Settings.PREF_HINT_LABEL_FROM_FIRST_MORE_KEY, false);
mShowsPopupHints = prefs.getBoolean(Settings.PREF_SHOW_POPUP_HINTS, false); mShowsPopupHints = prefs.getBoolean(Settings.PREF_SHOW_POPUP_HINTS, false);
mSpaceForLangChange = prefs.getBoolean(Settings.PREF_SPACE_TO_CHANGE_LANG, true); mSpaceForLangChange = prefs.getBoolean(Settings.PREF_SPACE_TO_CHANGE_LANG, true);
mSpaceLanguageSlide = prefs.getBoolean(Settings.PREF_SPACE_LANGUAGE_SLIDE, false); mSpaceLanguageSlide = prefs.getBoolean(Settings.PREF_SPACE_LANGUAGE_SLIDE, false);

View file

@ -238,6 +238,8 @@
<string name="show_hints">Show key hints</string> <string name="show_hints">Show key hints</string>
<!-- Description of the settings to show hints --> <!-- Description of the settings to show hints -->
<string name="show_hints_summary">Show long-press hints</string> <string name="show_hints_summary">Show long-press hints</string>
<!-- Title of the settings to show hint based on actual long-press key -->
<string name="show_hints_from_first_popup_key">Take hint label from first popup key</string>
<!-- Title of the settings to show "..." as hints for more functionality on long-press --> <!-- Title of the settings to show "..." as hints for more functionality on long-press -->
<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 -->

View file

@ -17,6 +17,12 @@
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<SwitchPreferenceCompat
android:key="pref_hint_label_from_first_more_key"
android:title="@string/show_hints_from_first_popup_key"
android:defaultValue="false"
android:persistent="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="pref_show_popup_hints" android:key="pref_show_popup_hints"
android:title="@string/show_popup_hints" android:title="@string/show_popup_hints"