mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Improve TalkBack support for settings/setup
This commit is contained in:
parent
2c4859598e
commit
b72bc9c385
@ -73,7 +73,9 @@ fun ScreenTitle(title: String, showBack: Boolean = false, navController: NavHost
|
|||||||
val rowModifier = if(showBack) {
|
val rowModifier = if(showBack) {
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable { navController.navigateUp() }
|
.clickable(onClickLabel = "Navigate back") {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Modifier.fillMaxWidth()
|
Modifier.fillMaxWidth()
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,31 @@ import android.provider.Settings
|
|||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.runtime.Composable
|
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
|
import org.futo.inputmethod.latin.utils.UncachedInputMethodManagerUtils
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SetupOrMain(inputMethodEnabled: Boolean, inputMethodSelected: Boolean, micPermissionGrantedOrUsingSystem: Boolean, doublePackage: Boolean, main: @Composable () -> Unit) {
|
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) {
|
if (!inputMethodEnabled) {
|
||||||
SetupEnableIME()
|
SetupEnableIME()
|
||||||
} else if (!inputMethodSelected) {
|
} else if (!inputMethodSelected) {
|
||||||
|
@ -29,6 +29,9 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
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.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -46,7 +49,7 @@ fun SetupContainer(inner: @Composable () -> Unit) {
|
|||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||||
contentDescription = "FUTO Logo",
|
contentDescription = null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
.align(Alignment.Center),
|
.align(Alignment.Center),
|
||||||
@ -77,7 +80,12 @@ fun SetupContainer(inner: @Composable () -> Unit) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Step(fraction: Float, text: String) {
|
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)
|
Text(text, style = Typography.labelSmall)
|
||||||
LinearProgressIndicator(progress = fraction, modifier = Modifier.fillMaxWidth())
|
LinearProgressIndicator(progress = fraction, modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user