diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0bc8a0d..20046b0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ package="com.pluscubed.velociraptor"> + diff --git a/app/src/main/java/com/pluscubed/velociraptor/settings/PermissionsFragment.kt b/app/src/main/java/com/pluscubed/velociraptor/settings/PermissionsFragment.kt index 8bc06ec..3ef02ff 100644 --- a/app/src/main/java/com/pluscubed/velociraptor/settings/PermissionsFragment.kt +++ b/app/src/main/java/com/pluscubed/velociraptor/settings/PermissionsFragment.kt @@ -95,10 +95,16 @@ class PermissionsFragment : Fragment() { } enableLocationButton.setOnClickListener { v -> - requestPermissions( - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_LOCATION - ) + if (Build.VERSION.SDK_INT < 29) + requestPermissions( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + REQUEST_LOCATION + ) + else + requestPermissions( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION), + REQUEST_LOCATION + ) } } diff --git a/app/src/main/java/com/pluscubed/velociraptor/utils/Utils.kt b/app/src/main/java/com/pluscubed/velociraptor/utils/Utils.kt index 096c91b..eccf486 100644 --- a/app/src/main/java/com/pluscubed/velociraptor/utils/Utils.kt +++ b/app/src/main/java/com/pluscubed/velociraptor/utils/Utils.kt @@ -128,10 +128,19 @@ object Utils { fun isLocationPermissionGranted(context: Context?): Boolean { if (context != null) { - return ContextCompat.checkSelfPermission( - context, - Manifest.permission.ACCESS_FINE_LOCATION - ) == PackageManager.PERMISSION_GRANTED + return if (Build.VERSION.SDK_INT < 29) + ContextCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_FINE_LOCATION + ) == PackageManager.PERMISSION_GRANTED + else + ContextCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_FINE_LOCATION + ) == PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission( + context, + Manifest.permission.ACCESS_BACKGROUND_LOCATION + ) == PackageManager.PERMISSION_GRANTED } return false }