Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ Mapbox welcomes participation and contributions from everyone.
#### Features
#### Bug fixes and improvements
- Marked `ReplayProgressObserver`, `MapboxReplayer`, `ReplayLocationEngine`, `RerouteController#RoutesCallback`, `NavigationRerouteController#RoutesCallback`, `LocationObserver`, `NavigationSessionStateObserver`, `OffRouteObserver`, `RouteProgressObserver`, `TripSessionStateObserver`, `VoiceInstructionsObserver` methods with `@UiThread` annotation. [#6266](https://github.com/mapbox/mapbox-navigation-android/pull/6266)
- Fix crash due to multiple DataStores active. [#6392](https://github.com/mapbox/mapbox-navigation-android/pull/6392)

## Mapbox Navigation SDK 2.9.0-alpha.3 - 23 September, 2022
### Changelog
[Changes between v2.9.0-alpha.2 and v2.9.0-alpha.3](https://github.com/mapbox/mapbox-navigation-android/compare/v2.9.0-alpha.2...v2.9.0-alpha.3)

#### Known issues

:bangbang: `MapboxAudioGuidance` crashes when attached to new instances of `MapboxNavigation`. This will crash `ui-androidauto` and `ui-dropin`. There is no known work around and it will be fixed in 2.9.0-alpha.4. [#6392](https://github.com/mapbox/mapbox-navigation-android/pull/6392)

#### Features
- Moved `MapboxAudioGuidance` and `MapboxAudioGuidanceState` into public api. [#6336](https://github.com/mapbox/mapbox-navigation-android/pull/6336)
- Introduced `ViewOptionsCustomization.showCameraDebugInfo` to allow end users to enable camera debug info. [#6356](https://github.com/mapbox/mapbox-navigation-android/pull/6356)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import kotlinx.coroutines.flow.map
/**
* Implementation for preferences that exist beyond app and car sessions.
*/
class NavigationDataStoreOwner(context: Context, storeName: String) {
class NavigationDataStoreOwner(context: Context) {

private val Context.dataStore by preferencesDataStore(storeName)
private var dataStore: DataStore<Preferences> = context.dataStore
private val dataStore: DataStore<Preferences> = context.dataStore

fun <T> read(key: NavigationDataStoreKey<T>): Flow<T> {
return dataStore.data.map { preferences ->
Expand All @@ -27,4 +26,9 @@ class NavigationDataStoreOwner(context: Context, storeName: String) {
preferences[key.preferenceKey] = value ?: key.defaultValue
}
}

private companion object {
private const val NAVIGATION_DATA_STORE_NAME = "mapbox_navigation_preferences"
private val Context.dataStore by preferencesDataStore(name = NAVIGATION_DATA_STORE_NAME)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal constructor(
*/
override fun onAttached(mapboxNavigation: MapboxNavigation) {
val context = mapboxNavigation.navigationOptions.applicationContext
dataStoreOwner = audioGuidanceServices.dataStoreOwner(context, DEFAULT_DATA_STORE_NAME)
dataStoreOwner = audioGuidanceServices.dataStoreOwner(context)
configOwner = audioGuidanceServices.configOwner(context)
mapboxVoiceInstructions.registerObservers(mapboxNavigation)
job = scope.launch {
Expand Down Expand Up @@ -198,7 +198,6 @@ internal constructor(
companion object {
private val STORE_AUDIO_GUIDANCE_MUTED =
booleanDataStoreKey("audio_guidance_muted", false)
private const val DEFAULT_DATA_STORE_NAME = "mapbox_navigation_preferences"

/**
* Construct an instance without registering to [MapboxNavigationApp].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ class MapboxAudioGuidanceServices {

fun configOwner(context: Context): NavigationConfigOwner = NavigationConfigOwner(context)

fun dataStoreOwner(context: Context, storeName: String) =
NavigationDataStoreOwner(context, storeName)
fun dataStoreOwner(context: Context) = NavigationDataStoreOwner(context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TestMapboxAudioGuidanceServices(
every { mapboxVoiceInstructions() } returns mapboxVoiceInstructions
every { mapboxAudioGuidanceVoice(any(), any()) } returns mapboxAudioGuidanceVoice
every { configOwner(any()) } returns carAppConfigOwner
every { dataStoreOwner(any(), any()) } returns dataStoreOwner
every { dataStoreOwner(any()) } returns dataStoreOwner
}

fun emitVoiceInstruction(state: MapboxVoiceInstructions.State) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class MapboxAudioGuidanceTest {
mapboxAudioGuidanceServices.mapboxVoiceInstructions()
}
verifySequence {
mapboxAudioGuidanceServices.dataStoreOwner(any(), any())
mapboxAudioGuidanceServices.dataStoreOwner(any())
mapboxAudioGuidanceServices.configOwner(any())
mapboxAudioGuidanceServices.mapboxAudioGuidanceVoice(any(), "en")
mapboxAudioGuidanceServices.mapboxAudioGuidanceVoice(any(), voiceLanguage)
Expand Down