diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/config/NavigationViewComponentBuilder.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/config/NavigationViewComponentBuilder.kt index d3fd8568..557518ef 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/config/NavigationViewComponentBuilder.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/config/NavigationViewComponentBuilder.kt @@ -19,14 +19,16 @@ import com.stadiamaps.ferrostar.composeui.views.components.TripProgressView import com.stadiamaps.ferrostar.core.NavigationUiState data class NavigationViewComponentBuilder( - val instructionsView: @Composable (modifier: Modifier, uiState: NavigationUiState) -> Unit, - val progressView: + internal val instructionsView: + @Composable + (modifier: Modifier, uiState: NavigationUiState) -> Unit, + internal val progressView: @Composable (modifier: Modifier, uiState: NavigationUiState, onTapExit: (() -> Unit)?) -> Unit, - val streetNameView: + internal val streetNameView: @Composable (modifier: Modifier, roadName: String?, cameraControlState: CameraControlState) -> Unit, - val customOverlayView: @Composable (BoxScope.(Modifier) -> Unit)? = null, + internal val customOverlayView: @Composable (BoxScope.(Modifier) -> Unit)? = null, // TODO: We may reasonably be able to add the NavigationMapView here. But not sure how much // value that would add // since most of the hard config already exists within the overlay views which are not @@ -72,6 +74,8 @@ data class NavigationViewComponentBuilder( } }) } + + fun getCustomOverlayView(): @Composable (BoxScope.(Modifier) -> Unit)? = customOverlayView } fun NavigationViewComponentBuilder.withInstructionsView( diff --git a/android/core/src/main/java/com/stadiamaps/ferrostar/core/annotation/SpeedSerializationAdapter.kt b/android/core/src/main/java/com/stadiamaps/ferrostar/core/annotation/SpeedSerializationAdapter.kt index a7bcf136..570a8f21 100644 --- a/android/core/src/main/java/com/stadiamaps/ferrostar/core/annotation/SpeedSerializationAdapter.kt +++ b/android/core/src/main/java/com/stadiamaps/ferrostar/core/annotation/SpeedSerializationAdapter.kt @@ -18,7 +18,7 @@ class SpeedSerializationAdapter : JsonAdapter() { is Speed.NoLimit -> writer.name("none").value(true) is Speed.Unknown -> writer.name("unknown").value(true) is Speed.Value -> - writer.name("value").value(speed.value).name("unit").value(speed.unit.text) + writer.name("speed").value(speed.value).name("unit").value(speed.unit.text) } writer.endObject() } @@ -33,7 +33,7 @@ class SpeedSerializationAdapter : JsonAdapter() { var unit: String? = null while (reader.hasNext()) { - when (reader.selectName(JsonReader.Options.of("none", "unknown", "value", "unit"))) { + when (reader.selectName(JsonReader.Options.of("none", "unknown", "speed", "unit"))) { 0 -> none = reader.nextBoolean() 1 -> unknown = reader.nextBoolean() 2 -> value = reader.nextDouble() diff --git a/android/demo-app/src/main/java/com/stadiamaps/ferrostar/DemoNavigationViewModel.kt b/android/demo-app/src/main/java/com/stadiamaps/ferrostar/DemoNavigationViewModel.kt index 84e6e2c2..1384ab76 100644 --- a/android/demo-app/src/main/java/com/stadiamaps/ferrostar/DemoNavigationViewModel.kt +++ b/android/demo-app/src/main/java/com/stadiamaps/ferrostar/DemoNavigationViewModel.kt @@ -1,13 +1,14 @@ package com.stadiamaps.ferrostar import android.util.Log -import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.stadiamaps.ferrostar.core.DefaultNavigationViewModel import com.stadiamaps.ferrostar.core.FerrostarCore import com.stadiamaps.ferrostar.core.LocationProvider import com.stadiamaps.ferrostar.core.LocationUpdateListener import com.stadiamaps.ferrostar.core.NavigationUiState -import com.stadiamaps.ferrostar.core.NavigationViewModel +import com.stadiamaps.ferrostar.core.annotation.AnnotationPublisher +import com.stadiamaps.ferrostar.core.annotation.valhalla.valhallaExtendedOSRMAnnotationPublisher import com.stadiamaps.ferrostar.core.isNavigating import java.util.concurrent.Executors import kotlinx.coroutines.flow.MutableStateFlow @@ -24,7 +25,8 @@ import uniffi.ferrostar.UserLocation class DemoNavigationViewModel( // This is a simple example, but these would typically be dependency injected private val ferrostarCore: FerrostarCore = AppModule.ferrostarCore, -) : ViewModel(), LocationUpdateListener, NavigationViewModel { + annotationPublisher: AnnotationPublisher<*> = valhallaExtendedOSRMAnnotationPublisher() +) : DefaultNavigationViewModel(ferrostarCore, annotationPublisher), LocationUpdateListener { private val locationStateFlow = MutableStateFlow(null) private val executor = Executors.newSingleThreadScheduledExecutor() diff --git a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/DynamicallyOrientingNavigationView.kt b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/DynamicallyOrientingNavigationView.kt index 96ea05e9..2af4e2c1 100644 --- a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/DynamicallyOrientingNavigationView.kt +++ b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/DynamicallyOrientingNavigationView.kt @@ -140,7 +140,7 @@ fun DynamicallyOrientingNavigationView( } } - views.customOverlayView?.let { customOverlayView -> + views.getCustomOverlayView()?.let { customOverlayView -> customOverlayView(Modifier.windowInsetsPadding(WindowInsets.systemBars).padding(gridPadding)) } } diff --git a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/LandscapeNavigationView.kt b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/LandscapeNavigationView.kt index 8a28bfe6..295654e0 100644 --- a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/LandscapeNavigationView.kt +++ b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/LandscapeNavigationView.kt @@ -112,7 +112,7 @@ fun LandscapeNavigationView( mapViewInsets = mapViewInsets, onTapExit = onTapExit) - views.customOverlayView?.let { customOverlayView -> + views.getCustomOverlayView()?.let { customOverlayView -> customOverlayView(Modifier.windowInsetsPadding(WindowInsets.systemBars).padding(gridPadding)) } } diff --git a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/PortraitNavigationView.kt b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/PortraitNavigationView.kt index f7e29ea2..0daa8363 100644 --- a/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/PortraitNavigationView.kt +++ b/android/maplibreui/src/main/java/com/stadiamaps/ferrostar/maplibreui/views/PortraitNavigationView.kt @@ -123,7 +123,7 @@ fun PortraitNavigationView( mapViewInsets = mapViewInsets, onTapExit = onTapExit) - views.customOverlayView?.let { customOverlayView -> + views.getCustomOverlayView()?.let { customOverlayView -> customOverlayView( Modifier.windowInsetsPadding(WindowInsets.systemBars).padding(gridPadding)) }