Announce when entering/exiting action window

This commit is contained in:
Aleksandras Kostarevas 2024-05-28 16:08:14 +03:00
parent 70f2f371de
commit 216e19f629
3 changed files with 16 additions and 0 deletions

View File

@ -39,6 +39,7 @@ interface KeyboardManagerForAction {
fun cursorRight(steps: Int, stepOverWords: Boolean, select: Boolean)
fun performHapticAndAudioFeedback(code: Int, view: View)
fun announce(s: String)
fun getActiveLocale(): Locale
}

View File

@ -44,6 +44,7 @@ import androidx.lifecycle.LifecycleCoroutineScope
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.futo.inputmethod.accessibility.AccessibilityUtils
import org.futo.inputmethod.latin.AudioAndHapticFeedbackManager
import org.futo.inputmethod.latin.BuildConfig
import org.futo.inputmethod.latin.LanguageSwitcherDialog
@ -183,6 +184,13 @@ class UixActionKeyboardManager(val uixManager: UixManager, val latinIME: LatinIM
override fun getActiveLocale(): Locale {
return latinIME.latinIMELegacy.locale
}
override fun announce(s: String) {
AccessibilityUtils.init(getContext())
if(AccessibilityUtils.getInstance().isAccessibilityEnabled) {
AccessibilityUtils.getInstance().announceForAccessibility(uixManager.getComposeView(), s)
}
}
}
class UixManager(private val latinIME: LatinIME) {
@ -261,11 +269,15 @@ class UixManager(private val latinIME: LatinIME) {
}
setContent()
keyboardManagerForAction.announce("${latinIME.resources.getString(action.name)} mode")
}
fun returnBackToMainKeyboardViewFromAction() {
if(currWindowActionWindow == null) return
val name = latinIME.resources.getString(currWindowAction!!.name)
currWindowActionWindow!!.close()
currWindowAction = null
@ -278,6 +290,8 @@ class UixManager(private val latinIME: LatinIME) {
latinIME.window.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
setContent()
keyboardManagerForAction.announce("$name closed")
}
private fun toggleExpandAction() {

View File

@ -208,6 +208,7 @@ private class VoiceInputActionWindow(
wasFinished = true
inputTransaction.commit(result)
manager.announce(result)
manager.closeActionWindow()
}