0
0
mirror of https://github.com/florisboard/florisboard.git synced 2024-09-19 19:42:20 +02:00

Rework enum display string strategy

Preparation for further lib de-entanglement
This commit is contained in:
Patrick Goldinger 2024-07-05 17:56:29 +02:00
parent bd9f7750aa
commit 6244198795
No known key found for this signature in database
33 changed files with 643 additions and 733 deletions

View File

@ -0,0 +1,597 @@
package dev.patrickgold.florisboard.app
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.settings.theme.DisplayColorsAs
import dev.patrickgold.florisboard.app.settings.theme.DisplayKbdAfterDialogs
import dev.patrickgold.florisboard.ime.core.DisplayLanguageNamesIn
import dev.patrickgold.florisboard.ime.input.CapitalizationBehavior
import dev.patrickgold.florisboard.ime.input.HapticVibrationMode
import dev.patrickgold.florisboard.ime.input.InputFeedbackActivationMode
import dev.patrickgold.florisboard.ime.keyboard.IncognitoMode
import dev.patrickgold.florisboard.ime.keyboard.SpaceBarMode
import dev.patrickgold.florisboard.ime.landscapeinput.LandscapeInputUiMode
import dev.patrickgold.florisboard.ime.media.emoji.EmojiSkinTone
import dev.patrickgold.florisboard.ime.nlp.SpellingLanguageMode
import dev.patrickgold.florisboard.ime.onehanded.OneHandedMode
import dev.patrickgold.florisboard.ime.smartbar.CandidatesDisplayMode
import dev.patrickgold.florisboard.ime.smartbar.ExtendedActionsPlacement
import dev.patrickgold.florisboard.ime.smartbar.IncognitoDisplayMode
import dev.patrickgold.florisboard.ime.smartbar.SmartbarLayout
import dev.patrickgold.florisboard.ime.text.gestures.SwipeAction
import dev.patrickgold.florisboard.ime.text.key.KeyHintMode
import dev.patrickgold.florisboard.ime.text.key.UtilityKeyAction
import dev.patrickgold.florisboard.ime.theme.ThemeMode
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.florisboard.lib.snygg.SnyggLevel
import dev.patrickgold.jetpref.datastore.ui.ListPreferenceEntry
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
import org.florisboard.lib.kotlin.curlyFormat
import kotlin.reflect.KClass
private const val DEFAULT = ""
private val ENUM_DISPLAY_ENTRIES = mapOf<Pair<KClass<*>, String>, @Composable () -> List<ListPreferenceEntry<*>>>(
AppTheme::class to DEFAULT to {
listPrefEntries {
entry(
key = AppTheme.AUTO,
label = stringRes(R.string.settings__system_default),
)
entry(
key = AppTheme.AUTO_AMOLED,
label = stringRes(R.string.pref__advanced__settings_theme__auto_amoled),
)
entry(
key = AppTheme.LIGHT,
label = stringRes(R.string.pref__advanced__settings_theme__light),
)
entry(
key = AppTheme.DARK,
label = stringRes(R.string.pref__advanced__settings_theme__dark),
)
entry(
key = AppTheme.AMOLED_DARK,
label = stringRes(R.string.pref__advanced__settings_theme__amoled_dark),
)
}
},
CandidatesDisplayMode::class to DEFAULT to {
listPrefEntries {
entry(
key = CandidatesDisplayMode.CLASSIC,
label = stringRes(R.string.enum__candidates_display_mode__classic),
)
entry(
key = CandidatesDisplayMode.DYNAMIC,
label = stringRes(R.string.enum__candidates_display_mode__dynamic),
)
entry(
key = CandidatesDisplayMode.DYNAMIC_SCROLLABLE,
label = stringRes(R.string.enum__candidates_display_mode__dynamic_scrollable),
)
}
},
CapitalizationBehavior::class to DEFAULT to {
listPrefEntries {
entry(
key = CapitalizationBehavior.CAPSLOCK_BY_DOUBLE_TAP,
label = stringRes(R.string.enum__capitalization_behavior__capslock_by_double_tap),
)
entry(
key = CapitalizationBehavior.CAPSLOCK_BY_CYCLE,
label = stringRes(R.string.enum__capitalization_behavior__capslock_by_cycle),
)
}
},
DisplayColorsAs::class to DEFAULT to {
listPrefEntries {
entry(
key = DisplayColorsAs.HEX8,
label = stringRes(R.string.enum__display_colors_as__hex8),
description = stringRes(R.string.general__example_given).curlyFormat("example" to "#4caf50ff"),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DisplayColorsAs.RGBA,
label = stringRes(R.string.enum__display_colors_as__rgba),
description = stringRes(R.string.general__example_given).curlyFormat("example" to "rgba(76,175,80,1.0)"),
showDescriptionOnlyIfSelected = true,
)
}
},
DisplayKbdAfterDialogs::class to DEFAULT to {
listPrefEntries {
entry(
key = DisplayKbdAfterDialogs.ALWAYS,
label = stringRes(R.string.enum__display_kbd_after_dialogs__always),
description = stringRes(R.string.enum__display_kbd_after_dialogs__always__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DisplayKbdAfterDialogs.NEVER,
label = stringRes(R.string.enum__display_kbd_after_dialogs__never),
description = stringRes(R.string.enum__display_kbd_after_dialogs__never__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DisplayKbdAfterDialogs.REMEMBER,
label = stringRes(R.string.enum__display_kbd_after_dialogs__remember),
description = stringRes(R.string.enum__display_kbd_after_dialogs__remember__description),
showDescriptionOnlyIfSelected = true,
)
}
},
DisplayLanguageNamesIn::class to DEFAULT to {
listPrefEntries {
entry(
key = DisplayLanguageNamesIn.SYSTEM_LOCALE,
label = stringRes(R.string.enum__display_language_names_in__system_locale),
description = stringRes(R.string.enum__display_language_names_in__system_locale__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DisplayLanguageNamesIn.NATIVE_LOCALE,
label = stringRes(R.string.enum__display_language_names_in__native_locale),
description = stringRes(R.string.enum__display_language_names_in__native_locale__description),
showDescriptionOnlyIfSelected = true,
)
}
},
EmojiSkinTone::class to DEFAULT to {
listPrefEntries {
entry(
key = EmojiSkinTone.DEFAULT,
label = stringRes(
R.string.enum__emoji_skin_tone__default,
"emoji" to "\uD83D\uDC4B" // 👋
),
)
entry(
key = EmojiSkinTone.LIGHT_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__light_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFB" // 👋🏻
),
)
entry(
key = EmojiSkinTone.MEDIUM_LIGHT_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_light_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFC" // 👋🏼
),
)
entry(
key = EmojiSkinTone.MEDIUM_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFD" // 👋🏽
),
)
entry(
key = EmojiSkinTone.MEDIUM_DARK_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_dark_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFE" // 👋🏾
),
)
entry(
key = EmojiSkinTone.DARK_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__dark_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFF" // 👋🏿
),
)
}
},
ExtendedActionsPlacement::class to DEFAULT to {
listPrefEntries {
entry(
key = ExtendedActionsPlacement.ABOVE_CANDIDATES,
label = stringRes(R.string.enum__extended_actions_placement__above_candidates),
description = stringRes(R.string.enum__extended_actions_placement__above_candidates__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = ExtendedActionsPlacement.BELOW_CANDIDATES,
label = stringRes(R.string.enum__extended_actions_placement__below_candidates),
description = stringRes(R.string.enum__extended_actions_placement__below_candidates__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = ExtendedActionsPlacement.OVERLAY_APP_UI,
label = stringRes(R.string.enum__extended_actions_placement__overlay_app_ui),
description = stringRes(R.string.enum__extended_actions_placement__overlay_app_ui__description),
showDescriptionOnlyIfSelected = true,
)
}
},
HapticVibrationMode::class to DEFAULT to {
listPrefEntries {
entry(
key = HapticVibrationMode.USE_VIBRATOR_DIRECTLY,
label = stringRes(R.string.enum__haptic_vibration_mode__use_vibrator_directly),
description = stringRes(R.string.enum__haptic_vibration_mode__use_vibrator_directly__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = HapticVibrationMode.USE_HAPTIC_FEEDBACK_INTERFACE,
label = stringRes(R.string.enum__haptic_vibration_mode__use_haptic_feedback_interface),
description = stringRes(R.string.enum__haptic_vibration_mode__use_haptic_feedback_interface__description),
showDescriptionOnlyIfSelected = true,
)
}
},
KeyHintMode::class to DEFAULT to {
listPrefEntries {
entry(
key = KeyHintMode.ACCENT_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__accent_priority),
description = stringRes(R.string.enum__key_hint_mode__accent_priority__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = KeyHintMode.HINT_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__hint_priority),
description = stringRes(R.string.enum__key_hint_mode__hint_priority__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = KeyHintMode.SMART_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__smart_priority),
description = stringRes(R.string.enum__key_hint_mode__smart_priority__description),
showDescriptionOnlyIfSelected = true,
)
}
},
IncognitoDisplayMode::class to DEFAULT to {
listPrefEntries {
entry(
key = IncognitoDisplayMode.REPLACE_SHARED_ACTIONS_TOGGLE,
label = stringRes(id = R.string.enum__incognito_display_mode__replace_shared_actions_toggle),
)
entry(
key = IncognitoDisplayMode.DISPLAY_BEHIND_KEYBOARD,
label = stringRes(id = R.string.enum__incognito_display_mode__display_behind_keyboard),
)
}
},
IncognitoMode::class to DEFAULT to {
listPrefEntries {
entry(
key = IncognitoMode.FORCE_OFF,
label = stringRes(R.string.enum__incognito_mode__force_off),
description = stringRes(R.string.enum__incognito_mode__force_off__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = IncognitoMode.DYNAMIC_ON_OFF,
label = stringRes(R.string.enum__incognito_mode__dynamic_on_off),
description = stringRes(R.string.enum__incognito_mode__dynamic_on_off__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = IncognitoMode.FORCE_ON,
label = stringRes(R.string.enum__incognito_mode__force_on),
description = stringRes(R.string.enum__incognito_mode__force_on__description),
showDescriptionOnlyIfSelected = true,
)
}
},
InputFeedbackActivationMode::class to "audio" to {
listPrefEntries {
entry(
key = InputFeedbackActivationMode.RESPECT_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__audio_respect_system_settings),
)
entry(
key = InputFeedbackActivationMode.IGNORE_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__audio_ignore_system_settings),
)
}
},
InputFeedbackActivationMode::class to "haptic" to {
listPrefEntries {
entry(
key = InputFeedbackActivationMode.RESPECT_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__haptic_respect_system_settings),
)
entry(
key = InputFeedbackActivationMode.IGNORE_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__haptic_ignore_system_settings),
)
}
},
LandscapeInputUiMode::class to DEFAULT to {
listPrefEntries {
entry(
key = LandscapeInputUiMode.NEVER_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__never_show),
)
entry(
key = LandscapeInputUiMode.ALWAYS_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__always_show),
)
entry(
key = LandscapeInputUiMode.DYNAMICALLY_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__dynamically_show),
)
}
},
OneHandedMode::class to DEFAULT to {
listPrefEntries {
entry(
key = OneHandedMode.OFF,
label = stringRes(R.string.enum__one_handed_mode__off),
)
entry(
key = OneHandedMode.START,
label = stringRes(R.string.enum__one_handed_mode__start),
)
entry(
key = OneHandedMode.END,
label = stringRes(R.string.enum__one_handed_mode__end),
)
}
},
SmartbarLayout::class to DEFAULT to {
listPrefEntries {
entry(
key = SmartbarLayout.SUGGESTIONS_ONLY,
label = stringRes(R.string.enum__smartbar_layout__suggestions_only),
description = stringRes(R.string.enum__smartbar_layout__suggestions_only__description),
)
entry(
key = SmartbarLayout.ACTIONS_ONLY,
label = stringRes(R.string.enum__smartbar_layout__actions_only),
description = stringRes(R.string.enum__smartbar_layout__actions_only__description),
)
entry(
key = SmartbarLayout.SUGGESTIONS_ACTIONS_SHARED,
label = stringRes(R.string.enum__smartbar_layout__suggestions_action_shared),
description = stringRes(R.string.enum__smartbar_layout__suggestions_action_shared__description),
)
entry(
key = SmartbarLayout.SUGGESTIONS_ACTIONS_EXTENDED,
label = stringRes(R.string.enum__smartbar_layout__suggestions_actions_extended),
description = stringRes(R.string.enum__smartbar_layout__suggestions_actions_extended__description),
)
}
},
SnyggLevel::class to DEFAULT to {
listPrefEntries {
entry(
key = SnyggLevel.BASIC,
label = stringRes(R.string.enum__snygg_level__basic),
description = stringRes(R.string.enum__snygg_level__basic__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = SnyggLevel.ADVANCED,
label = stringRes(R.string.enum__snygg_level__advanced),
description = stringRes(R.string.enum__snygg_level__advanced__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = SnyggLevel.DEVELOPER,
label = stringRes(R.string.enum__snygg_level__developer),
description = stringRes(R.string.enum__snygg_level__developer__description),
showDescriptionOnlyIfSelected = true,
)
}
},
SpaceBarMode::class to DEFAULT to {
listPrefEntries {
entry(
key = SpaceBarMode.NOTHING,
label = stringRes(R.string.enum__space_bar_mode__nothing),
)
entry(
key = SpaceBarMode.CURRENT_LANGUAGE,
label = stringRes(R.string.enum__space_bar_mode__current_language),
)
entry(
key = SpaceBarMode.SPACE_BAR_KEY,
label = stringRes(R.string.enum__space_bar_mode__space_bar_key),
)
}
},
SpellingLanguageMode::class to DEFAULT to {
listPrefEntries {
entry(
key = SpellingLanguageMode.USE_SYSTEM_LANGUAGES,
label = stringRes(R.string.enum__spelling_language_mode__use_system_languages),
)
entry(
key = SpellingLanguageMode.USE_KEYBOARD_SUBTYPES,
label = stringRes(R.string.enum__spelling_language_mode__use_keyboard_subtypes),
)
}
},
SwipeAction::class to "general" to {
listPrefEntries {
entry(
key = SwipeAction.NO_ACTION,
label = stringRes(R.string.enum__swipe_action__no_action),
)
entry(
key = SwipeAction.CYCLE_TO_PREVIOUS_KEYBOARD_MODE,
label = stringRes(R.string.enum__swipe_action__cycle_to_previous_keyboard_mode),
)
entry(
key = SwipeAction.CYCLE_TO_NEXT_KEYBOARD_MODE,
label = stringRes(R.string.enum__swipe_action__cycle_to_next_keyboard_mode),
)
entry(
key = SwipeAction.DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
entry(
key = SwipeAction.HIDE_KEYBOARD,
label = stringRes(R.string.enum__swipe_action__hide_keyboard),
)
entry(
key = SwipeAction.INSERT_SPACE,
label = stringRes(R.string.enum__swipe_action__insert_space),
)
entry(
key = SwipeAction.MOVE_CURSOR_UP,
label = stringRes(R.string.enum__swipe_action__move_cursor_up),
)
entry(
key = SwipeAction.MOVE_CURSOR_DOWN,
label = stringRes(R.string.enum__swipe_action__move_cursor_down),
)
entry(
key = SwipeAction.MOVE_CURSOR_LEFT,
label = stringRes(R.string.enum__swipe_action__move_cursor_left),
)
entry(
key = SwipeAction.MOVE_CURSOR_RIGHT,
label = stringRes(R.string.enum__swipe_action__move_cursor_right),
)
entry(
key = SwipeAction.MOVE_CURSOR_START_OF_LINE,
label = stringRes(R.string.enum__swipe_action__move_cursor_start_of_line),
)
entry(
key = SwipeAction.MOVE_CURSOR_END_OF_LINE,
label = stringRes(R.string.enum__swipe_action__move_cursor_end_of_line),
)
entry(
key = SwipeAction.MOVE_CURSOR_START_OF_PAGE,
label = stringRes(R.string.enum__swipe_action__move_cursor_start_of_page),
)
entry(
key = SwipeAction.MOVE_CURSOR_END_OF_PAGE,
label = stringRes(R.string.enum__swipe_action__move_cursor_end_of_page),
)
entry(
key = SwipeAction.SHIFT,
label = stringRes(R.string.enum__swipe_action__shift),
)
entry(
key = SwipeAction.REDO,
label = stringRes(R.string.enum__swipe_action__redo),
)
entry(
key = SwipeAction.UNDO,
label = stringRes(R.string.enum__swipe_action__undo),
)
entry(
key = SwipeAction.SWITCH_TO_CLIPBOARD_CONTEXT,
label = stringRes(R.string.enum__swipe_action__switch_to_clipboard_context),
)
entry(
key = SwipeAction.SHOW_INPUT_METHOD_PICKER,
label = stringRes(R.string.enum__swipe_action__show_input_method_picker),
)
entry(
key = SwipeAction.SWITCH_TO_PREV_SUBTYPE,
label = stringRes(R.string.enum__swipe_action__switch_to_prev_subtype),
)
entry(
key = SwipeAction.SWITCH_TO_NEXT_SUBTYPE,
label = stringRes(R.string.enum__swipe_action__switch_to_next_subtype),
)
entry(
key = SwipeAction.SWITCH_TO_PREV_KEYBOARD,
label = stringRes(R.string.enum__swipe_action__switch_to_prev_keyboard),
)
entry(
key = SwipeAction.TOGGLE_SMARTBAR_VISIBILITY,
label = stringRes(R.string.enum__swipe_action__toggle_smartbar_visibility),
)
}
},
SwipeAction::class to "deleteSwipe" to {
listPrefEntries {
entry(
key = SwipeAction.NO_ACTION,
label = stringRes(R.string.enum__swipe_action__no_action),
)
entry(
key = SwipeAction.DELETE_CHARACTERS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__delete_characters_precisely),
)
entry(
key = SwipeAction.DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
entry(
key = SwipeAction.DELETE_WORDS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__delete_words_precisely),
)
entry(
key = SwipeAction.SELECT_CHARACTERS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__select_characters_precisely),
)
entry(
key = SwipeAction.SELECT_WORDS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__select_words_precisely),
)
}
},
SwipeAction::class to "deleteLongPress" to {
listPrefEntries {
entry(
key = SwipeAction.DELETE_CHARACTER,
label = stringRes(R.string.enum__swipe_action__delete_character),
)
entry(
key = SwipeAction.DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
}
},
ThemeMode::class to DEFAULT to {
listPrefEntries {
entry(
key = ThemeMode.ALWAYS_DAY,
label = stringRes(R.string.enum__theme_mode__always_day),
)
entry(
key = ThemeMode.ALWAYS_NIGHT,
label = stringRes(R.string.enum__theme_mode__always_night),
)
entry(
key = ThemeMode.FOLLOW_SYSTEM,
label = stringRes(R.string.enum__theme_mode__follow_system),
)
entry(
key = ThemeMode.FOLLOW_TIME,
label = stringRes(R.string.enum__theme_mode__follow_time),
)
}
},
UtilityKeyAction::class to DEFAULT to {
listPrefEntries {
entry(
key = UtilityKeyAction.SWITCH_TO_EMOJIS,
label = stringRes(R.string.enum__utility_key_action__switch_to_emojis),
)
entry(
key = UtilityKeyAction.SWITCH_LANGUAGE,
label = stringRes(R.string.enum__utility_key_action__switch_language),
)
entry(
key = UtilityKeyAction.SWITCH_KEYBOARD_APP,
label = stringRes(R.string.enum__utility_key_action__switch_keyboard_app),
)
entry(
key = UtilityKeyAction.DYNAMIC_SWITCH_LANGUAGE_EMOJIS,
label = stringRes(R.string.enum__utility_key_action__dynamic_switch_language_emojis),
)
}
},
)
@Composable
fun <V : Any> enumDisplayEntriesOf(
enumClass: KClass<V>,
variant: String = DEFAULT,
): List<ListPreferenceEntry<V>> {
@Suppress("UNCHECKED_CAST")
return ENUM_DISPLAY_ENTRIES[enumClass to variant]?.invoke()
as List<ListPreferenceEntry<V>>
}

View File

@ -30,6 +30,7 @@ import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.AppTheme
import dev.patrickgold.florisboard.app.LocalNavController
import dev.patrickgold.florisboard.app.Routes
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.core.DisplayLanguageNamesIn
import dev.patrickgold.florisboard.ime.keyboard.IncognitoMode
import dev.patrickgold.florisboard.lib.FlorisLocale
@ -56,28 +57,7 @@ fun AdvancedScreen() = FlorisScreen {
prefs.advanced.settingsTheme,
icon = Icons.Default.Palette,
title = stringRes(R.string.pref__advanced__settings_theme__label),
entries = listPrefEntries {
entry(
key = AppTheme.AUTO,
label = stringRes(R.string.settings__system_default),
)
entry(
key = AppTheme.AUTO_AMOLED,
label = stringRes(R.string.pref__advanced__settings_theme__auto_amoled),
)
entry(
key = AppTheme.LIGHT,
label = stringRes(R.string.pref__advanced__settings_theme__light),
)
entry(
key = AppTheme.DARK,
label = stringRes(R.string.pref__advanced__settings_theme__dark),
)
entry(
key = AppTheme.AMOLED_DARK,
label = stringRes(R.string.pref__advanced__settings_theme__amoled_dark),
)
},
entries = enumDisplayEntriesOf(AppTheme::class),
)
SwitchPreference(
pref = prefs.advanced.useMaterialYou,
@ -165,7 +145,7 @@ fun AdvancedScreen() = FlorisScreen {
prefs.advanced.incognitoMode,
icon = vectorResource(id = R.drawable.ic_incognito),
title = stringRes(R.string.pref__advanced__incognito_mode__label),
entries = IncognitoMode.listEntries(),
entries = enumDisplayEntriesOf(IncognitoMode::class),
)
Preference(
icon = Icons.Default.Adb,

View File

@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.text.gestures.SwipeAction
import dev.patrickgold.florisboard.lib.compose.FlorisInfoCard
import dev.patrickgold.florisboard.lib.compose.FlorisScreen
@ -93,25 +94,25 @@ fun GesturesScreen() = FlorisScreen {
ListPreference(
prefs.gestures.swipeUp,
title = stringRes(R.string.pref__gestures__swipe_up__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
enabledIf = { prefs.glide.enabled isEqualTo false },
)
ListPreference(
prefs.gestures.swipeDown,
title = stringRes(R.string.pref__gestures__swipe_down__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
enabledIf = { prefs.glide.enabled isEqualTo false },
)
ListPreference(
prefs.gestures.swipeLeft,
title = stringRes(R.string.pref__gestures__swipe_left__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
enabledIf = { prefs.glide.enabled isEqualTo false },
)
ListPreference(
prefs.gestures.swipeRight,
title = stringRes(R.string.pref__gestures__swipe_right__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
enabledIf = { prefs.glide.enabled isEqualTo false },
)
}
@ -120,22 +121,22 @@ fun GesturesScreen() = FlorisScreen {
ListPreference(
prefs.gestures.spaceBarSwipeUp,
title = stringRes(R.string.pref__gestures__space_bar_swipe_up__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
)
ListPreference(
prefs.gestures.spaceBarSwipeLeft,
title = stringRes(R.string.pref__gestures__space_bar_swipe_left__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
)
ListPreference(
prefs.gestures.spaceBarSwipeRight,
title = stringRes(R.string.pref__gestures__space_bar_swipe_right__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
)
ListPreference(
prefs.gestures.spaceBarLongPress,
title = stringRes(R.string.pref__gestures__space_bar_long_press__label),
entries = SwipeAction.generalListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "general"),
)
}
@ -143,12 +144,12 @@ fun GesturesScreen() = FlorisScreen {
ListPreference(
prefs.gestures.deleteKeySwipeLeft,
title = stringRes(R.string.pref__gestures__delete_key_swipe_left__label),
entries = SwipeAction.deleteSwipeListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "deleteSwipe"),
)
ListPreference(
prefs.gestures.deleteKeyLongPress,
title = stringRes(R.string.pref__gestures__delete_key_long_press__label),
entries = SwipeAction.deleteLongPressListEntries(),
entries = enumDisplayEntriesOf(SwipeAction::class, "deleteLongPress"),
)
DialogSliderPreference(
prefs.gestures.swipeVelocityThreshold,

View File

@ -19,6 +19,7 @@ package dev.patrickgold.florisboard.app.settings.keyboard
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.input.InputFeedbackActivationMode
import dev.patrickgold.florisboard.ime.input.HapticVibrationMode
import org.florisboard.lib.android.AndroidVersion
@ -49,7 +50,7 @@ fun InputFeedbackScreen() = FlorisScreen {
switchPref = prefs.inputFeedback.audioEnabled,
title = stringRes(R.string.pref__input_feedback__audio_enabled__label),
summarySwitchDisabled = stringRes(R.string.pref__input_feedback__audio_enabled__summary_disabled),
entries = InputFeedbackActivationMode.audioListEntries(),
entries = enumDisplayEntriesOf(InputFeedbackActivationMode::class, "audio"),
)
DialogSliderPreference(
prefs.inputFeedback.audioVolume,
@ -98,13 +99,13 @@ fun InputFeedbackScreen() = FlorisScreen {
switchPref = prefs.inputFeedback.hapticEnabled,
title = stringRes(R.string.pref__input_feedback__haptic_enabled__label),
summarySwitchDisabled = stringRes(R.string.pref__input_feedback__haptic_enabled__summary_disabled),
entries = InputFeedbackActivationMode.hapticListEntries(),
entries = enumDisplayEntriesOf(InputFeedbackActivationMode::class, "haptic")
)
ListPreference(
prefs.inputFeedback.hapticVibrationMode,
title = stringRes(R.string.pref__input_feedback__haptic_vibration_mode__label),
enabledIf = { prefs.inputFeedback.hapticEnabled isEqualTo true },
entries = HapticVibrationMode.listEntries(),
entries = enumDisplayEntriesOf(HapticVibrationMode::class),
)
DialogSliderPreference(
prefs.inputFeedback.hapticVibrationDuration,

View File

@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.LocalNavController
import dev.patrickgold.florisboard.app.Routes
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.input.CapitalizationBehavior
import dev.patrickgold.florisboard.ime.keyboard.SpaceBarMode
import dev.patrickgold.florisboard.ime.landscapeinput.LandscapeInputUiMode
@ -55,14 +56,14 @@ fun KeyboardScreen() = FlorisScreen {
switchPref = prefs.keyboard.hintedNumberRowEnabled,
title = stringRes(R.string.pref__keyboard__hinted_number_row_mode__label),
summarySwitchDisabled = stringRes(R.string.state__disabled),
entries = KeyHintMode.listEntries(),
entries = enumDisplayEntriesOf(KeyHintMode::class),
)
ListPreference(
listPref = prefs.keyboard.hintedSymbolsMode,
switchPref = prefs.keyboard.hintedSymbolsEnabled,
title = stringRes(R.string.pref__keyboard__hinted_symbols_mode__label),
summarySwitchDisabled = stringRes(R.string.state__disabled),
entries = KeyHintMode.listEntries(),
entries = enumDisplayEntriesOf(KeyHintMode::class),
)
SwitchPreference(
prefs.keyboard.utilityKeyEnabled,
@ -72,18 +73,18 @@ fun KeyboardScreen() = FlorisScreen {
ListPreference(
prefs.keyboard.utilityKeyAction,
title = stringRes(R.string.pref__keyboard__utility_key_action__label),
entries = UtilityKeyAction.listEntries(),
entries = enumDisplayEntriesOf(UtilityKeyAction::class),
visibleIf = { prefs.keyboard.utilityKeyEnabled isEqualTo true },
)
ListPreference(
prefs.keyboard.spaceBarMode,
title = stringRes(R.string.pref__keyboard__space_bar_mode__label),
entries = SpaceBarMode.listEntries(),
entries = enumDisplayEntriesOf(SpaceBarMode::class),
)
ListPreference(
prefs.keyboard.capitalizationBehavior,
title = stringRes(R.string.pref__keyboard__capitalization_behavior__label),
entries = CapitalizationBehavior.listEntries(),
entries = enumDisplayEntriesOf(CapitalizationBehavior::class),
)
DialogSliderPreference(
primaryPref = prefs.keyboard.fontSizeMultiplierPortrait,
@ -99,14 +100,14 @@ fun KeyboardScreen() = FlorisScreen {
ListPreference(
listPref = prefs.keyboard.incognitoDisplayMode,
title = stringRes(R.string.pref__keyboard__incognito_indicator__label),
entries = IncognitoDisplayMode.listEntries(),
entries = enumDisplayEntriesOf(IncognitoDisplayMode::class),
)
PreferenceGroup(title = stringRes(R.string.pref__keyboard__group_layout__label)) {
ListPreference(
prefs.keyboard.oneHandedMode,
title = stringRes(R.string.pref__keyboard__one_handed_mode__label),
entries = OneHandedMode.listEntries(),
entries = enumDisplayEntriesOf(OneHandedMode::class),
)
DialogSliderPreference(
prefs.keyboard.oneHandedModeScaleFactor,
@ -120,7 +121,7 @@ fun KeyboardScreen() = FlorisScreen {
ListPreference(
prefs.keyboard.landscapeInputUiMode,
title = stringRes(R.string.pref__keyboard__landscape_input_ui_mode__label),
entries = LandscapeInputUiMode.listEntries(),
entries = enumDisplayEntriesOf(LandscapeInputUiMode::class),
)
DialogSliderPreference(
primaryPref = prefs.keyboard.heightFactorPortrait,

View File

@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.LocalNavController
import dev.patrickgold.florisboard.app.Routes
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.cacheManager
import dev.patrickgold.florisboard.ime.core.DisplayLanguageNamesIn
import dev.patrickgold.florisboard.ime.keyboard.LayoutType
@ -76,12 +77,11 @@ fun LocalizationScreen() = FlorisScreen {
)
}
content {
ListPreference(
prefs.localization.displayLanguageNamesIn,
title = stringRes(R.string.settings__localization__display_language_names_in__label),
entries = DisplayLanguageNamesIn.listEntries(),
entries = enumDisplayEntriesOf(DisplayLanguageNamesIn::class),
)
Preference(
// icon = R.drawable.ic_edit,

View File

@ -18,6 +18,7 @@ package dev.patrickgold.florisboard.app.settings.media
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.media.emoji.EmojiSkinTone
import dev.patrickgold.florisboard.lib.compose.FlorisScreen
import dev.patrickgold.florisboard.lib.compose.pluralsRes
@ -37,7 +38,7 @@ fun MediaScreen() = FlorisScreen {
ListPreference(
prefs.media.emojiPreferredSkinTone,
title = stringRes(R.string.prefs__media__emoji_preferred_skin_tone),
entries = EmojiSkinTone.listEntries(),
entries = enumDisplayEntriesOf(EmojiSkinTone::class),
)
DialogSliderPreference(
prefs.media.emojiRecentlyUsedMaxSize,

View File

@ -18,6 +18,7 @@ package dev.patrickgold.florisboard.app.settings.smartbar
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.smartbar.CandidatesDisplayMode
import dev.patrickgold.florisboard.ime.smartbar.ExtendedActionsPlacement
import dev.patrickgold.florisboard.ime.smartbar.SmartbarLayout
@ -41,7 +42,7 @@ fun SmartbarScreen() = FlorisScreen {
ListPreference(
listPref = prefs.smartbar.layout,
title = stringRes(R.string.pref__smartbar__layout__label),
entries = SmartbarLayout.listEntries(),
entries = enumDisplayEntriesOf(SmartbarLayout::class),
enabledIf = { prefs.smartbar.enabled isEqualTo true },
)
@ -49,7 +50,7 @@ fun SmartbarScreen() = FlorisScreen {
ListPreference(
prefs.suggestion.displayMode,
title = stringRes(R.string.pref__suggestion__display_mode__label),
entries = CandidatesDisplayMode.listEntries(),
entries = enumDisplayEntriesOf(CandidatesDisplayMode::class),
enabledIf = { prefs.smartbar.enabled isEqualTo true },
visibleIf = { prefs.smartbar.layout isNotEqualTo SmartbarLayout.ACTIONS_ONLY },
)
@ -73,7 +74,7 @@ fun SmartbarScreen() = FlorisScreen {
ListPreference(
listPref = prefs.smartbar.extendedActionsPlacement,
title = stringRes(R.string.pref__smartbar__extended_actions_placement__label),
entries = ExtendedActionsPlacement.listEntries(),
entries = enumDisplayEntriesOf(ExtendedActionsPlacement::class),
enabledIf = { prefs.smartbar.enabled isEqualTo true },
visibleIf = { prefs.smartbar.layout isEqualTo SmartbarLayout.SUGGESTIONS_ACTIONS_EXTENDED },
)

View File

@ -16,34 +16,10 @@
package dev.patrickgold.florisboard.app.settings.theme
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
import org.florisboard.lib.kotlin.curlyFormat
/**
* DisplayColorsAs indicates how color strings should be visually presented to the user.
*/
enum class DisplayColorsAs {
HEX8,
RGBA;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = HEX8,
label = stringRes(R.string.enum__display_colors_as__hex8),
description = stringRes(R.string.general__example_given).curlyFormat("example" to "#4caf50ff"),
showDescriptionOnlyIfSelected = true,
)
entry(
key = RGBA,
label = stringRes(R.string.enum__display_colors_as__rgba),
description = stringRes(R.string.general__example_given).curlyFormat("example" to "rgba(76,175,80,1.0)"),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.app.settings.theme
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* DisplayPreviewAfterDialogs indicates if the keyboard should auto-open after closing
* any dialog. This is useful because the dialog always hides the keyboard and one may
@ -30,28 +25,4 @@ enum class DisplayKbdAfterDialogs {
ALWAYS,
NEVER,
REMEMBER;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = ALWAYS,
label = stringRes(R.string.enum__display_kbd_after_dialogs__always),
description = stringRes(R.string.enum__display_kbd_after_dialogs__always__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = NEVER,
label = stringRes(R.string.enum__display_kbd_after_dialogs__never),
description = stringRes(R.string.enum__display_kbd_after_dialogs__never__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = REMEMBER,
label = stringRes(R.string.enum__display_kbd_after_dialogs__remember),
description = stringRes(R.string.enum__display_kbd_after_dialogs__remember__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.app.florisPreferenceModel
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.florisboard.lib.snygg.SnyggLevel
@ -40,17 +41,17 @@ fun FineTuneDialog(onDismiss: () -> Unit) {
ListPreference(
listPref = prefs.theme.editorLevel,
title = stringRes(R.string.settings__theme_editor__fine_tune__level),
entries = SnyggLevel.listEntries(),
entries = enumDisplayEntriesOf(SnyggLevel::class),
)
ListPreference(
listPref = prefs.theme.editorDisplayColorsAs,
title = stringRes(R.string.settings__theme_editor__fine_tune__display_colors_as),
entries = DisplayColorsAs.listEntries(),
entries = enumDisplayEntriesOf(DisplayColorsAs::class),
)
ListPreference(
listPref = prefs.theme.editorDisplayKbdAfterDialogs,
title = stringRes(R.string.settings__theme_editor__fine_tune__display_kbd_after_dialogs),
entries = DisplayKbdAfterDialogs.listEntries(),
entries = enumDisplayEntriesOf(DisplayKbdAfterDialogs::class),
)
}
}

View File

@ -30,6 +30,7 @@ import androidx.compose.ui.unit.dp
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.LocalNavController
import dev.patrickgold.florisboard.app.Routes
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.app.ext.AddonManagementReferenceBox
import dev.patrickgold.florisboard.app.ext.ExtensionListScreenType
import dev.patrickgold.florisboard.ime.theme.ThemeManager
@ -79,7 +80,7 @@ fun ThemeScreen() = FlorisScreen {
prefs.theme.mode,
icon = Icons.Default.BrightnessAuto,
title = stringRes(R.string.pref__theme__mode__label),
entries = ThemeMode.listEntries(),
entries = enumDisplayEntriesOf(ThemeMode::class),
)
if (themeMode == ThemeMode.FOLLOW_TIME) {
FlorisInfoCard(

View File

@ -34,6 +34,7 @@ import androidx.compose.ui.unit.dp
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.app.LocalNavController
import dev.patrickgold.florisboard.app.Routes
import dev.patrickgold.florisboard.app.enumDisplayEntriesOf
import dev.patrickgold.florisboard.ime.nlp.SpellingLanguageMode
import org.florisboard.lib.android.AndroidVersion
import dev.patrickgold.florisboard.lib.compose.FlorisErrorCard
@ -151,7 +152,7 @@ fun TypingScreen() = FlorisScreen {
prefs.spelling.languageMode,
icon = Icons.Default.Language,
title = stringRes(R.string.pref__spelling__language_mode__label),
entries = SpellingLanguageMode.listEntries(),
entries = enumDisplayEntriesOf(SpellingLanguageMode::class),
enabledIf = { florisSpellCheckerEnabled.value },
)
SwitchPreference(

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.core
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* DisplayLocalesIn indicates how language names should be visually presented to the user.
*/
@ -29,22 +24,4 @@ enum class DisplayLanguageNamesIn {
SYSTEM_LOCALE,
/** Language names are displayed in the locale referred by itself. */
NATIVE_LOCALE;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = SYSTEM_LOCALE,
label = stringRes(R.string.enum__display_language_names_in__system_locale),
description = stringRes(R.string.enum__display_language_names_in__system_locale__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = NATIVE_LOCALE,
label = stringRes(R.string.enum__display_language_names_in__native_locale),
description = stringRes(R.string.enum__display_language_names_in__native_locale__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -1,25 +1,6 @@
package dev.patrickgold.florisboard.ime.input
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class CapitalizationBehavior {
CAPSLOCK_BY_DOUBLE_TAP,
CAPSLOCK_BY_CYCLE;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = CAPSLOCK_BY_DOUBLE_TAP,
label = stringRes(R.string.enum__capitalization_behavior__capslock_by_double_tap),
)
entry(
key = CAPSLOCK_BY_CYCLE,
label = stringRes(R.string.enum__capitalization_behavior__capslock_by_cycle),
)
}
}
}

View File

@ -16,30 +16,7 @@
package dev.patrickgold.florisboard.ime.input
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class HapticVibrationMode {
USE_VIBRATOR_DIRECTLY,
USE_HAPTIC_FEEDBACK_INTERFACE;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = USE_VIBRATOR_DIRECTLY,
label = stringRes(R.string.enum__haptic_vibration_mode__use_vibrator_directly),
description = stringRes(R.string.enum__haptic_vibration_mode__use_vibrator_directly__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = USE_HAPTIC_FEEDBACK_INTERFACE,
label = stringRes(R.string.enum__haptic_vibration_mode__use_haptic_feedback_interface),
description = stringRes(R.string.enum__haptic_vibration_mode__use_haptic_feedback_interface__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -16,38 +16,7 @@
package dev.patrickgold.florisboard.ime.input
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class InputFeedbackActivationMode {
RESPECT_SYSTEM_SETTINGS,
IGNORE_SYSTEM_SETTINGS;
companion object {
@Composable
fun audioListEntries() = listPrefEntries {
entry(
key = RESPECT_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__audio_respect_system_settings),
)
entry(
key = IGNORE_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__audio_ignore_system_settings),
)
}
@Composable
fun hapticListEntries() = listPrefEntries {
entry(
key = RESPECT_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__haptic_respect_system_settings),
)
entry(
key = IGNORE_SYSTEM_SETTINGS,
label = stringRes(R.string.enum__input_feedback_activation_mode__haptic_ignore_system_settings),
)
}
}
}

View File

@ -16,37 +16,8 @@
package dev.patrickgold.florisboard.ime.keyboard
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class IncognitoMode {
FORCE_OFF,
FORCE_ON,
DYNAMIC_ON_OFF;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = FORCE_OFF,
label = stringRes(R.string.enum__incognito_mode__force_off),
description = stringRes(R.string.enum__incognito_mode__force_off__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DYNAMIC_ON_OFF,
label = stringRes(R.string.enum__incognito_mode__dynamic_on_off),
description = stringRes(R.string.enum__incognito_mode__dynamic_on_off__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = FORCE_ON,
label = stringRes(R.string.enum__incognito_mode__force_on),
description = stringRes(R.string.enum__incognito_mode__force_on__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -1,30 +1,7 @@
package dev.patrickgold.florisboard.ime.keyboard
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class SpaceBarMode {
NOTHING,
CURRENT_LANGUAGE,
SPACE_BAR_KEY;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = NOTHING,
label = stringRes(R.string.enum__space_bar_mode__nothing),
)
entry(
key = CURRENT_LANGUAGE,
label = stringRes(R.string.enum__space_bar_mode__current_language),
)
entry(
key = SPACE_BAR_KEY,
label = stringRes(R.string.enum__space_bar_mode__space_bar_key),
)
}
}
}

View File

@ -16,31 +16,8 @@
package dev.patrickgold.florisboard.ime.landscapeinput
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class LandscapeInputUiMode {
NEVER_SHOW,
ALWAYS_SHOW,
DYNAMICALLY_SHOW;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = NEVER_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__never_show),
)
entry(
key = ALWAYS_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__always_show),
)
entry(
key = DYNAMICALLY_SHOW,
label = stringRes(R.string.enum__landscape_input_ui_mode__dynamically_show),
)
}
}
}

View File

@ -16,16 +16,12 @@
package dev.patrickgold.florisboard.ime.media.emoji
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.ime.keyboard.AbstractKeyData
import dev.patrickgold.florisboard.ime.keyboard.ComputingEvaluator
import dev.patrickgold.florisboard.ime.keyboard.KeyData
import dev.patrickgold.florisboard.ime.popup.PopupSet
import dev.patrickgold.florisboard.ime.text.key.KeyCode
import dev.patrickgold.florisboard.ime.text.key.KeyType
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
import java.util.stream.IntStream
import kotlin.streams.toList
@ -36,54 +32,6 @@ enum class EmojiSkinTone(val id: Int) {
MEDIUM_SKIN_TONE(0x1F3FD),
MEDIUM_DARK_SKIN_TONE(0x1F3FE),
DARK_SKIN_TONE(0x1F3FF);
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = DEFAULT,
label = stringRes(
R.string.enum__emoji_skin_tone__default,
"emoji" to "\uD83D\uDC4B" // 👋
),
)
entry(
key = LIGHT_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__light_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFB" // 👋🏻
),
)
entry(
key = MEDIUM_LIGHT_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_light_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFC" // 👋🏼
),
)
entry(
key = MEDIUM_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFD" // 👋🏽
),
)
entry(
key = MEDIUM_DARK_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__medium_dark_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFE" // 👋🏾
),
)
entry(
key = DARK_SKIN_TONE,
label = stringRes(
R.string.enum__emoji_skin_tone__dark_skin_tone,
"emoji" to "\uD83D\uDC4B\uD83C\uDFFF" // 👋🏿
),
)
}
}
}
enum class EmojiHairStyle(val id: Int) {

View File

@ -16,29 +16,10 @@
package dev.patrickgold.florisboard.ime.nlp
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum for the spelling language modes.
*/
enum class SpellingLanguageMode {
USE_SYSTEM_LANGUAGES,
USE_KEYBOARD_SUBTYPES;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = USE_SYSTEM_LANGUAGES,
label = stringRes(R.string.enum__spelling_language_mode__use_system_languages),
)
entry(
key = USE_KEYBOARD_SUBTYPES,
label = stringRes(R.string.enum__spelling_language_mode__use_keyboard_subtypes),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.onehanded
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Static object which contains all possible one-handed mode strings.
*/
@ -28,22 +23,4 @@ enum class OneHandedMode {
OFF,
START,
END;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = OFF,
label = stringRes(R.string.enum__one_handed_mode__off),
)
entry(
key = START,
label = stringRes(R.string.enum__one_handed_mode__start),
)
entry(
key = END,
label = stringRes(R.string.enum__one_handed_mode__end),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.smartbar
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum class defining the display mode for the candidates.
*/
@ -28,22 +23,4 @@ enum class CandidatesDisplayMode {
CLASSIC,
DYNAMIC,
DYNAMIC_SCROLLABLE;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = CLASSIC,
label = stringRes(R.string.enum__candidates_display_mode__classic),
)
entry(
key = DYNAMIC,
label = stringRes(R.string.enum__candidates_display_mode__dynamic),
)
entry(
key = DYNAMIC_SCROLLABLE,
label = stringRes(R.string.enum__candidates_display_mode__dynamic_scrollable),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.smartbar
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum class defining the possible placements for the Smartbar extended actions.
*/
@ -28,28 +23,4 @@ enum class ExtendedActionsPlacement {
ABOVE_CANDIDATES,
BELOW_CANDIDATES,
OVERLAY_APP_UI;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = ABOVE_CANDIDATES,
label = stringRes(R.string.enum__extended_actions_placement__above_candidates),
description = stringRes(R.string.enum__extended_actions_placement__above_candidates__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = BELOW_CANDIDATES,
label = stringRes(R.string.enum__extended_actions_placement__below_candidates),
description = stringRes(R.string.enum__extended_actions_placement__below_candidates__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = OVERLAY_APP_UI,
label = stringRes(R.string.enum__extended_actions_placement__overlay_app_ui),
description = stringRes(R.string.enum__extended_actions_placement__overlay_app_ui__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -1,25 +1,6 @@
package dev.patrickgold.florisboard.ime.smartbar
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class IncognitoDisplayMode {
REPLACE_SHARED_ACTIONS_TOGGLE,
DISPLAY_BEHIND_KEYBOARD;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = REPLACE_SHARED_ACTIONS_TOGGLE,
label = stringRes(id = R.string.enum__incognito_display_mode__replace_shared_actions_toggle),
)
entry(
key = DISPLAY_BEHIND_KEYBOARD,
label = stringRes(id = R.string.enum__incognito_display_mode__display_behind_keyboard),
)
}
}
}

View File

@ -16,40 +16,9 @@
package dev.patrickgold.florisboard.ime.smartbar
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
enum class SmartbarLayout {
SUGGESTIONS_ONLY,
ACTIONS_ONLY,
SUGGESTIONS_ACTIONS_SHARED,
SUGGESTIONS_ACTIONS_EXTENDED;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = SUGGESTIONS_ONLY,
label = stringRes(R.string.enum__smartbar_layout__suggestions_only),
description = stringRes(R.string.enum__smartbar_layout__suggestions_only__description),
)
entry(
key = ACTIONS_ONLY,
label = stringRes(R.string.enum__smartbar_layout__actions_only),
description = stringRes(R.string.enum__smartbar_layout__actions_only__description),
)
entry(
key = SUGGESTIONS_ACTIONS_SHARED,
label = stringRes(R.string.enum__smartbar_layout__suggestions_action_shared),
description = stringRes(R.string.enum__smartbar_layout__suggestions_action_shared__description),
)
entry(
key = SUGGESTIONS_ACTIONS_EXTENDED,
label = stringRes(R.string.enum__smartbar_layout__suggestions_actions_extended),
description = stringRes(R.string.enum__smartbar_layout__suggestions_actions_extended__description),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.text.gestures
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum for declaring the possible actions for swipe gestures.
*/
@ -53,142 +48,4 @@ enum class SwipeAction {
SWITCH_TO_PREV_KEYBOARD,
TOGGLE_SMARTBAR_VISIBILITY,
UNDO;
companion object {
@Composable
fun generalListEntries() = listPrefEntries {
entry(
key = NO_ACTION,
label = stringRes(R.string.enum__swipe_action__no_action),
)
entry(
key = CYCLE_TO_PREVIOUS_KEYBOARD_MODE,
label = stringRes(R.string.enum__swipe_action__cycle_to_previous_keyboard_mode),
)
entry(
key = CYCLE_TO_NEXT_KEYBOARD_MODE,
label = stringRes(R.string.enum__swipe_action__cycle_to_next_keyboard_mode),
)
entry(
key = DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
entry(
key = HIDE_KEYBOARD,
label = stringRes(R.string.enum__swipe_action__hide_keyboard),
)
entry(
key = INSERT_SPACE,
label = stringRes(R.string.enum__swipe_action__insert_space),
)
entry(
key = MOVE_CURSOR_UP,
label = stringRes(R.string.enum__swipe_action__move_cursor_up),
)
entry(
key = MOVE_CURSOR_DOWN,
label = stringRes(R.string.enum__swipe_action__move_cursor_down),
)
entry(
key = MOVE_CURSOR_LEFT,
label = stringRes(R.string.enum__swipe_action__move_cursor_left),
)
entry(
key = MOVE_CURSOR_RIGHT,
label = stringRes(R.string.enum__swipe_action__move_cursor_right),
)
entry(
key = MOVE_CURSOR_START_OF_LINE,
label = stringRes(R.string.enum__swipe_action__move_cursor_start_of_line),
)
entry(
key = MOVE_CURSOR_END_OF_LINE,
label = stringRes(R.string.enum__swipe_action__move_cursor_end_of_line),
)
entry(
key = MOVE_CURSOR_START_OF_PAGE,
label = stringRes(R.string.enum__swipe_action__move_cursor_start_of_page),
)
entry(
key = MOVE_CURSOR_END_OF_PAGE,
label = stringRes(R.string.enum__swipe_action__move_cursor_end_of_page),
)
entry(
key = SHIFT,
label = stringRes(R.string.enum__swipe_action__shift),
)
entry(
key = REDO,
label = stringRes(R.string.enum__swipe_action__redo),
)
entry(
key = UNDO,
label = stringRes(R.string.enum__swipe_action__undo),
)
entry(
key = SWITCH_TO_CLIPBOARD_CONTEXT,
label = stringRes(R.string.enum__swipe_action__switch_to_clipboard_context),
)
entry(
key = SHOW_INPUT_METHOD_PICKER,
label = stringRes(R.string.enum__swipe_action__show_input_method_picker),
)
entry(
key = SWITCH_TO_PREV_SUBTYPE,
label = stringRes(R.string.enum__swipe_action__switch_to_prev_subtype),
)
entry(
key = SWITCH_TO_NEXT_SUBTYPE,
label = stringRes(R.string.enum__swipe_action__switch_to_next_subtype),
)
entry(
key = SWITCH_TO_PREV_KEYBOARD,
label = stringRes(R.string.enum__swipe_action__switch_to_prev_keyboard),
)
entry(
key = TOGGLE_SMARTBAR_VISIBILITY,
label = stringRes(R.string.enum__swipe_action__toggle_smartbar_visibility),
)
}
@Composable
fun deleteSwipeListEntries() = listPrefEntries {
entry(
key = NO_ACTION,
label = stringRes(R.string.enum__swipe_action__no_action),
)
entry(
key = DELETE_CHARACTERS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__delete_characters_precisely),
)
entry(
key = DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
entry(
key = DELETE_WORDS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__delete_words_precisely),
)
entry(
key = SELECT_CHARACTERS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__select_characters_precisely),
)
entry(
key = SELECT_WORDS_PRECISELY,
label = stringRes(R.string.enum__swipe_action__select_words_precisely),
)
}
@Composable
fun deleteLongPressListEntries() = listPrefEntries {
entry(
key = DELETE_CHARACTER,
label = stringRes(R.string.enum__swipe_action__delete_character),
)
entry(
key = DELETE_WORD,
label = stringRes(R.string.enum__swipe_action__delete_word),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.text.key
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum for the key hint modes.
*/
@ -29,28 +24,4 @@ enum class KeyHintMode {
HINT_PRIORITY,
ACCENT_PRIORITY,
SMART_PRIORITY;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = ACCENT_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__accent_priority),
description = stringRes(R.string.enum__key_hint_mode__accent_priority__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = HINT_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__hint_priority),
description = stringRes(R.string.enum__key_hint_mode__hint_priority__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = SMART_PRIORITY,
label = stringRes(R.string.enum__key_hint_mode__smart_priority),
description = stringRes(R.string.enum__key_hint_mode__smart_priority__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.text.key
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum for declaring the utility key actions.
*/
@ -30,26 +25,4 @@ enum class UtilityKeyAction {
SWITCH_KEYBOARD_APP,
DYNAMIC_SWITCH_LANGUAGE_EMOJIS,
DISABLED;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = SWITCH_TO_EMOJIS,
label = stringRes(R.string.enum__utility_key_action__switch_to_emojis),
)
entry(
key = SWITCH_LANGUAGE,
label = stringRes(R.string.enum__utility_key_action__switch_language),
)
entry(
key = SWITCH_KEYBOARD_APP,
label = stringRes(R.string.enum__utility_key_action__switch_keyboard_app),
)
entry(
key = DYNAMIC_SWITCH_LANGUAGE_EMOJIS,
label = stringRes(R.string.enum__utility_key_action__dynamic_switch_language_emojis),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.ime.theme
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* Enum class which specifies all theme modes available. Used in the Settings
* to properly manage different use cases when the day or night theme should
@ -31,26 +26,4 @@ enum class ThemeMode {
ALWAYS_NIGHT,
FOLLOW_SYSTEM,
FOLLOW_TIME;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = ALWAYS_DAY,
label = stringRes(R.string.enum__theme_mode__always_day),
)
entry(
key = ALWAYS_NIGHT,
label = stringRes(R.string.enum__theme_mode__always_night),
)
entry(
key = FOLLOW_SYSTEM,
label = stringRes(R.string.enum__theme_mode__follow_system),
)
entry(
key = FOLLOW_TIME,
label = stringRes(R.string.enum__theme_mode__follow_time),
)
}
}
}

View File

@ -16,11 +16,6 @@
package dev.patrickgold.florisboard.lib.snygg
import androidx.compose.runtime.Composable
import dev.patrickgold.florisboard.R
import dev.patrickgold.florisboard.lib.compose.stringRes
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
/**
* SnyggLevel indicates if a rule property is intended to be edited by all users (BASIC) or only by advanced users
* (ADVANCED). This level is intended for theme editor UIs to hide certain properties in a "basic" mode, for the Snygg
@ -33,28 +28,4 @@ enum class SnyggLevel : Comparable<SnyggLevel> {
ADVANCED,
/** A property is intended to be edited by developers **/
DEVELOPER;
companion object {
@Composable
fun listEntries() = listPrefEntries {
entry(
key = BASIC,
label = stringRes(R.string.enum__snygg_level__basic),
description = stringRes(R.string.enum__snygg_level__basic__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = ADVANCED,
label = stringRes(R.string.enum__snygg_level__advanced),
description = stringRes(R.string.enum__snygg_level__advanced__description),
showDescriptionOnlyIfSelected = true,
)
entry(
key = DEVELOPER,
label = stringRes(R.string.enum__snygg_level__developer),
description = stringRes(R.string.enum__snygg_level__developer__description),
showDescriptionOnlyIfSelected = true,
)
}
}
}

View File

@ -817,6 +817,9 @@
<string name="enum__key_hint_mode__smart_priority" comment="Enum value label">Smart prioritization</string>
<string name="enum__key_hint_mode__smart_priority__description" comment="Enum value description">The initial character selected after long press is dynamically decided to be either the primary accent or the hint symbol, based on the current language and layout</string>
<string name="enum__incognito_display_mode__replace_shared_actions_toggle" comment="Enum value label">Replace shared actions toggle icon with the incognito indicator</string>
<string name="enum__incognito_display_mode__display_behind_keyboard" comment="Enum value label">Display the incognito indicator behind the keyboard</string>
<string name="enum__incognito_mode__force_off" comment="Enum value label">Force off</string>
<string name="enum__incognito_mode__force_off__description" comment="Enum value description">Incognito mode will always be disabled, regardless of the target app\'s passed options. The incognito quick action in the Smartbar will not be available with this option.</string>
<string name="enum__incognito_mode__force_on" comment="Enum value label">Force on</string>
@ -824,9 +827,6 @@
<string name="enum__incognito_mode__dynamic_on_off" comment="Enum value label">Dynamically on/off</string>
<string name="enum__incognito_mode__dynamic_on_off__description" comment="Enum value description">Recommended option. Incognito mode will be dynamically enabled or disabled either through the target app\'s passed options or by manually toggling it through the incognito quick action in the Smartbar.</string>
<string name="enum__incognito_display_mode__replace_shared_actions_toggle" comment="Enum value label">Replace shared actions toggle icon with the incognito indicator</string>
<string name="enum__incognito_display_mode__display_behind_keyboard" comment="Enum value label">Display the incognito indicator behind the keyboard</string>
<string name="enum__input_feedback_activation_mode__audio_respect_system_settings" comment="Enum value label">Dynamically play sounds for input events, depending on system settings</string>
<string name="enum__input_feedback_activation_mode__audio_ignore_system_settings" comment="Enum value label">Always play sounds for input events, regardless of system settings</string>
<string name="enum__input_feedback_activation_mode__haptic_respect_system_settings" comment="Enum value label">Dynamically vibrate for input events, depending on system settings</string>