mapbox / mapbox/mapbox-navigation-android

Distinguishing states when session is started

Open
#3,275 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Core
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Mapbox Navigation SDK version:**
qa_release_core_1.0.0-qa.2020w27
qa_release_ui_1.0.0-qa.2020w27

### Issue
The states available in Navigation-Core for Free Drive and Active Guidance is [TripSessionState](https://github.com/mapbox/mapbox-navigation-android/blob/82785402548dae40ec7b6000308ab2b5b8f22f93/libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/session/TripSessionState.kt#L6-L16) and [getRoutes](https://github.com/mapbox/mapbox-navigation-android/blob/82785402548dae40ec7b6000308ab2b5b8f22f93/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt#L286).

When a session is STARTED, there are only 2 states available in navigation core. All the examples have these states, but are not handling them directly. This makes it difficult to [restore state on configuration changes](https://github.com/mapbox/navigation-sdks/issues/402)

| Free Drive | Set route (?) | Active guidance |
| -- | -- | -- |
| ![session-start](https://user-images.githubusercontent.com/3021882/86381449-35851900-bc42-11ea-8b45-772d13b1a57d.png) | ![set-route](https://user-images.githubusercontent.com/3021882/86381973-7a10b480-bc42-11ea-8c61-0eb3b2c96f46.png) | ![active-guidance](https://user-images.githubusercontent.com/3021882/86382073-8268ef80-bc42-11ea-936c-e27b63554ce0.png) |

### Solutions

1tap is solving this with a [NavigationViewsState](https://github.com/mapbox/1tap-android/blob/2ddc0daf437c5f3c44770dce2c2042120e85f1f2/navigation/src/main/java/com/mapbox/onetap/navigation/route/domain/NavigationViewsState.kt#L12-L32)

Navigation-UI stores a "navigation_running" key and restores it onCreate inside [NavigationView](https://github.com/mapbox/mapbox-navigation-android/blob/82785402548dae40ec7b6000308ab2b5b8f22f93/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/NavigationView.java#L802-L808)

### Next steps

All the examples are working around this problem by subscribing to the LocationEngine separately, and they're not starting the session right away. Considering solutions for all of our [core examples](https://github.com/mapbox/mapbox-navigation-android/tree/master/examples/src/main/java/com/mapbox/navigation/examples/core)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TripSessionState.kt and MapboxNavigation.kt to understand the existing session and route states, then compare the restoration logic in NavigationView.java and the core examples. Review the linked configuration-change context and determine a consistent state model and example handling; done means session states can be distinguished and restored without the current LocationEngine workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
api, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.