mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
Update release workflow
Automatically show keyboard in AppLockDialog
This commit is contained in:
@@ -25,10 +25,13 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
@@ -44,6 +47,7 @@ import androidx.compose.ui.window.DialogProperties
|
||||
fun AppLockDialog(onSucceed: () -> Unit, onDismiss: () -> Unit) = Dialog(onDismiss, DialogProperties(true, false)) {
|
||||
val context = LocalContext.current
|
||||
val fm = LocalFocusManager.current
|
||||
val fr = remember { FocusRequester() }
|
||||
var input by rememberSaveable { mutableStateOf("") }
|
||||
var isError by rememberSaveable { mutableStateOf(false) }
|
||||
fun unlock() {
|
||||
@@ -55,14 +59,18 @@ fun AppLockDialog(onSucceed: () -> Unit, onDismiss: () -> Unit) = Dialog(onDismi
|
||||
}
|
||||
}
|
||||
LaunchedEffect(Unit) {
|
||||
if (Build.VERSION.SDK_INT >= 28 && SP.biometricsUnlock) startBiometricsUnlock(context, onSucceed)
|
||||
if (Build.VERSION.SDK_INT >= 28 && SP.biometricsUnlock) {
|
||||
startBiometricsUnlock(context, onSucceed)
|
||||
} else {
|
||||
fr.requestFocus()
|
||||
}
|
||||
}
|
||||
BackHandler(onBack = onDismiss)
|
||||
Card(Modifier.pointerInput(Unit) { detectTapGestures(onTap = { fm.clearFocus() }) }, shape = RoundedCornerShape(16.dp)) {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
OutlinedTextField(
|
||||
input, { input = it; isError = false }, Modifier.width(200.dp),
|
||||
input, { input = it; isError = false }, Modifier.width(200.dp).focusRequester(fr),
|
||||
label = { Text(stringResource(R.string.password)) }, isError = isError,
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Password, imeAction = if(input.length >= 4) ImeAction.Go else ImeAction.Done
|
||||
|
||||
Reference in New Issue
Block a user