Improve TalkBack support for settings/setup

This commit is contained in:
Aleksandras Kostarevas 2024-05-28 13:46:46 +03:00
parent 2c4859598e
commit b72bc9c385
3 changed files with 34 additions and 3 deletions

View File

@ -73,7 +73,9 @@ fun ScreenTitle(title: String, showBack: Boolean = false, navController: NavHost
val rowModifier = if(showBack) {
Modifier
.fillMaxWidth()
.clickable { navController.navigateUp() }
.clickable(onClickLabel = "Navigate back") {
navController.navigateUp()
}
} else {
Modifier.fillMaxWidth()
}

View File

@ -6,10 +6,31 @@ import android.provider.Settings
import android.view.inputmethod.InputMethodManager
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import org.futo.inputmethod.accessibility.AccessibilityUtils
import org.futo.inputmethod.latin.utils.UncachedInputMethodManagerUtils
@Composable
fun SetupOrMain(inputMethodEnabled: Boolean, inputMethodSelected: Boolean, micPermissionGrantedOrUsingSystem: Boolean, doublePackage: Boolean, main: @Composable () -> Unit) {
val wasSetupActive = remember { mutableStateOf(false) }
val view = LocalView.current
val context = LocalContext.current
LaunchedEffect(inputMethodSelected, inputMethodEnabled, micPermissionGrantedOrUsingSystem) {
wasSetupActive.value = wasSetupActive.value || !inputMethodEnabled || !inputMethodSelected || !micPermissionGrantedOrUsingSystem
if(inputMethodSelected && inputMethodEnabled && micPermissionGrantedOrUsingSystem && wasSetupActive.value) {
AccessibilityUtils.init(context)
if(AccessibilityUtils.getInstance().isAccessibilityEnabled) {
AccessibilityUtils.getInstance()
.announceForAccessibility(view, "FUTO Keyboard has been activated")
}
}
}
if (!inputMethodEnabled) {
SetupEnableIME()
} else if (!inputMethodSelected) {

View File

@ -29,6 +29,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.text
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@ -46,7 +49,7 @@ fun SetupContainer(inner: @Composable () -> Unit) {
) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = "FUTO Logo",
contentDescription = null,
modifier = Modifier
.matchParentSize()
.align(Alignment.Center),
@ -77,7 +80,12 @@ fun SetupContainer(inner: @Composable () -> Unit) {
@Composable
fun Step(fraction: Float, text: String) {
Column(modifier = Modifier.padding(16.dp)) {
Column(modifier = Modifier
.padding(16.dp)
.clearAndSetSemantics {
this.text = AnnotatedString(text)
}
) {
Text(text, style = Typography.labelSmall)
LinearProgressIndicator(progress = fraction, modifier = Modifier.fillMaxWidth())
}