[Drop-In UI] Moved LocationComponent outside Drop-In UI#6206
[Drop-In UI] Moved LocationComponent outside Drop-In UI#6206abhishek1508 merged 1 commit intomainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6206 +/- ##
============================================
- Coverage 68.87% 68.85% -0.02%
+ Complexity 4478 4453 -25
============================================
Files 678 668 -10
Lines 26830 26690 -140
Branches 3153 3147 -6
============================================
- Hits 18479 18378 -101
+ Misses 7142 7104 -38
+ Partials 1209 1208 -1
|
d6db9b8 to
029fb87
Compare
029fb87 to
dffe76d
Compare
|
@kmadsen Can you give a brief look and see if this would work for AA, or if this needs some changes? |
| private val mapView: MapView, | ||
| private val locationPuck: LocationPuck, | ||
| private val locationProvider: NavigationLocationProvider, | ||
| private val enableLocationUpdates: Boolean = true |
There was a problem hiding this comment.
These option parameters are not good for java backwards compatibility.
What do you think about moving the option as a function?
class LocationComponent(
...
fun enableLocationUpdates(enable: Boolean)
There was a problem hiding this comment.
Otherwise it would need to go in an Options.Builder
There was a problem hiding this comment.
I wouldn't worry about the "java backwards compatibility" (this is an experimental, internal component).
Sure, we can do the method instead.
There was a problem hiding this comment.
I wouldn't worry about the "java backwards compatibility
We're addressing java backwards compatiblity #6292. That is part of creating a stable api. If there is no intention to make this LocationComponent public, then sure we don't have to worry about it.
Some version of this is going to become a public api for AA
There was a problem hiding this comment.
Nvm. I found a better way to deal with this.
I've split LocationComponent into two separate components:
- LocationComponent responsible for registering
LocationObserverand updatingNavigationLocationProvider - LocationPuckComponent for configuring and updating LocationPuck. This component depends on
MapboxMap,LocationComponentPlugin,LocationPuckandNavigationLocationProvider, which are available in both AA and DropIn UI.
dffe76d to
86ce56d
Compare
|
@kmadsen Thanks for reviewing. I've addressed your feedback. Can you give it another look and let me know if this will work for AA? |
| */ | ||
| @ExperimentalPreviewMapboxNavigationAPI | ||
| fun ComponentInstaller.locationPuck( | ||
| mapView: MapView, |
There was a problem hiding this comment.
We spoke of this some, but is there a way to remove the MapView parameter here?
The component installer could be used in android auto if it used something like a MapComponentInstaller 🤔
There was a problem hiding this comment.
We need MapView here in order to access LocationComponentPlugin (mapView.location) which is required to create LocationPuckComponent.
Remember, these installers are meant to work with MapView, not MapSurface.
For installers that work with AA, we need to create separate installers that will accept MapSurface as an argument.
There was a problem hiding this comment.
I mean, why not use MapPluginProviderDelegate to get the LocationComponentPlugin
There was a problem hiding this comment.
Use MapPluginProviderDelegate instead of MapView? That wouldn't work. We wouldn't be able to acquire MapboxMap, norContext.
There was a problem hiding this comment.
Yeah, would also prefer a simple MapView over requiring it all to be passed like this
fun ComponentInstaller.locationPuck(
context: Context,
mapboxMap: MapboxMap,
plugins: MapPluginProviderDelegate,
config: LocationPuckComponentConfig.() -> Unit = {}
): Installation {
Another approach could be to define a MapComponentInstaller
fun MapComponentInstaller.locationPuck(
config: LocationPuckComponentConfig.() -> Unit = {}
): Installation {There was a problem hiding this comment.
Another approach could be to define a MapComponentInstaller
fun MapComponentInstaller.locationPuck( config: LocationPuckComponentConfig.() -> Unit = {} ): Installation {
We could introduce this once we implement dedicated component installers for MapView and SurfaceMap.
MapboxNavigationApp.installComponents(this) {
map(mapView) { // this: MapComponentInstaller
locationPuck()
}
// and for surface map
map(surfaceMap) { // this: SurfaceMapComponentInstaller
locationPuck()
}
}fb22cb7 to
84d564a
Compare
Split LocationComponent into two separate components. One responsible for observing MapboxNavigation location and updating NavigationLocationProvider, and second for configuring and updating Location Puck.
84d564a to
b82ffde
Compare
Part of https://github.com/mapbox/navigation-sdks/issues/1780
TL;DR
This PR adds a new ComponentInstaller that simplifies the configuration of a Map LocationPuck.
Description
LocationComponenttolibnavui-mapsmoduleLocationObserverlogic fromLocationStateControllertoLocationComponentComponentInstaller.locationPuck(map)libnavui-mapsMetalava file