kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat: expand role confirmation to include REPEATER (#1657)
* Clarify role change behavior The role change logic was modified to show a confirmation dialog when the role is set to `ROUTER`, `ROUTER_CLIENT`, or `REPEATER`. Previously, the dialog was only displayed when setting the role to `ROUTER`. * Implement router role confirmation dialog - Added a confirmation dialog when changing the device role to ROUTER, ROUTER_CLIENT, or REPEATER. - The confirmation dialog ensures users are aware of the implications of selecting a role used for infrastructure. - Updated the logic to set the selected role only after confirmation. - Only show dialog when changing to infrastructure roles. * remove deprecated ROUTER_CLIENT to avoid confusionpull/1653/head^2
rodzic
d40672df40
commit
6dfb6a56d6
|
@ -17,9 +17,11 @@
|
||||||
|
|
||||||
package com.geeksville.mesh.ui.radioconfig.components
|
package com.geeksville.mesh.ui.radioconfig.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
@ -131,6 +133,11 @@ fun RouterRoleConfirmationDialog(
|
||||||
Column {
|
Column {
|
||||||
Text(text = annotatedDialogText)
|
Text(text = annotatedDialogText)
|
||||||
Row(
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable(true) {
|
||||||
|
confirmed = !confirmed
|
||||||
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Checkbox(
|
Checkbox(
|
||||||
|
@ -168,16 +175,22 @@ fun DeviceConfigItemList(
|
||||||
) {
|
) {
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
var deviceInput by rememberSaveable { mutableStateOf(deviceConfig) }
|
var deviceInput by rememberSaveable { mutableStateOf(deviceConfig) }
|
||||||
|
var selectedRole by rememberSaveable { mutableStateOf(deviceInput.role) }
|
||||||
var showRouterRoleConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
val infrastructureRoles = listOf(
|
||||||
if (showRouterRoleConfirmationDialog) {
|
DeviceConfig.Role.ROUTER,
|
||||||
RouterRoleConfirmationDialog(
|
DeviceConfig.Role.REPEATER,
|
||||||
onDismiss = { showRouterRoleConfirmationDialog = false },
|
)
|
||||||
onConfirm = {
|
if (selectedRole != deviceInput.role) {
|
||||||
showRouterRoleConfirmationDialog = false
|
if (selectedRole in infrastructureRoles) {
|
||||||
deviceInput = deviceInput.copy { role = DeviceConfig.Role.ROUTER }
|
RouterRoleConfirmationDialog(
|
||||||
}
|
onDismiss = { selectedRole = deviceInput.role },
|
||||||
)
|
onConfirm = {
|
||||||
|
deviceInput = deviceInput.copy { role = selectedRole }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
deviceInput = deviceInput.copy { role = selectedRole }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
|
@ -190,11 +203,7 @@ fun DeviceConfigItemList(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
selectedItem = deviceInput.role,
|
selectedItem = deviceInput.role,
|
||||||
onItemSelected = {
|
onItemSelected = {
|
||||||
if (it == DeviceConfig.Role.ROUTER && deviceInput.role != DeviceConfig.Role.ROUTER) {
|
selectedRole = it
|
||||||
showRouterRoleConfirmationDialog = true
|
|
||||||
} else {
|
|
||||||
deviceInput = deviceInput.copy { role = it }
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
summary = stringResource(id = deviceInput.role.stringRes),
|
summary = stringResource(id = deviceInput.role.stringRes),
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue