diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f91c22e..75a0ce5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,7 +6,6 @@
-
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt
index d8af6e4..177401f 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt
@@ -23,10 +23,7 @@ object WeatherHelper {
Kotpref.init(context)
if (Preferences.customLocationAdd != "") {
WeatherNetworkApi(context).updateWeather()
- } else if (context.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION) &&
- (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.R ||
- context.checkGrantedPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION))
- ) {
+ } else if (context.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
LocationService.requestNewLocation(context)
} else {
Preferences.weatherProviderLocationError = context.getString(R.string.weather_provider_error_missing_location)
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt
index 44a1f2d..73bb497 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/services/LocationService.kt
@@ -18,7 +18,6 @@ import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
-import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
import kotlinx.coroutines.*
import org.greenrobot.eventbus.EventBus
import java.lang.Exception
@@ -38,9 +37,10 @@ class LocationService : Service() {
startForeground(LOCATION_ACCESS_NOTIFICATION_ID, getLocationAccessNotification())
job?.cancel()
job = GlobalScope.launch(Dispatchers.IO) {
- if (checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION) &&
- (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.R ||
- checkGrantedPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION))
+ if (ActivityCompat.checkSelfPermission(
+ this@LocationService,
+ Manifest.permission.ACCESS_FINE_LOCATION
+ ) == PackageManager.PERMISSION_GRANTED
) {
if (com.google.android.gms.common.GoogleApiAvailability.getInstance()
.isGooglePlayServicesAvailable(this@LocationService)
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/WeatherFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/WeatherFragment.kt
index 4fc5644..93189c0 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/WeatherFragment.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/tabs/WeatherFragment.kt
@@ -134,23 +134,13 @@ class WeatherFragment : Fragment() {
}
private fun checkLocationPermission() {
- if (requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION) &&
- (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.R ||
- requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION))
- ) {
+ if (requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
binding.locationPermissionAlert.isVisible = false
} else if (Preferences.customLocationAdd == "") {
binding.locationPermissionAlert.isVisible = true
binding.locationPermissionAlert.setOnClickListener {
requirePermission()
}
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R &&
- requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)
- ) {
- val text = getString(R.string.action_grant_permission) + " - " +
- requireContext().packageManager.backgroundPermissionOptionLabel
- binding.locationPermissionAlert.text = text
- }
binding.weatherProviderLocationError.isVisible = false
} else {
binding.locationPermissionAlert.isVisible = false
@@ -232,11 +222,7 @@ class WeatherFragment : Fragment() {
private fun requirePermission() {
Dexter.withContext(requireContext())
.withPermissions(
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R &&
- requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION))
- Manifest.permission.ACCESS_BACKGROUND_LOCATION
- else
- Manifest.permission.ACCESS_FINE_LOCATION
+ Manifest.permission.ACCESS_FINE_LOCATION
).withListener(object: MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
report?.let {