mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 08:55:54 +03:00
add ACCESS_COARSE_LOCATION for LocationPickerController
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
7803263c1d
commit
80e1bc6505
2 changed files with 22 additions and 19 deletions
|
@ -71,6 +71,7 @@
|
|||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
|
||||
<application
|
||||
android:name=".application.NextcloudTalkApplication"
|
||||
|
|
|
@ -212,8 +212,8 @@ class LocationPickerController(args: Bundle) :
|
|||
}
|
||||
|
||||
private fun initMap() {
|
||||
if (!isFineLocationPermissionGranted()) {
|
||||
requestFineLocationPermission()
|
||||
if (!isLocationPermissionsGranted()) {
|
||||
requestLocationPermissions()
|
||||
}
|
||||
|
||||
binding.map.setTileSource(TileSourceFactory.MAPNIK)
|
||||
|
@ -370,29 +370,31 @@ class LocationPickerController(args: Bundle) :
|
|||
})
|
||||
}
|
||||
|
||||
private fun isFineLocationPermissionGranted(): Boolean {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
return if (PermissionChecker.checkSelfPermission(
|
||||
context!!,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
) == PermissionChecker.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.d(TAG, "Permission is granted")
|
||||
true
|
||||
} else {
|
||||
Log.d(TAG, "Permission is revoked")
|
||||
false
|
||||
}
|
||||
private fun isLocationPermissionsGranted(): Boolean {
|
||||
fun isCoarseLocationGranted(): Boolean {
|
||||
return PermissionChecker.checkSelfPermission(
|
||||
context!!,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
fun isFineLocationGranted() : Boolean {
|
||||
return PermissionChecker.checkSelfPermission(
|
||||
context!!,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
isCoarseLocationGranted() && isFineLocationGranted()
|
||||
} else {
|
||||
Log.d(TAG, "Permission is granted")
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestFineLocationPermission() {
|
||||
private fun requestLocationPermissions() {
|
||||
requestPermissions(
|
||||
arrayOf(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
),
|
||||
REQUEST_PERMISSIONS_REQUEST_CODE
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue