mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-07 07:07:43 +00:00
Optionally show popup hints on number row (#1303)
This commit is contained in:
parent
0d48a18264
commit
82ec37f339
6 changed files with 33 additions and 9 deletions
|
@ -17,12 +17,10 @@ import helium314.keyboard.keyboard.internal.keyboard_parser.floris.TextKeyData
|
||||||
import helium314.keyboard.latin.common.isEmoji
|
import helium314.keyboard.latin.common.isEmoji
|
||||||
import helium314.keyboard.latin.define.DebugFlags
|
import helium314.keyboard.latin.define.DebugFlags
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.CUSTOM_LAYOUT_PREFIX
|
|
||||||
import helium314.keyboard.latin.utils.POPUP_KEYS_LAYOUT
|
import helium314.keyboard.latin.utils.POPUP_KEYS_LAYOUT
|
||||||
import helium314.keyboard.latin.utils.POPUP_KEYS_NUMBER
|
import helium314.keyboard.latin.utils.POPUP_KEYS_NUMBER
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils
|
import helium314.keyboard.latin.utils.ScriptUtils
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||||
import helium314.keyboard.latin.utils.getCustomLayoutFiles
|
|
||||||
import helium314.keyboard.latin.utils.replaceFirst
|
import helium314.keyboard.latin.utils.replaceFirst
|
||||||
import helium314.keyboard.latin.utils.splitAt
|
import helium314.keyboard.latin.utils.splitAt
|
||||||
import helium314.keyboard.latin.utils.sumOf
|
import helium314.keyboard.latin.utils.sumOf
|
||||||
|
@ -88,9 +86,11 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co
|
||||||
addNumberRowOrPopupKeys(baseKeys, numberRow)
|
addNumberRowOrPopupKeys(baseKeys, numberRow)
|
||||||
if (params.mId.isAlphabetKeyboard)
|
if (params.mId.isAlphabetKeyboard)
|
||||||
addSymbolPopupKeys(baseKeys)
|
addSymbolPopupKeys(baseKeys)
|
||||||
if (params.mId.isAlphaOrSymbolKeyboard && params.mId.mNumberRowEnabled)
|
if (params.mId.isAlphaOrSymbolKeyboard && params.mId.mNumberRowEnabled) {
|
||||||
baseKeys.add(0, numberRow
|
val newLabelFlags = defaultLabelFlags or
|
||||||
.mapTo(mutableListOf()) { it.copy(newLabelFlags = Key.LABEL_FLAGS_DISABLE_HINT_LABEL or defaultLabelFlags) })
|
if (Settings.getInstance().current.mShowNumberRowHints) 0 else Key.LABEL_FLAGS_DISABLE_HINT_LABEL
|
||||||
|
baseKeys.add(0, numberRow.mapTo(mutableListOf()) { it.copy(newLabelFlags = newLabelFlags) })
|
||||||
|
}
|
||||||
if (!params.mAllowRedundantPopupKeys)
|
if (!params.mAllowRedundantPopupKeys)
|
||||||
params.baseKeys = baseKeys.flatMap { it.map { it.toKeyParams(params) } }
|
params.baseKeys = baseKeys.flatMap { it.map { it.toKeyParams(params) } }
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
|
||||||
setupHistoryRetentionTimeSettings();
|
setupHistoryRetentionTimeSettings();
|
||||||
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
||||||
setLocalizedNumberRowVisibility();
|
setLocalizedNumberRowVisibility();
|
||||||
|
setNumberRowHintsVisibility();
|
||||||
findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
|
findPreference(Settings.PREF_POPUP_KEYS_LABELS_ORDER).setVisible(getSharedPreferences().getBoolean(Settings.PREF_SHOW_HINTS, false));
|
||||||
findPreference(Settings.PREF_POPUP_KEYS_ORDER).setOnPreferenceClickListener((pref) -> {
|
findPreference(Settings.PREF_POPUP_KEYS_ORDER).setOnPreferenceClickListener((pref) -> {
|
||||||
DialogUtilsKt.reorderDialog(requireContext(), Settings.PREF_POPUP_KEYS_ORDER,
|
DialogUtilsKt.reorderDialog(requireContext(), Settings.PREF_POPUP_KEYS_ORDER,
|
||||||
|
@ -77,12 +78,18 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
|
||||||
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings();
|
||||||
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_HINTS,
|
||||||
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, Settings.PREF_REMOVE_REDUNDANT_POPUPS -> mReloadKeyboard = true;
|
Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, Settings.PREF_REMOVE_REDUNDANT_POPUPS -> mReloadKeyboard = true;
|
||||||
|
case Settings.PREF_SHOW_NUMBER_ROW -> {
|
||||||
|
setNumberRowHintsVisibility();
|
||||||
|
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));
|
||||||
|
setNumberRowHintsVisibility();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +115,12 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
|
||||||
pref.setVisible(false);
|
pref.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setNumberRowHintsVisibility() {
|
||||||
|
var prefs = getSharedPreferences();
|
||||||
|
setPreferenceVisible(Settings.PREF_SHOW_NUMBER_ROW_HINTS, prefs.getBoolean(Settings.PREF_SHOW_HINTS, false)
|
||||||
|
&& prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false));
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings() {
|
private void refreshEnablingsOfKeypressSoundAndVibrationAndHistRetentionSettings() {
|
||||||
final SharedPreferences prefs = getSharedPreferences();
|
final SharedPreferences prefs = getSharedPreferences();
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
|
|
|
@ -147,6 +147,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
|
|
||||||
public static final String PREF_SHOW_NUMBER_ROW = "show_number_row";
|
public static final String PREF_SHOW_NUMBER_ROW = "show_number_row";
|
||||||
public static final String PREF_LOCALIZED_NUMBER_ROW = "localized_number_row";
|
public static final String PREF_LOCALIZED_NUMBER_ROW = "localized_number_row";
|
||||||
|
public static final String PREF_SHOW_NUMBER_ROW_HINTS = "show_number_row_hints";
|
||||||
public static final String PREF_CUSTOM_CURRENCY_KEY = "custom_currency_key";
|
public static final String PREF_CUSTOM_CURRENCY_KEY = "custom_currency_key";
|
||||||
|
|
||||||
public static final String PREF_SHOW_HINTS = "show_hints";
|
public static final String PREF_SHOW_HINTS = "show_hints";
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class SettingsValues {
|
||||||
private final boolean mShowsLanguageSwitchKey;
|
private final boolean mShowsLanguageSwitchKey;
|
||||||
public final boolean mShowsNumberRow;
|
public final boolean mShowsNumberRow;
|
||||||
public final boolean mLocalizedNumberRow;
|
public final boolean mLocalizedNumberRow;
|
||||||
|
public final boolean mShowNumberRowHints;
|
||||||
public final boolean mShowsHints;
|
public final boolean mShowsHints;
|
||||||
public final boolean mShowsPopupHints;
|
public final boolean mShowsPopupHints;
|
||||||
public final boolean mSpaceForLangChange;
|
public final boolean mSpaceForLangChange;
|
||||||
|
@ -174,6 +175,7 @@ public class SettingsValues {
|
||||||
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false); // only relevant for default functional key layout
|
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false); // only relevant for default functional key layout
|
||||||
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);
|
||||||
|
mShowNumberRowHints = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW_HINTS, false);
|
||||||
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true);
|
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true);
|
||||||
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);
|
||||||
|
|
|
@ -239,6 +239,8 @@
|
||||||
<string name="localized_number_row">Localize number row</string>
|
<string name="localized_number_row">Localize number row</string>
|
||||||
<!-- Description of the settings to localize number row -->
|
<!-- Description of the settings to localize number row -->
|
||||||
<string name="localized_number_row_summary">Prefer localized over latin numbers</string>
|
<string name="localized_number_row_summary">Prefer localized over latin numbers</string>
|
||||||
|
<!-- Title of the setting to enable number row hints -->
|
||||||
|
<string name="number_row_hints">Show hints on number row</string>
|
||||||
<!-- Title of the setting to show key hints -->
|
<!-- Title of the setting to show key hints -->
|
||||||
<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 -->
|
||||||
|
|
|
@ -85,6 +85,12 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="show_number_row_hints"
|
||||||
|
android:title="@string/number_row_hints"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:persistent="true" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="show_language_switch_key"
|
android:key="show_language_switch_key"
|
||||||
android:title="@string/show_language_switch_key"
|
android:title="@string/show_language_switch_key"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue