fix: `getNumber` exception for unrecognized `RegionCode` entries

Fatal Exception: java.lang.IllegalArgumentException: Can't get the number of an unknown enum value.
pull/1375/head
andrekir 2024-11-02 06:16:33 -03:00
rodzic 605ef120c9
commit f2511f814c
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -97,10 +97,11 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
spinner.isEnabled = !model.isManaged
// Update the status string (highest priority messages first)
val regionUnset = region == ConfigProtos.Config.LoRaConfig.RegionCode.UNSET
val info = model.myNodeInfo.value
when (connectionState) {
MeshService.ConnectionState.CONNECTED ->
if (region.number == 0) R.string.must_set_region else R.string.connected_to
if (regionUnset) R.string.must_set_region else R.string.connected_to
MeshService.ConnectionState.DISCONNECTED -> R.string.not_connected
MeshService.ConnectionState.DEVICE_SLEEP -> R.string.connected_sleeping
else -> null