diff --git a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java index c8a1f52a5fc..b4c03ef5457 100644 --- a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java +++ b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java @@ -215,7 +215,7 @@ public void onStart(@NonNull LifecycleOwner owner) { @Override public void onResume(@NonNull LifecycleOwner owner) { if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated()) { - startNavigation(); + startNavigationScreen(); // updateCarNavigation(routingHelper.getLastFixedLocation()); } else { showRoutePreview(); @@ -377,7 +377,7 @@ private void processNavigationIntent(@NonNull Uri uri) { if (obj != null) { getApp().getOsmandMap().getMapLayers().getMapActionsHelper().startNavigation(); if (hasStarted()) { - startNavigation(); + startNavigationScreen(); } } }); @@ -419,7 +419,7 @@ public boolean requestLocationNavigation() { return requestLocationPermission(); } - public void startNavigation() { + public void startNavigationScreen() { if (navigationScreen != null) { CarContext context = getCarContext(); ScreenManager screenManager = context.getCarService(ScreenManager.class); @@ -432,8 +432,11 @@ public void startNavigation() { navigationScreen = new NavigationScreen(getCarContext(), settingsAction, this); navigationCarSurface.setCallback(navigationScreen); } - startCarNavigation(); getCarContext().getCarService(ScreenManager.class).push(navigationScreen); + // navigation already started + if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated() && !carNavigationActive) { + startCarNavigation(); + } } @@ -512,7 +515,7 @@ private void showRoutePreview() { if (obj != null) { app.getOsmandMap().getMapLayers().getMapActionsHelper().startNavigation(); if (hasStarted()) { - startNavigation(); + startNavigationScreen(); } } }); @@ -674,7 +677,7 @@ public void updateCarNavigation(Location currentLocation) { if (carNavigationSession != null) { NavigationScreen navigationScreen = carNavigationSession.getNavigationScreen(); if (navigationScreen == null) { - carNavigationSession.startNavigation(); + carNavigationSession.startNavigationScreen(); navigationScreen = carNavigationSession.getNavigationScreen(); } if (navigationScreen != null) { diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt b/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt index ebfe74795d2..f91ff0b7f7c 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt +++ b/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt @@ -70,7 +70,7 @@ abstract class BaseAndroidAutoScreen(carContext: CarContext) : Screen(carContext private fun startNavigation() { app.osmandMap.mapLayers.mapActionsHelper.startNavigation() val session = app.carNavigationSession - session?.startNavigation() + session?.startNavigationScreen() } protected fun createSearchAction() = Action.Builder() diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/FavoritesScreen.java b/OsmAnd/src/net/osmand/plus/auto/screens/FavoritesScreen.java index 3f69bc3619f..ddf072a85ed 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/FavoritesScreen.java +++ b/OsmAnd/src/net/osmand/plus/auto/screens/FavoritesScreen.java @@ -21,7 +21,6 @@ import androidx.car.app.navigation.model.PlaceListNavigationTemplate; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.IconCompat; -import androidx.lifecycle.DefaultLifecycleObserver; import androidx.lifecycle.LifecycleOwner; import net.osmand.data.FavouritePoint; @@ -31,8 +30,6 @@ import net.osmand.plus.auto.NavigationSession; import net.osmand.plus.auto.TripUtils; import net.osmand.plus.myplaces.favorites.FavoriteGroup; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.enums.CompassMode; import net.osmand.plus.utils.AndroidUtils; import net.osmand.plus.views.PointImageUtils; import net.osmand.plus.views.layers.FavouritesLayer; @@ -161,7 +158,7 @@ private void onRouteSelected(@NonNull SearchResult sr) { getApp().getOsmandMap().getMapLayers().getMapActionsHelper().startNavigation(); NavigationSession session = getApp().getCarNavigationSession(); if (session != null && session.hasStarted()) { - session.startNavigation(); + session.startNavigationScreen(); } } diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/LandingScreen.kt b/OsmAnd/src/net/osmand/plus/auto/screens/LandingScreen.kt index 15e15b4b19e..0b31611dfd9 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/LandingScreen.kt +++ b/OsmAnd/src/net/osmand/plus/auto/screens/LandingScreen.kt @@ -126,7 +126,7 @@ class LandingScreen( if (app.routingHelper.isRouteCalculated) { app.routingHelper.resumeNavigation() } - carNavigationSession.startNavigation() + carNavigationSession.startNavigationScreen() // duplicate code from startNavigation // val navigationScreen = carNavigationSession.navigationScreen // navigationScreen?.let {