store background location pref

This commit is contained in:
Kevin Hester 2021-06-23 12:41:44 -07:00
parent 74f7281a60
commit 74a34cd9b6
5 changed files with 20 additions and 2 deletions

View file

@ -651,6 +651,9 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
binding.provideLocationCheckbox.setOnCheckedChangeListener { view, isChecked ->
// No matter what set our desired state in prefs
model.provideLocation.value = isChecked
if (view.isPressed && isChecked) { // We want to ignore changes caused by code (as opposed to the user)
debug("User changed location tracking to $isChecked")
view.isChecked =
@ -977,7 +980,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
scanModel.startScan()
// system permissions might have changed while we were away
binding.provideLocationCheckbox.isChecked = myActivity.hasBackgroundPermission()
binding.provideLocationCheckbox.isChecked = myActivity.hasBackgroundPermission() && (model.provideLocation.value ?: false)
myActivity.registerReceiver(updateProgressReceiver, updateProgressFilter)