Skip to content

Commit

Permalink
Add boolean check to location permissions
Browse files Browse the repository at this point in the history
Limits the number of times user can upgrade from approximate to precise location.

Issue #127
  • Loading branch information
englehorn committed Jan 31, 2022
1 parent 7021398 commit f759154
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class TrafficMapFragment : DaggerFragment(), Injectable, OnMapReadyCallback,

var showAlerts: Boolean = true
var showRestAreas: Boolean = true
var requestLocationUpgrade: Boolean = true

private lateinit var mMap: GoogleMap

Expand Down Expand Up @@ -274,7 +275,9 @@ class TrafficMapFragment : DaggerFragment(), Injectable, OnMapReadyCallback,
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_my_location -> {
myLocationFineWithPermissionCheck()
if (requestLocationUpgrade) {
myLocationFineWithPermissionCheck()
}
checkAppPermissions()
}
}
Expand Down Expand Up @@ -1068,6 +1071,11 @@ class TrafficMapFragment : DaggerFragment(), Injectable, OnMapReadyCallback,
}
-> {
myLocationCoarseWithPermissionCheck()

if (Build.VERSION.SDK_INT > 30) {
requestLocationUpgrade = false
}

}
else -> {
// Present permission dialog to request permission type
Expand Down

0 comments on commit f759154

Please sign in to comment.