feat(#2060): Enforce valid names for UserConfig (#2063)

pull/2054/head
James Rich 2025-06-09 17:46:22 +00:00 zatwierdzone przez GitHub
rodzic f5b34d6408
commit 4767e48fe2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -69,7 +69,6 @@ fun PreferenceFooter(
modifier = modifier
.height(48.dp)
.weight(1f),
enabled = enabled,
onClick = onNegativeClicked,
) {
Text(

Wyświetl plik

@ -82,6 +82,9 @@ fun UserConfigItemList(
var userInput by rememberSaveable { mutableStateOf(userConfig) }
val firmwareVersion = DeviceVersion(metadata?.firmwareVersion ?: "")
val validLongName = userInput.longName.isNotBlank()
val validShortName = userInput.shortName.isNotBlank()
val validNames = validLongName && validShortName
LazyColumn(
modifier = Modifier.fillMaxSize()
) {
@ -102,7 +105,7 @@ fun UserConfigItemList(
value = userInput.longName,
maxSize = 39, // long_name max_size:40
enabled = enabled,
isError = userInput.longName.isEmpty(),
isError = !validLongName,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Text, imeAction = ImeAction.Done
),
@ -119,7 +122,7 @@ fun UserConfigItemList(
value = userInput.shortName,
maxSize = 4, // short_name max_size:5
enabled = enabled,
isError = userInput.shortName.isEmpty(),
isError = !validShortName,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Text, imeAction = ImeAction.Done
),
@ -165,7 +168,7 @@ fun UserConfigItemList(
item {
PreferenceFooter(
enabled = enabled && userInput != userConfig,
enabled = enabled && userInput != userConfig && validNames,
onCancelClicked = {
focusManager.clearFocus()
userInput = userConfig