Breaking Change: Add some more attributes to geocoded sensor and check that device supports it (#2809)

* Add some more attributes to geocoded sensor and check that device supports it

* Remove language attribute as it does not supply the expected data

* Combine latitude and longitude into the location attribute again
This commit is contained in:
Daniel Shokouhi 2022-08-29 19:25:48 -05:00 committed by GitHub
parent d00c823651
commit db8913c712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,10 @@ class GeocodeSensorManager : SensorManager {
return listOf(geocodedLocation)
}
override fun hasSensor(context: Context): Boolean {
return Geocoder.isPresent()
}
override fun requiredPermissions(sensorId: String): Array<String> {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
arrayOf(
@ -99,13 +103,16 @@ class GeocodeSensorManager : SensorManager {
"country" to it.countryName,
"iso_country_code" to it.countryCode,
"locality" to it.locality,
"latitude" to it.latitude,
"longitude" to it.longitude,
"location" to listOf(it.latitude, it.longitude),
"name" to it.featureName,
"phone" to it.phone,
"premises" to it.premises,
"postal_code" to it.postalCode,
"sub_administrative_area" to it.subAdminArea,
"sub_locality" to it.subLocality,
"sub_thoroughfare" to it.subThoroughfare,
"thoroughfare" to it.thoroughfare
"thoroughfare" to it.thoroughfare,
"url" to it.url
)
}.orEmpty()