diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/Components.kt b/java/src/org/futo/inputmethod/latin/uix/settings/Components.kt index 3e9dab9cd..5f898b82c 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/Components.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/Components.kt @@ -392,7 +392,7 @@ fun SettingSlider( ) { SettingSliderForDataStoreItem( title = title, - item = useDataStore(setting), + item = useDataStore(setting, blocking = true), default = setting.default, range = range, transform = transform, diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/Hooks.kt b/java/src/org/futo/inputmethod/latin/uix/settings/Hooks.kt index 3240c83f9..498a8a5e6 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/Hooks.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/Hooks.kt @@ -51,17 +51,27 @@ fun useDataStoreValueBlocking(v: SettingsKey): T { } @Composable -fun useDataStore(key: Preferences.Key, default: T): DataStoreItem { +fun useDataStore(key: Preferences.Key, default: T, blocking: Boolean = false): DataStoreItem { val context = LocalContext.current val coroutineScope = rememberCoroutineScope() - val enableSoundFlow: Flow = remember { - context.dataStore.data.map { - preferences -> preferences[key] ?: default + val initialValue = remember { + if(blocking) { + runBlocking { + context.getSetting(key, default) + } + } else { + default } } - val value = enableSoundFlow.collectAsState(initial = default).value!! + val valueFlow: Flow = remember { + context.dataStore.data.map { preferences -> + preferences[key] ?: default + } + } + + val value = valueFlow.collectAsState(initial = initialValue).value!! val setValue = { newValue: T -> coroutineScope.launch { @@ -76,8 +86,8 @@ fun useDataStore(key: Preferences.Key, default: T): DataStoreItem { @Composable -fun useDataStore(key: SettingsKey): DataStoreItem { - return useDataStore(key.key, key.default) +fun useDataStore(key: SettingsKey, blocking: Boolean = false): DataStoreItem { + return useDataStore(key.key, key.default, blocking) } @Composable diff --git a/java/src/org/futo/inputmethod/latin/uix/theme/selector/ThemePicker.kt b/java/src/org/futo/inputmethod/latin/uix/theme/selector/ThemePicker.kt index 6d78776c9..e3e97442e 100644 --- a/java/src/org/futo/inputmethod/latin/uix/theme/selector/ThemePicker.kt +++ b/java/src/org/futo/inputmethod/latin/uix/theme/selector/ThemePicker.kt @@ -227,15 +227,19 @@ fun ThemePicker(onSelected: (ThemeOption) -> Unit) { title = "Keyboard Height", setting = KeyboardHeightMultiplierSetting, range = 0.33f .. 1.75f, transform = { it }, - indicator = { "${(it * 100.0f).roundToInt()}%" } + indicator = { "${(it * 100.0f).roundToInt()}%" }, + steps = 16 ) } item(span = { GridItemSpan(maxCurrentLineSpan) }) { SettingSlider( title = "Keyboard Offset", setting = KeyboardBottomOffsetSetting, - range = 0.0f .. 128.0f, transform = { it }, - indicator = { "${String.format("%.1f", it)} dp" } + range = 0.0f .. 50.0f, + hardRange = 0.0f .. 250.0f, + transform = { it }, + indicator = { "${String.format("%.1f", it)} dp" }, + steps = 9 ) } }