-
Notifications
You must be signed in to change notification settings - Fork 319
Feature/ak #220 faster route callback #2455
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
Conversation
|
Could you @designevokes @map-angela @noracalabrese take a look at this when you have a chance? It'd be 💯 if we can start getting input from you on the design side of things. |
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Show resolved
Hide resolved
Guardiola31337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments / questions to discuss as a team @abhishek1508
examples/src/main/java/com/mapbox/navigation/examples/activity/SimpleMapboxNavigationKt.kt
Outdated
Show resolved
Hide resolved
examples/src/main/java/com/mapbox/navigation/examples/activity/SimpleMapboxNavigationKt.kt
Outdated
Show resolved
Hide resolved
examples/src/main/java/com/mapbox/navigation/examples/activity/SimpleMapboxNavigationKt.kt
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| private val fasterRouteObserver = object : FasterRouteObserver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this as part of this PR? Currently faster route is disable by default downstream
Lines 116 to 119 in fbbeee4
| private fun isRouteFaster(newRoute: DirectionsRoute): Boolean { | |
| // TODO: Implement the logic to check if the route is faster | |
| return false | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I would like to stick it as a part of this PR because that's the objective of this ticket. To be able to provide a callback for user to act on faster route. The part where we fix the above isRouteFaster is going to come up here
| private val router: Router | ||
| ) : DirectionsSession { | ||
|
|
||
| private val fasterRouteInterval = 2 * 60 * 1000L // 2 minutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be customizable from a client point of view as well as enabling / disabling faster functionality completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming up as a part of this
fbbeee4 to
b7fc749
Compare
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tag the team for a review next time around @abhishek1508, I completely missed the PR! :)
The idea LGTM, we're only missing the docs. The UI lives only in an example so I'm happy to merge and we can keep the design discussion going for the refactor of the UI lib.
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/FasterRouteObserver.kt
Show resolved
Hide resolved
|
|
||
| interface FasterRouteObserver { | ||
|
|
||
| fun onFasterRouteAvailable(fasterRoute: DirectionsRoute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we provide a list of routes from the response here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun requestFasterRoute(routeOptions: RouteOptions) { if (routes.isEmpty()) { return } router.getRoute(routeOptions, object : Router.Callback { override fun onResponse(routes: List<DirectionsRoute>) { val route = routes[0] if (isRouteFaster(route)) { fasterRouteObservers.forEach { it.onFasterRouteAvailable(route) } } } override fun onFailure(throwable: Throwable) { // do nothing } override fun onCanceled() { // do nothing } }) }
If you look at the onResponse we use the route at index 0 to check if the route is faster than the current route. If true only then we broadcast a faster route. The question, I would like to ask here is do we want to emit a list of routes because then how does the end client know which route is faster in that list? There are 2 solutions to this:
- We emit the list of route and say that route at index 0 in this list has been verified to be faster; so use it - so then in that case why to even send a list since the 0th route is always going to be faster.
- Send a list to the user and ask him to find out which route is faster
I don't see either of the solution that we would probably want to extend from SDK perspective.
Faster route in itself is a very specific feature that says we found 1 faster route rather than multiple faster routes. In that case I think we should only emit one route.
Comments/Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great to add unit tests as well.
Codecov Report
@@ Coverage Diff @@
## master #2455 +/- ##
=========================================
Coverage 32.29% 32.29%
Complexity 621 621
=========================================
Files 143 143
Lines 5605 5605
Branches 434 434
=========================================
Hits 1810 1810
Misses 3595 3595
Partials 200 200 |
|
|
||
| fun unregisterRoutesObserver(routesObserver: RoutesObserver) | ||
|
|
||
| fun registerFasterRouteObserver(fasterRouteObserver: FasterRouteObserver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in #2462, if MapboxNavigation is going to be responsible for making the decision if the route is faster, it could also notify the users back and maintain the observers' list. We don't need to return the control back to the DirectionsSession.
Otherwise, I'd prefer MapboxDirectionsSession to have a constructor injected FasterRouteDetector from #2462 instead of the FasterRouteRequestCallback mechanism. We ultimately don't need to worry about whether or not the requested succeeded as the session's client.
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge and iterate in #2462 👍
8608149 to
085f420
Compare
Description
Implement callback to allow user to accept or dismiss faster route (https://github.com/mapbox/navigation-sdks/issues/220)
bug,feature,new API(s),SEMVER, etc.)Goal
Implement callback to allow user to accept or dismiss faster route
Implementation
Implement callback to allow user to accept or dismiss faster route
Screenshots or Gifs
Testing
Please describe the manual tests that you ran to verify your changes
SNAPSHOTupstream dependencies if needed) through testapp/demo app and run all activities to avoid regressionsChecklist
CHANGELOGincluding this PR