File tree Expand file tree Collapse file tree
java/io/github/sds100/keymapper/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -907,7 +907,27 @@ class KeyMapListViewModel(
907907 }
908908
909909 fun showInputMethodPicker () {
910- showInputMethodPickerUseCase.show(fromForeground = true )
910+ coroutineScope.launch {
911+ val autoSwitchEnabled = showInputMethodPickerUseCase.isAutoSwitchImeEnabled.first()
912+
913+ if (autoSwitchEnabled) {
914+ val response = showDialog(
915+ " disable_auto_switch_ime_dialog" ,
916+ DialogModel .Alert (
917+ title = getString(R .string.dialog_title_disable_auto_switch_ime),
918+ message = getString(R .string.dialog_message_disable_auto_switch_ime),
919+ positiveButtonText = getString(R .string.pos_ok),
920+ negativeButtonText = getString(R .string.neg_cancel),
921+ ),
922+ )
923+
924+ if (response != DialogResponse .POSITIVE ) return @launch
925+
926+ showInputMethodPickerUseCase.disableAutoSwitch()
927+ }
928+
929+ showInputMethodPickerUseCase.show(fromForeground = true )
930+ }
911931 }
912932
913933 private suspend fun onAutomaticBackupResult (result : KMResult <* >) {
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}
Original file line number Diff line number Diff line change 19011901 <string name =" dialog_bug_report_discord_button" >Open Discord</string >
19021902 <string name =" dialog_bug_report_email_button" >Email us</string >
19031903
1904+ <string name =" dialog_title_disable_auto_switch_ime" >Disable auto-switch keyboard?</string >
1905+ <string name =" dialog_message_disable_auto_switch_ime" >Choosing a keyboard here will disable the automatic keyboard switching feature. You can re-enable it in Settings.</string >
1906+
19041907</resources >
You can’t perform that action at this time.
0 commit comments