Keep screen awake during voice input

This commit is contained in:
Aleksandras Kostarevas 2024-03-21 19:34:35 -05:00
parent 601d6df6b3
commit 20f897aa56
3 changed files with 9 additions and 0 deletions

View File

@ -64,6 +64,7 @@ data class Action(
@DrawableRes val icon: Int,
@StringRes val name: Int,
val canShowKeyboard: Boolean = false,
val keepScreenAwake: Boolean = false,
val windowImpl: ((KeyboardManagerForAction, PersistentActionState?) -> ActionWindow)?,
val simplePressImpl: ((KeyboardManagerForAction, PersistentActionState?) -> Unit)?,

View File

@ -7,6 +7,7 @@ import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InlineSuggestionsResponse
import androidx.annotation.RequiresApi
import androidx.compose.animation.AnimatedVisibility
@ -230,6 +231,10 @@ class UixManager(private val latinIME: LatinIME) {
currWindowActionWindow = action.windowImpl?.let { it(keyboardManagerForAction, persistentStates[action]) }
if(action.keepScreenAwake) {
latinIME.window.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
setContent()
}
@ -245,6 +250,8 @@ class UixManager(private val latinIME: LatinIME) {
latinIME.onKeyboardShown()
latinIME.window.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
setContent()
}

View File

@ -244,6 +244,7 @@ private class VoiceInputActionWindow(
val VoiceInputAction = Action(icon = R.drawable.mic_fill,
name = R.string.voice_input_action_title,
simplePressImpl = null,
keepScreenAwake = true,
persistentState = { VoiceInputPersistentState(it) },
windowImpl = { manager, persistentState ->
VoiceInputActionWindow(