Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class FixKeyEventActionDelegateImpl @Inject constructor(
preferenceRepository.get(Keys.keyEventActionsUseSystemBridge)
.map { it ?: PreferenceDefaults.KEY_EVENT_ACTIONS_USE_SYSTEM_BRIDGE }

override val isAutoSwitchImeEnabled: Flow<Boolean> =
preferenceRepository.get(Keys.changeImeOnInputFocus)
.map { it ?: PreferenceDefaults.CHANGE_IME_ON_INPUT_FOCUS }

private val showBottomSheet: MutableStateFlow<Boolean> = MutableStateFlow(false)

@OptIn(ExperimentalCoroutinesApi::class)
Expand Down Expand Up @@ -166,6 +170,7 @@ class FixKeyEventActionDelegateImpl @Inject constructor(

interface FixKeyEventActionDelegate {
val fixKeyEventActionState: StateFlow<FixKeyEventActionState?>
val isAutoSwitchImeEnabled: Flow<Boolean>

fun showFixKeyEventActionBottomSheet()
fun dismissFixKeyEventActionBottomSheet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,27 @@ class KeyMapListViewModel(
}

fun showInputMethodPicker() {
showInputMethodPickerUseCase.show(fromForeground = true)
coroutineScope.launch {
val autoSwitchEnabled = isAutoSwitchImeEnabled.first()

if (autoSwitchEnabled) {
val response = showDialog(
"disable_auto_switch_ime_dialog",
DialogModel.Alert(
title = getString(R.string.dialog_title_disable_auto_switch_ime),
message = getString(R.string.dialog_message_disable_auto_switch_ime),
positiveButtonText = getString(R.string.pos_ok),
negativeButtonText = getString(R.string.neg_cancel),
),
)

if (response != DialogResponse.POSITIVE) return@launch

onAutoSwitchImeCheckedChange(false)
}

showInputMethodPickerUseCase.show(fromForeground = true)
}
}

private suspend fun onAutomaticBackupResult(result: KMResult<*>) {
Expand Down
3 changes: 3 additions & 0 deletions base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1901,4 +1901,7 @@
<string name="dialog_bug_report_discord_button">Open Discord</string>
<string name="dialog_bug_report_email_button">Email us</string>

<string name="dialog_title_disable_auto_switch_ime">Disable auto-switch keyboard?</string>
<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>

</resources>
Loading