Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location crash #5084

Merged
merged 23 commits into from
Jan 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7242f1c
Fix a crash when disabling the location on the device
bmarty Jan 27, 2022
db3f60b
Inform the user when the location provider is disabled.
bmarty Jan 27, 2022
e3242f0
Prevent the dialog from being cancellable, since OK button finish the…
bmarty Jan 27, 2022
e9b9406
Rework the location code - WIP
bmarty Jan 27, 2022
1f53945
Rework the location code - WIP
bmarty Jan 27, 2022
55ed737
Rework the location code - WIP
bmarty Jan 27, 2022
26c0fee
Add a loader waiting for the user location to be known
bmarty Jan 27, 2022
0f8c3bc
Try to get location by using all available providers.
onurays Jan 28, 2022
4026ddb
Fix multiple pin rendering.
onurays Jan 28, 2022
50279e3
Use static map image in timeline.
onurays Jan 28, 2022
2dc52da
Use static map image in bottom sheet.
onurays Jan 28, 2022
e0ac8ee
No need for an extra FrameLayout
bmarty Jan 28, 2022
eff6942
Use a MaterialCarView
bmarty Jan 28, 2022
2ce3894
Create a UrlMapProvider for a better handling of RTL languages, and b…
bmarty Jan 28, 2022
b14e557
Use the existing item click mechanism
bmarty Jan 29, 2022
83ed80e
Rename fun for clarity
bmarty Jan 29, 2022
303a858
Create an extension, improve the parsing algorithm, add robustness an…
bmarty Jan 29, 2022
99f82d9
Avoid taking into account network location if we have gps location.
bmarty Jan 29, 2022
a8c251f
Avoid taking into account any provider location if we have gps location.
bmarty Jan 29, 2022
2fbb434
Format
bmarty Jan 29, 2022
ecd41d3
network "not live" lcoation can be more accurate than GPS "not live" …
bmarty Jan 31, 2022
4e3c730
Changelog
bmarty Jan 31, 2022
8ee23c1
Merge branch 'develop' into feature/bma/location_crash
bmarty Jan 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
network "not live" lcoation can be more accurate than GPS "not live" …
…location. So do not ignore them. Not sure how if this is a universal rule...
bmarty committed Jan 31, 2022

Verified

This commit was signed with the committer’s verified signature.
ayumi ayumi  yu
commit ecd41d38260507eed54f370dcd429017cc1d31a3
Original file line number Diff line number Diff line change
@@ -40,12 +40,12 @@ class LocationTracker @Inject constructor(

private var callback: Callback? = null

private var hasGpsProviderLocation = false
private var hasGpsProviderLiveLocation = false

@RequiresPermission(anyOf = [Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION])
fun start(callback: Callback?) {
Timber.d("## LocationTracker. start()")
hasGpsProviderLocation = false
hasGpsProviderLiveLocation = false
this.callback = callback

if (locationManager == null) {
@@ -66,9 +66,9 @@ class LocationTracker @Inject constructor(
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
Timber.d("## LocationTracker. lastKnownLocation: $lastKnownLocation")
} else {
Timber.d("## LocationTracker. lastKnownLocation")
Timber.d("## LocationTracker. lastKnownLocation: ${lastKnownLocation.provider}")
}
onLocationChanged(lastKnownLocation)
notifyLocation(lastKnownLocation, isLive = false)
}

locationManager.requestLocationUpdates(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to call this multiple times this fun and call only once locationManager?.removeUpdates(this) in onStop? Maybe yes but I want to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can see the location icon on Status Bar is disappearing when fragment is destroyed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah didn't notice that. It does not disappear on my side

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I have to put the entire app into bg to make it disappear to be more precise.

@@ -95,20 +95,20 @@ class LocationTracker @Inject constructor(
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
Timber.d("## LocationTracker. onLocationChanged: $location")
} else {
Timber.d("## LocationTracker. onLocationChanged")
Timber.d("## LocationTracker. onLocationChanged: ${location.provider}")
}
notifyLocation(location)
notifyLocation(location, isLive = true)
}

private fun notifyLocation(location: Location) {
private fun notifyLocation(location: Location, isLive: Boolean) {
when (location.provider) {
LocationManager.GPS_PROVIDER -> {
hasGpsProviderLocation = true
hasGpsProviderLiveLocation = isLive
}
else -> {
if (hasGpsProviderLocation) {
if (hasGpsProviderLiveLocation) {
// Ignore this update
Timber.d("## LocationTracker. ignoring location from ${location.provider}, we have gps location")
Timber.d("## LocationTracker. ignoring location from ${location.provider}, we have gps live location")
return
}
}