From 9cdaf6f79a32187f48256f8f1871f68a03efe7d3 Mon Sep 17 00:00:00 2001 From: andrekir Date: Tue, 26 Jul 2022 22:28:19 -0300 Subject: [PATCH] fix region changes not updating UI --- .../geeksville/mesh/ui/SettingsFragment.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt index b9a6c8c04..5d2da2903 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt @@ -145,13 +145,19 @@ class SettingsFragment : ScreenFragment("Settings"), Logging { private fun updateNodeInfo() { val connected = model.connectionState.value - val isConnected = connected == MeshService.ConnectionState.CONNECTED - binding.nodeSettings.visibility = if (isConnected) View.VISIBLE else View.GONE - binding.provideLocationCheckbox.visibility = if (isConnected) View.VISIBLE else View.GONE + binding.nodeSettings.visibility = if (model.isConnected()) View.VISIBLE else View.GONE + binding.provideLocationCheckbox.visibility = if (model.isConnected()) View.VISIBLE else View.GONE if (connected == MeshService.ConnectionState.DISCONNECTED) model.setOwner("") + if (model.gpsDisabled) { + model.provideLocation.value = false + binding.provideLocationCheckbox.isChecked = false + } else { + binding.provideLocationCheckbox.isEnabled = isGooglePlayAvailable(requireContext()) + } + // update the region selection from the device val region = model.region val spinner = binding.regionSpinner @@ -243,12 +249,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging { } model.localConfig.observe(viewLifecycleOwner) { - binding.provideLocationCheckbox.isEnabled = - isGooglePlayAvailable(requireContext()) && !model.gpsDisabled - if (model.gpsDisabled) { - model.provideLocation.value = false - binding.provideLocationCheckbox.isChecked = false - } + updateNodeInfo() } // Also watch myNodeInfo because it might change later