mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(settings): add DNS support and fix UDP protocol toggle (#5013)
This commit is contained in:
parent
150ee3f1a4
commit
ad08a6c7b7
2 changed files with 31 additions and 19 deletions
|
|
@ -689,6 +689,7 @@
|
|||
<string name="ip">IP</string>
|
||||
<string name="gateway">Gateway</string>
|
||||
<string name="subnet">Subred</string>
|
||||
<string name="dns">DNS</string>
|
||||
<string name="paxcounter_config">Paxcounter Config</string>
|
||||
<string name="paxcounter_enabled">Paxcounter enabled</string>
|
||||
<string name="status_message">Status Message</string>
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import org.meshtastic.core.resources.config_network_eth_enabled_summary
|
|||
import org.meshtastic.core.resources.config_network_udp_enabled_summary
|
||||
import org.meshtastic.core.resources.config_network_wifi_enabled_summary
|
||||
import org.meshtastic.core.resources.connection_status
|
||||
import org.meshtastic.core.resources.dns
|
||||
import org.meshtastic.core.resources.error
|
||||
import org.meshtastic.core.resources.ethernet_config
|
||||
import org.meshtastic.core.resources.ethernet_enabled
|
||||
|
|
@ -271,29 +272,31 @@ fun NetworkConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit, onO
|
|||
SwitchPreference(
|
||||
title = stringResource(Res.string.udp_enabled),
|
||||
summary = stringResource(Res.string.config_network_udp_enabled_summary),
|
||||
checked = formState.value.address_mode == Config.NetworkConfig.AddressMode.STATIC,
|
||||
onCheckedChange = {
|
||||
formState.value =
|
||||
formState.value.copy(
|
||||
address_mode =
|
||||
if (it) {
|
||||
Config.NetworkConfig.AddressMode.STATIC
|
||||
} else {
|
||||
Config.NetworkConfig.AddressMode.DHCP
|
||||
},
|
||||
)
|
||||
checked =
|
||||
formState.value.enabled_protocols and Config.NetworkConfig.ProtocolFlags.UDP_BROADCAST.value !=
|
||||
0,
|
||||
onCheckedChange = { enabled ->
|
||||
val flags =
|
||||
if (enabled) {
|
||||
formState.value.enabled_protocols or
|
||||
Config.NetworkConfig.ProtocolFlags.UDP_BROADCAST.value
|
||||
} else {
|
||||
formState.value.enabled_protocols and
|
||||
Config.NetworkConfig.ProtocolFlags.UDP_BROADCAST.value.inv()
|
||||
}
|
||||
formState.value = formState.value.copy(enabled_protocols = flags)
|
||||
},
|
||||
enabled = state.connected,
|
||||
)
|
||||
HorizontalDivider()
|
||||
DropDownPreference(
|
||||
title = stringResource(Res.string.ipv4_mode),
|
||||
enabled = state.connected,
|
||||
selectedItem = formState.value.address_mode,
|
||||
onItemSelected = { formState.value = formState.value.copy(address_mode = it) },
|
||||
itemLabel = { it.name },
|
||||
)
|
||||
if (formState.value.address_mode == Config.NetworkConfig.AddressMode.STATIC) {
|
||||
HorizontalDivider()
|
||||
DropDownPreference(
|
||||
title = stringResource(Res.string.ipv4_mode),
|
||||
enabled = state.connected,
|
||||
selectedItem = formState.value.address_mode,
|
||||
onItemSelected = { formState.value = formState.value.copy(address_mode = it) },
|
||||
itemLabel = { it.name },
|
||||
)
|
||||
HorizontalDivider()
|
||||
val ipv4 = formState.value.ipv4_config ?: Config.NetworkConfig.IpV4Config()
|
||||
EditIPv4Preference(
|
||||
|
|
@ -323,6 +326,14 @@ fun NetworkConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit, onO
|
|||
},
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
)
|
||||
HorizontalDivider()
|
||||
EditIPv4Preference(
|
||||
title = stringResource(Res.string.dns),
|
||||
value = ipv4.dns,
|
||||
enabled = state.connected,
|
||||
onValueChanged = { formState.value = formState.value.copy(ipv4_config = ipv4.copy(dns = it)) },
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue