change provideLocation on isPressed

This commit is contained in:
andrekir
2022-11-25 18:53:50 -03:00
parent 689e7e7eca
commit 3d79601965

View File

@@ -380,12 +380,12 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
.launchIn(lifecycleScope)
binding.provideLocationCheckbox.setOnCheckedChangeListener { view, isChecked ->
model.provideLocation.value = isChecked
// Don't check the box until the system setting changes
view.isChecked = isChecked && myActivity.hasBackgroundPermission()
if (view.isPressed) { // We want to ignore changes caused by code (as opposed to the user)
debug("User changed location tracking to $isChecked")
model.provideLocation.value = isChecked
if (isChecked && !view.isChecked)
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.background_required)