Skip to content

Commit a739d60

Browse files
committed
Update voice input settings loading to occur synchronously
1 parent 93bde30 commit a739d60

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

java/src/org/futo/inputmethod/latin/uix/Settings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class DataStoreHelper {
194194
}
195195

196196

197-
suspend fun <T> Context.getSetting(key: Preferences.Key<T>, default: T): T {
197+
fun <T> Context.getSetting(key: Preferences.Key<T>, default: T): T {
198198
/*val valueFlow: Flow<T> =
199199
this.dataStore.data.map { preferences -> preferences[key] ?: default }.take(1)
200200
@@ -263,7 +263,7 @@ data class SettingsKey<T>(
263263
val default: T
264264
)
265265

266-
suspend fun <T> Context.getSetting(key: SettingsKey<T>): T {
266+
fun <T> Context.getSetting(key: SettingsKey<T>): T {
267267
return getSetting(key.key, key.default)
268268
}
269269

java/src/org/futo/inputmethod/latin/uix/actions/VoiceInputAction.kt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,38 +101,38 @@ private class VoiceInputActionWindow(
101101
val context = manager.getContext()
102102

103103
private var shouldPlaySounds: Boolean = false
104-
private suspend fun loadSettings(): RecognizerViewSettings = coroutineScope {
105-
val enableSound = async { context.getSetting(ENABLE_SOUND) }
106-
val verboseFeedback = async { context.getSetting(VERBOSE_PROGRESS) }
107-
val disallowSymbols = async { context.getSetting(DISALLOW_SYMBOLS) }
108-
val useBluetoothAudio = async { context.getSetting(PREFER_BLUETOOTH) }
109-
val requestAudioFocus = async { context.getSetting(AUDIO_FOCUS) }
110-
val canExpandSpace = async { context.getSetting(CAN_EXPAND_SPACE) }
104+
private fun loadSettings(): RecognizerViewSettings {
105+
val enableSound = context.getSetting(ENABLE_SOUND)
106+
val verboseFeedback = context.getSetting(VERBOSE_PROGRESS)
107+
val disallowSymbols = context.getSetting(DISALLOW_SYMBOLS)
108+
val useBluetoothAudio = context.getSetting(PREFER_BLUETOOTH)
109+
val requestAudioFocus = context.getSetting(AUDIO_FOCUS)
110+
val canExpandSpace = context.getSetting(CAN_EXPAND_SPACE)
111111

112112
val primaryModel = model
113113
val languageSpecificModels = mutableMapOf<Language, ModelLoader>()
114114
val allowedLanguages = listOf(
115115
getLanguageFromWhisperString(locale.language)
116116
).filterNotNull().toSet()
117117

118-
shouldPlaySounds = enableSound.await()
118+
shouldPlaySounds = enableSound
119119

120-
return@coroutineScope RecognizerViewSettings(
120+
return RecognizerViewSettings(
121121
shouldShowInlinePartialResult = false,
122-
shouldShowVerboseFeedback = verboseFeedback.await(),
122+
shouldShowVerboseFeedback = verboseFeedback,
123123
modelRunConfiguration = MultiModelRunConfiguration(
124124
primaryModel = primaryModel,
125125
languageSpecificModels = languageSpecificModels
126126
),
127127
decodingConfiguration = DecodingConfiguration(
128128
glossary = state.userDictionaryObserver.getWords().map { it.word },
129129
languages = allowedLanguages,
130-
suppressSymbols = disallowSymbols.await()
130+
suppressSymbols = disallowSymbols
131131
),
132132
recordingConfiguration = RecordingSettings(
133-
preferBluetoothMic = useBluetoothAudio.await(),
134-
requestAudioFocus = requestAudioFocus.await(),
135-
canExpandSpace = canExpandSpace.await()
133+
preferBluetoothMic = useBluetoothAudio,
134+
requestAudioFocus = requestAudioFocus,
135+
canExpandSpace = canExpandSpace
136136
)
137137
)
138138
}
@@ -142,9 +142,7 @@ private class VoiceInputActionWindow(
142142

143143
private val initJob = manager.getLifecycleScope().launch {
144144
yield()
145-
val settings = withContext(Dispatchers.IO) {
146-
loadSettings()
147-
}
145+
val settings = loadSettings()
148146

149147
yield()
150148
val recognizerView = try {

0 commit comments

Comments
 (0)