fix: location sharing without gms when not moving [WPB-9724] 🍒 #3143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was automatically cherry-picked based on the following PR:
Original PR description:
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
Sometimes when we want to share the location on grapehene devices, the app is stuck on loading.
Causes (Optional)
On graphene there is no google services so the app uses the native manager to get the location, by requesting location updates. It works fine when the user is moving, but not when standing in the same place, probably because
requestLocationUpdates
emits items only when the location changes.Solutions
On newer Android versions use new way of getting location -
getCurrentLocation
and on old ones instead ofrequestLocationUpdates
, userequestSingleUpdate
because the app needs and uses only a single data anyway, doesn't need to listen for multiple changes.Also, to make it even faster and more user friendly, first the last known location is checked and if it's not too old (currently if it's not older than 1m) then just use this last location because it looks like the user hasn't moved since then.
If the last location is too old, then just request the current one. There is also a timeout of 10s to get the current location,
getCurrentLocation
has some timeout anyway, but it's not configurable and it's unclear how big it is, so to make it unified a custom one is created - if the new location doesn't appear within 10s, then user gets the info that the app couldn't get the location.Added tests for both
LocationPickerHelper
(to test getting location without google services on both new and old Android versions using robolectric) andLocationPickerHelperFlavor
(to test getting location with google services using mockk).Testing
Test Coverage (Optional)
How to Test
Open conversation screen and try to share location.
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.