File tree Expand file tree Collapse file tree
base/src/main/java/io/github/sds100/keymapper/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,10 +63,6 @@ class FixKeyEventActionDelegateImpl @Inject constructor(
6363 preferenceRepository.get(Keys .keyEventActionsUseSystemBridge)
6464 .map { it ? : PreferenceDefaults .KEY_EVENT_ACTIONS_USE_SYSTEM_BRIDGE }
6565
66- override val isAutoSwitchImeEnabled: Flow <Boolean > =
67- preferenceRepository.get(Keys .changeImeOnInputFocus)
68- .map { it ? : PreferenceDefaults .CHANGE_IME_ON_INPUT_FOCUS }
69-
7066 private val showBottomSheet: MutableStateFlow <Boolean > = MutableStateFlow (false )
7167
7268 @OptIn(ExperimentalCoroutinesApi ::class )
@@ -170,7 +166,6 @@ class FixKeyEventActionDelegateImpl @Inject constructor(
170166
171167interface FixKeyEventActionDelegate {
172168 val fixKeyEventActionState: StateFlow <FixKeyEventActionState ?>
173- val isAutoSwitchImeEnabled: Flow <Boolean >
174169
175170 fun showFixKeyEventActionBottomSheet ()
176171 fun dismissFixKeyEventActionBottomSheet ()
Original file line number Diff line number Diff line change @@ -908,7 +908,7 @@ class KeyMapListViewModel(
908908
909909 fun showInputMethodPicker () {
910910 coroutineScope.launch {
911- val autoSwitchEnabled = isAutoSwitchImeEnabled.first()
911+ val autoSwitchEnabled = showInputMethodPickerUseCase. isAutoSwitchImeEnabled.first()
912912
913913 if (autoSwitchEnabled) {
914914 val response = showDialog(
@@ -923,7 +923,7 @@ class KeyMapListViewModel(
923923
924924 if (response != DialogResponse .POSITIVE ) return @launch
925925
926- onAutoSwitchImeCheckedChange( false )
926+ showInputMethodPickerUseCase.disableAutoSwitch( )
927927 }
928928
929929 showInputMethodPickerUseCase.show(fromForeground = true )
Original file line number Diff line number Diff line change 11package io.github.sds100.keymapper.base.system.inputmethod
22
3+ import io.github.sds100.keymapper.data.Keys
4+ import io.github.sds100.keymapper.data.PreferenceDefaults
5+ import io.github.sds100.keymapper.data.repositories.PreferenceRepository
36import io.github.sds100.keymapper.system.inputmethod.InputMethodAdapter
47import javax.inject.Inject
8+ import kotlinx.coroutines.flow.Flow
9+ import kotlinx.coroutines.flow.map
510
611class ShowInputMethodPickerUseCaseImpl @Inject constructor(
712 private val inputMethodAdapter : InputMethodAdapter ,
13+ private val preferenceRepository : PreferenceRepository ,
814) : ShowInputMethodPickerUseCase {
15+ override val isAutoSwitchImeEnabled: Flow <Boolean > =
16+ preferenceRepository.get(Keys .changeImeOnInputFocus)
17+ .map { it ? : PreferenceDefaults .CHANGE_IME_ON_INPUT_FOCUS }
18+
19+ override fun disableAutoSwitch () {
20+ preferenceRepository.set(Keys .changeImeOnInputFocus, false )
21+ }
22+
923 override fun show (fromForeground : Boolean ) {
1024 inputMethodAdapter.showImePicker(fromForeground = fromForeground)
1125 }
1226}
1327
1428interface ShowInputMethodPickerUseCase {
29+ val isAutoSwitchImeEnabled: Flow <Boolean >
30+
31+ fun disableAutoSwitch ()
1532 fun show (fromForeground : Boolean )
1633}
You can’t perform that action at this time.
0 commit comments