Do not reload backends without actual settings update

This commit is contained in:
Marvin W 2020-08-30 00:56:32 +02:00
parent 4c9a3fac6f
commit 8f22b3f6be
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
2 changed files with 8 additions and 0 deletions

View File

@ -169,12 +169,18 @@ class UnifiedLocationServiceRoot(private val service: UnifiedLocationServiceEntr
}
}
private fun <E> Set<E>.contentEquals(other: Set<E>): Boolean {
if (other.size != size) return false
return containsAll(other)
}
override fun getLocationBackends(): Array<String> {
return Preferences(service).locationBackends.toTypedArray()
}
override fun setLocationBackends(backends: Array<String>) {
checkAdminPermission();
if (Preferences(service).locationBackends.contentEquals(backends.toSet())) return
Preferences(service).locationBackends = backends.toSet()
reloadPreferences()
}
@ -185,6 +191,7 @@ class UnifiedLocationServiceRoot(private val service: UnifiedLocationServiceEntr
override fun setGeocoderBackends(backends: Array<String>) {
checkAdminPermission();
if (Preferences(service).geocoderBackends.contentEquals(backends.toSet())) return
Preferences(service).geocoderBackends = backends.toSet()
reloadPreferences()
}

View File

@ -184,6 +184,7 @@ class BackendDetailsFragment : Fragment(R.layout.backend_details), BackendDetail
}
override fun onEnabledChange(entry: BackendInfo?, newValue: Boolean) {
if (entry?.enabled?.get() == newValue) return
Log.d(TAG, "onEnabledChange: ${entry?.signedComponent} = $newValue")
val activity = requireActivity() as AppCompatActivity
entry?.enabled?.set(newValue)