update for proto changes

This commit is contained in:
andrekir 2022-09-18 18:35:13 -03:00
parent 5c586526da
commit 5382fdae49
10 changed files with 78 additions and 60 deletions

View file

@ -43,15 +43,15 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
model.localConfig.asLiveData().observe(viewLifecycleOwner) {
binding.positionBroadcastPeriodEditText.setText(model.config.position.positionBroadcastSecs.toString())
binding.lsSleepEditText.setText(model.config.power.lsSecs.toString())
binding.positionBroadcastPeriodView.isEnabled = !model.config.position.gpsDisabled
binding.positionBroadcastSwitch.isChecked = !model.config.position.gpsDisabled
binding.positionBroadcastPeriodView.isEnabled = model.config.position.gpsEnabled
binding.positionBroadcastSwitch.isChecked = model.config.position.gpsEnabled
binding.lsSleepView.isEnabled = model.config.power.isPowerSaving && model.isESP32()
binding.lsSleepSwitch.isChecked = model.config.power.isPowerSaving && model.isESP32()
}
model.connectionState.observe(viewLifecycleOwner) { connectionState ->
val connected = connectionState == MeshService.ConnectionState.CONNECTED
binding.positionBroadcastPeriodView.isEnabled = connected && !model.config.position.gpsDisabled
binding.positionBroadcastPeriodView.isEnabled = connected && model.config.position.gpsEnabled
binding.lsSleepView.isEnabled = connected && model.config.power.isPowerSaving
binding.positionBroadcastSwitch.isEnabled = connected
binding.lsSleepSwitch.isEnabled = connected && model.isESP32()
@ -87,7 +87,7 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
binding.positionBroadcastSwitch.setOnCheckedChangeListener { btn, isChecked ->
if (btn.isPressed) {
model.updatePositionConfig { it.copy { gpsDisabled = !isChecked } }
model.updatePositionConfig { it.copy { gpsEnabled = isChecked } }
debug("User changed locationShare to $isChecked")
}
}

View file

@ -251,7 +251,10 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
debug("Switching back to default channel")
installSettings(
Channel.default.settings,
Channel.default.loraConfig.copy { region = model.region }
Channel.default.loraConfig.copy {
region = model.region
txEnabled = model.txEnabled
}
)
}
.show()
@ -312,6 +315,8 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
// No matter what apply the speed selection from the user
val newLoRaConfig = loRaConfig {
region = model.region
txEnabled = model.txEnabled
usePreset = true
modemPreset = newModemPreset
}

View file

@ -161,17 +161,17 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (connected == MeshService.ConnectionState.DISCONNECTED)
model.setOwner("")
if (model.config.position.gpsDisabled) {
if (model.config.position.gpsEnabled) {
binding.provideLocationCheckbox.isEnabled = true
} else {
binding.provideLocationCheckbox.isChecked = false
binding.provideLocationCheckbox.isEnabled = false
} else {
binding.provideLocationCheckbox.isEnabled = true
}
// update the region selection from the device
val region = model.region
val spinner = binding.regionSpinner
val unsetIndex = regions.indexOf(ConfigProtos.Config.LoRaConfig.RegionCode.Unset.name)
val unsetIndex = regions.indexOf(ConfigProtos.Config.LoRaConfig.RegionCode.UNSET.name)
spinner.onItemSelectedListener = null
debug("current region is $region")