kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
rodzic
a603dcb91e
commit
e90aa6c5ed
|
@ -88,6 +88,7 @@ import com.geeksville.mesh.model.BTScanModel
|
|||
import com.geeksville.mesh.model.BluetoothViewModel
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import com.geeksville.mesh.repository.network.NetworkRepository
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
fun String?.isIPAddress(): Boolean {
|
||||
|
@ -145,6 +146,7 @@ fun SettingsScreen(
|
|||
|
||||
// State for manual IP address input
|
||||
var manualIpAddress by remember { mutableStateOf("") }
|
||||
var manualIpPort by remember { mutableStateOf(NetworkRepository.SERVICE_PORT.toString()) }
|
||||
|
||||
// State for the device scan dialog
|
||||
var showScanDialog by remember { mutableStateOf(false) }
|
||||
|
@ -306,7 +308,7 @@ fun SettingsScreen(
|
|||
scanModel.onSelected(
|
||||
BTScanModel.DeviceListEntry(
|
||||
"",
|
||||
"t$manualIpAddress",
|
||||
"t$manualIpAddress:$manualIpPort",
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -319,13 +321,13 @@ fun SettingsScreen(
|
|||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
RadioButton(
|
||||
selected = ("t$manualIpAddress" == selectedDevice),
|
||||
selected = ("t$manualIpAddress:$manualIpPort" == selectedDevice),
|
||||
onClick = {
|
||||
if (manualIpAddress.isIPAddress()) {
|
||||
scanModel.onSelected(
|
||||
BTScanModel.DeviceListEntry(
|
||||
"",
|
||||
"t$manualIpAddress",
|
||||
"t$manualIpAddress:$manualIpPort",
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -340,9 +342,23 @@ fun SettingsScreen(
|
|||
label = { Text(stringResource(R.string.ip_address)) },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.weight(weight = 0.7f)
|
||||
.padding(start = 16.dp)
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = manualIpPort,
|
||||
onValueChange = {
|
||||
// Only allow numeric input for port
|
||||
if (it.all { char -> char.isDigit() }) {
|
||||
manualIpPort = it
|
||||
}
|
||||
},
|
||||
label = { Text(stringResource(R.string.ip_port)) },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||
modifier = Modifier
|
||||
.weight(weight = 0.3f)
|
||||
.padding(start = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
<string name="connected_count">Connected: %1$s online</string>
|
||||
<string name="update_firmware">Update Firmware</string>
|
||||
<string name="ip_address">IP Address:</string>
|
||||
<string name="ip_port">Port:</string>
|
||||
<string name="connected">Connected to radio</string>
|
||||
<string name="connected_to">Connected to radio (%s)</string>
|
||||
<string name="not_connected">Not connected</string>
|
||||
|
|
Ładowanie…
Reference in New Issue