better instant-reload for some settings (while keyboard is showing)

This commit is contained in:
Helium314 2025-03-01 17:28:48 +01:00
parent 95b6333bf4
commit 1fc5d60483
2 changed files with 10 additions and 7 deletions

View file

@ -90,7 +90,7 @@ fun createAdvancedSettings(context: Context) = listOf(
Setting(context, Settings.PREF_ALWAYS_INCOGNITO_MODE, Setting(context, Settings.PREF_ALWAYS_INCOGNITO_MODE,
R.string.incognito, R.string.prefs_force_incognito_mode_summary) R.string.incognito, R.string.prefs_force_incognito_mode_summary)
{ {
SwitchPreference(it, Defaults.PREF_ALWAYS_INCOGNITO_MODE) SwitchPreference(it, Defaults.PREF_ALWAYS_INCOGNITO_MODE) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
}, },
Setting(context, Settings.PREF_KEY_LONGPRESS_TIMEOUT, R.string.prefs_key_longpress_timeout_settings) { setting -> Setting(context, Settings.PREF_KEY_LONGPRESS_TIMEOUT, R.string.prefs_key_longpress_timeout_settings) { setting ->
SliderPreference( SliderPreference(

View file

@ -81,7 +81,7 @@ fun PreferencesScreen(
fun createPreferencesSettings(context: Context) = listOf( fun createPreferencesSettings(context: Context) = listOf(
Setting(context, Settings.PREF_SHOW_HINTS, R.string.show_hints, R.string.show_hints_summary) { Setting(context, Settings.PREF_SHOW_HINTS, R.string.show_hints, R.string.show_hints_summary) {
SwitchPreference(it, Defaults.PREF_SHOW_HINTS) SwitchPreference(it, Defaults.PREF_SHOW_HINTS) { KeyboardSwitcher.getInstance().reloadKeyboard() }
}, },
Setting(context, Settings.PREF_POPUP_KEYS_LABELS_ORDER, R.string.hint_source) { Setting(context, Settings.PREF_POPUP_KEYS_LABELS_ORDER, R.string.hint_source) {
ReorderSwitchPreference(it, Defaults.PREF_POPUP_KEYS_LABELS_ORDER) ReorderSwitchPreference(it, Defaults.PREF_POPUP_KEYS_LABELS_ORDER)
@ -93,7 +93,7 @@ fun createPreferencesSettings(context: Context) = listOf(
SwitchPreference(it, Defaults.PREF_SHOW_POPUP_HINTS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() } SwitchPreference(it, Defaults.PREF_SHOW_POPUP_HINTS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
}, },
Setting(context, Settings.PREF_POPUP_ON, R.string.popup_on_keypress) { Setting(context, Settings.PREF_POPUP_ON, R.string.popup_on_keypress) {
SwitchPreference(it, Defaults.PREF_POPUP_ON) SwitchPreference(it, Defaults.PREF_POPUP_ON) { KeyboardSwitcher.getInstance().reloadKeyboard() }
}, },
Setting(context, Settings.PREF_VIBRATE_ON, R.string.vibrate_on_keypress) { Setting(context, Settings.PREF_VIBRATE_ON, R.string.vibrate_on_keypress) {
SwitchPreference(it, Defaults.PREF_VIBRATE_ON) SwitchPreference(it, Defaults.PREF_VIBRATE_ON)
@ -110,16 +110,19 @@ fun createPreferencesSettings(context: Context) = listOf(
SwitchPreference(it, Defaults.PREF_ENABLE_CLIPBOARD_HISTORY) SwitchPreference(it, Defaults.PREF_ENABLE_CLIPBOARD_HISTORY)
}, },
Setting(context, Settings.PREF_SHOW_NUMBER_ROW, R.string.number_row, R.string.number_row_summary) { Setting(context, Settings.PREF_SHOW_NUMBER_ROW, R.string.number_row, R.string.number_row_summary) {
SwitchPreference(it, Defaults.PREF_SHOW_NUMBER_ROW) { KeyboardSwitcher.getInstance().setThemeNeedsReload() } SwitchPreference(it, Defaults.PREF_SHOW_NUMBER_ROW) { KeyboardSwitcher.getInstance().reloadKeyboard() }
}, },
Setting(context, Settings.PREF_LOCALIZED_NUMBER_ROW, R.string.localized_number_row, R.string.localized_number_row_summary) { Setting(context, Settings.PREF_LOCALIZED_NUMBER_ROW, R.string.localized_number_row, R.string.localized_number_row_summary) {
SwitchPreference(it, Defaults.PREF_LOCALIZED_NUMBER_ROW) { KeyboardLayoutSet.onSystemLocaleChanged() } SwitchPreference(it, Defaults.PREF_LOCALIZED_NUMBER_ROW) {
KeyboardLayoutSet.onSystemLocaleChanged()
KeyboardSwitcher.getInstance().reloadKeyboard()
}
}, },
Setting(context, Settings.PREF_SHOW_NUMBER_ROW_HINTS, R.string.number_row_hints) { Setting(context, Settings.PREF_SHOW_NUMBER_ROW_HINTS, R.string.number_row_hints) {
SwitchPreference(it, Defaults.PREF_SHOW_NUMBER_ROW_HINTS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() } SwitchPreference(it, Defaults.PREF_SHOW_NUMBER_ROW_HINTS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
}, },
Setting(context, Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, R.string.show_language_switch_key) { Setting(context, Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, R.string.show_language_switch_key) {
SwitchPreference(it, Defaults.PREF_SHOW_LANGUAGE_SWITCH_KEY) { KeyboardSwitcher.getInstance().setThemeNeedsReload() } SwitchPreference(it, Defaults.PREF_SHOW_LANGUAGE_SWITCH_KEY) { KeyboardSwitcher.getInstance().reloadKeyboard() }
}, },
Setting(context, Settings.PREF_LANGUAGE_SWITCH_KEY, R.string.language_switch_key_behavior) { Setting(context, Settings.PREF_LANGUAGE_SWITCH_KEY, R.string.language_switch_key_behavior) {
ListPreference( ListPreference(
@ -133,7 +136,7 @@ fun createPreferencesSettings(context: Context) = listOf(
) { KeyboardSwitcher.getInstance().setThemeNeedsReload() } ) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
}, },
Setting(context, Settings.PREF_SHOW_EMOJI_KEY, R.string.show_emoji_key) { Setting(context, Settings.PREF_SHOW_EMOJI_KEY, R.string.show_emoji_key) {
SwitchPreference(it, Defaults.PREF_SHOW_EMOJI_KEY) SwitchPreference(it, Defaults.PREF_SHOW_EMOJI_KEY) { KeyboardSwitcher.getInstance().reloadKeyboard() }
}, },
Setting(context, Settings.PREF_REMOVE_REDUNDANT_POPUPS, Setting(context, Settings.PREF_REMOVE_REDUNDANT_POPUPS,
R.string.remove_redundant_popups, R.string.remove_redundant_popups_summary) R.string.remove_redundant_popups, R.string.remove_redundant_popups_summary)