Skip to content

Commit

Permalink
Fix background location false warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Semper-Viventem committed Jan 25, 2025
1 parent d2e25ee commit 36b4b7e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
minSdk = 29
targetSdk = 35

versionCode = 1708536363
versionName = "0.27.1-beta"
versionCode = 1708536364
versionName = "0.27.2-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PermissionHelper(

private var pending: (() -> Unit)? = null
private var permissionRequestTime: Long? = null
private val backgroundPermissionState = MutableStateFlow(checkBackgroundLocationPermition())
private val backgroundPermissionState = MutableStateFlow(backgroundLocationAllowed())

fun checkBlePermissions(
onRequestPermissions: (permissions: Array<String>, permissionRequestCode: Int, pendingFun: () -> Unit) -> Unit = ::requestPermissions,
Expand Down Expand Up @@ -90,15 +90,15 @@ class PermissionHelper(
return backgroundPermissionState
}

fun checkBackgroundLocationPermition(): Boolean {
fun backgroundLocationAllowed(): Boolean {
return checkPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
}

private fun fetchBackgroundLocationPermission() {
backgroundPermissionState.value = checkBackgroundLocationPermition()
backgroundPermissionState.value = backgroundLocationAllowed()
}

fun checkLocationPermission(): Boolean {
fun locationAllowed(): Boolean {
return checkPermission(Manifest.permission.ACCESS_FINE_LOCATION)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class BgScanService : Service() {
return when {
!locationProvider.isLocationAvailable() -> handleLocationDisabled()
!bleScannerHelper.isBluetoothEnabled() -> handleBleIsTurnedOffError()
permissionHelper.checkBackgroundLocationPermition() -> handleBackgroundLocationRestricted()
!permissionHelper.backgroundLocationAllowed() -> handleBackgroundLocationRestricted()
else -> NotificationsHelper.ServiceNotificationContent.NoDataYet
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ object SelectLocationScreen {
mapView.controller.setZoom(MapConfig.DEFAULT_MAP_ZOOM)
} else {
scope.launch {
if (permissionHelper.checkLocationPermission()) {
if (permissionHelper.locationAllowed()) {
locationProvider.observeLocation()
.filterNotNull()
.take(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SettingsViewModel(
if (locationProvider.isActive()) {
locationProvider.stopLocationListening()
locationProvider.startLocationFetching()
} else if (permissionHelper.checkLocationPermission()) {
} else if (permissionHelper.locationAllowed()) {
locationProvider.fetchOnce()
}
}
Expand Down

0 comments on commit 36b4b7e

Please sign in to comment.