Conversation
edf4d81 to
01bd7c1
Compare
|
@Guardiola31337 So excited to see this happening. |
tobrun
left a comment
There was a problem hiding this comment.
Looking great so far, just one remark on LocationSourceProvider
| private void initLocationSourceDictionary(Context context) { | ||
| locationSourceDictionary = new HashMap<>(3); | ||
| locationSourceDictionary.put("Google Play Services", GoogleLocationEngine.getLocationEngine(context)); | ||
| locationSourceDictionary.put("Lost", LostLocationEngine.getLocationEngine(context)); |
There was a problem hiding this comment.
above doesn't seem to validate if it's in the classpath or not
|
bf5a464 to
7340234
Compare
Usage: LocationEngineProvider locationEngineProvider = new LocationEngineProvider(this);
locationEngine = locationEngineProvider.obtainAvailableLocationEngines()
.get(LocationEngineProvider.GOOGLE_PLAY_SERVICES);
if (locationEngine == null) {
locationEngine = locationEngineProvider.obtainAvailableLocationEngines()
.get(LocationEngineProvider.ANDROID);
}What do you think @zugaldia?
We should revisit the provider strategy. I run some tests and the problem was that when you set the priority to
Not necessary anymore.
|
|
23b50d9 adds/fixes new APIs to get
LocationEngineProvider locationEngineProvider = new LocationEngineProvider(context);
locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable();
LocationEngineProvider locationEngineProvider = new LocationEngineProvider(this);
locationEngine = locationEngineProvider.obtainLocationEngineBy(LocationEngine.Type.GOOGLE_PLAY_SERVICES);
if (locationEngine == null) {
locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable();
}Or directly requesting LocationEngineProvider locationEngineProvider = new LocationEngineProvider(this);
locationEngine = locationEngineProvider.obtainLocationEngineBy(LocationEngine.Type.GOOGLE_PLAY_SERVICES);
if (locationEngine == null) {
locationEngine = locationEngineProvider.obtainLocationEngineBy(LocationEngine.Type.ANDROID);
}That ☝️ allows you to: LocationEngineProvider locationEngineProvider = new LocationEngineProvider(this);
locationEngine = locationEngineProvider.obtainLocationEngineBy(LocationEngine.Type.ANDROID);Could be useful/interesting in some use cases.
Apart from ☝️ this PR is ready for review. |
678a54a to
23b50d9
Compare
zugaldia
left a comment
There was a problem hiding this comment.
A few comments, none of them blocking the PR. Can't wait to start using the new APIs.
mapbox/app/build.gradle
Outdated
|
|
||
| // LOST | ||
| compile(rootProject.ext.dep.lost) { | ||
| exclude group: 'com.google.guava' |
There was a problem hiding this comment.
If we upgrade the dependency to the latest LOST that Guava exclusion is no longer necessary.
There was a problem hiding this comment.
I tested the sample app with lost 3.0.3 (atm latest version) and I found that it wasn't working properly so I'd rather keep lost 1.1.1 until lostzen/lost#241 gets fixed.
There was a problem hiding this comment.
@Guardiola31337 I'd actually argue the opposite. With this PR the developer now has the freedom to switch location providers if they don't meet their needs. I think that all that lostzen/lost#241 shows is that LOST fails under certain scenarios. I'd still upgrade to the latest version of LOST and leave it up to the developer decide if that scenario is a blocker for them.
| * Builds Android location engine | ||
| * Builds location engine | ||
| */ | ||
| private synchronized void buildAndroidLocationEngine() { |
There was a problem hiding this comment.
Why is synchronized no longer needed?
There was a problem hiding this comment.
@zugaldia
Don't like to answering with a question but I'm pretty sure you have more context:
Why was synchronized in the first place? Why getLocationEngine() from AndroidLocationEngine, LostLocationEngine and GoogleLocationEngine need to be synchronized?
BTW, I've tested it and I didn't find any issues so apparently is working as expected.
There was a problem hiding this comment.
@Guardiola31337 For thread safety, did your tests include that scenario (i.e. multi-threading)?
There was a problem hiding this comment.
@Guardiola31337 just seeing this is an Activity, I though this was part of the library, thanks for pointing that out. Nevermind.
|
|
||
| // LOST | ||
| provided(rootProject.ext.dep.lost) { | ||
| exclude group: 'com.google.guava' |
There was a problem hiding this comment.
Same here: let's update to the latest version. If the latest version is an issue to the developer, now they have a mechanism to switch to a different provider.
There was a problem hiding this comment.
| <item>Android</item> | ||
| <item>Lost</item> | ||
| <item>Google Play Services</item> | ||
| <item>Google_Play_Services</item> |
There was a problem hiding this comment.
Was this necessary to match the new Type enum? If so, 👍 .
d3584da to
2ec7c2d
Compare
cammace
left a comment
There was a problem hiding this comment.
Looks like this won't affect Navigation much, we do fall back on the LOST location engine currently in case a user doesn't pass in a location engine. This change I believe will require us to bring the LOST dependency directly into the nav sdk?
| * Sample LocationEngine using Google Play Services | ||
| */ | ||
| public class GoogleLocationEngine extends LocationEngine implements | ||
| class GoogleLocationEngine extends LocationEngine implements |
There was a problem hiding this comment.
This still needs to be public inorder not to break the API
| private GoogleApiClient googleApiClient; | ||
|
|
||
| public GoogleLocationEngine(Context context) { | ||
| private GoogleLocationEngine(Context context) { |
There was a problem hiding this comment.
needs to remain public to not break API
| * Sample LocationEngine using the Open Source Lost library | ||
| */ | ||
| public class LostLocationEngine extends LocationEngine implements LocationListener { | ||
| class LostLocationEngine extends LocationEngine implements |
There was a problem hiding this comment.
needs to remain public to not break API
| private LostApiClient lostApiClient; | ||
|
|
||
| public LostLocationEngine(Context context) { | ||
| private LostLocationEngine(Context context) { |
There was a problem hiding this comment.
needs to remain public to not break API
…nd address PR comments
…that CI passes (chicken-egg problem)
9694aad to
ab8f6c6
Compare
Lost dependency is not needed anymore we could use: LocationEngineProvider locationEngineProvider = new LocationEngineProvider(context);
locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable();which will return the best location engine available. Further information on how to use the new APIs 👉 #502 (comment) |
Per mapbox-gl-native/#9403 we're removing location dependencies on the map SDK. They'll be pulled in from here (MAS), so this PR addresses that.
LocationEngineimplementations for Android core, LOST, and Google Play Services backendsbuild.gradleas optional dependenciesAm I missing something? @mapbox/android
👀 @zugaldia @tobrun for review