diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt b/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt index 63b17a67fa9..68edb601a8f 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt +++ b/OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt @@ -51,7 +51,6 @@ abstract class BaseAndroidAutoScreen(carContext: CarContext) : Screen(carContext RoutePreviewScreen(carContext, settingsAction, result, true) ) { obj: Any? -> obj?.let { - onSearchResultSelected(result) startNavigation() finish() } @@ -64,9 +63,7 @@ abstract class BaseAndroidAutoScreen(carContext: CarContext) : Screen(carContext private fun startNavigation() { app.osmandMap.mapLayers.mapActionsHelper.startNavigation() val session = app.carNavigationSession - if (session != null && session.hasStarted()) { - session.startNavigation() - } + session?.startNavigation() } protected fun createSearchAction() = Action.Builder() @@ -99,9 +96,10 @@ abstract class BaseAndroidAutoScreen(carContext: CarContext) : Screen(carContext if (!mapRect.hasInitialState()) { val mapView = app.osmandMap.mapView val tb = mapView.rotatedTileBox - tb.setCenterLocation(tb.centerPixelX.toFloat() / tb.pixWidth, 0.5f ) + tb.setCenterLocation(tb.centerPixelX.toFloat() / tb.pixWidth, 0.5f) tb.rotate = 0f; - mapView.fitRectToMap(tb, + mapView.fitRectToMap( + tb, mapRect.left, mapRect.right, mapRect.top, mapRect.bottom, 0, 0, true, true ) diff --git a/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java b/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java index 0c8383c61ec..6866431dd03 100644 --- a/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java +++ b/OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java @@ -2,8 +2,6 @@ import static net.osmand.search.core.ObjectType.GPX_TRACK; -import android.os.Handler; -import android.os.Looper; import android.text.SpannableString; import androidx.annotation.NonNull; @@ -37,7 +35,6 @@ import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.settings.enums.CompassMode; -import net.osmand.plus.shared.SharedUtil; import net.osmand.plus.track.data.GPXInfo; import net.osmand.plus.track.helpers.GpxFileLoaderTask; import net.osmand.plus.track.helpers.SelectedGpxFile; @@ -98,7 +95,6 @@ public RoutePreviewScreen(@NonNull CarContext carContext, @NonNull Action settin this.searchResult = searchResult; this.calculateRoute = calculateRoute; getLifecycle().addObserver(this); - calculating = calculateRoute; } private void prepareRoute() { @@ -147,21 +143,20 @@ private void updateRoute(boolean newRoute) { String title = Algorithms.isEmpty(name) ? typeName : name; routeRows.add(new Row.Builder().setTitle(title).addText(description).build()); this.routeRows = routeRows; - calculating = app.getRoutingHelper().isRouteBeingCalculated(); invalidate(); } } @Override public void onCreate(@NonNull LifecycleOwner owner) { - OsmandApplication app = getApp(); - app.getRoutingHelper().addListener(this); - app.getTargetPointsHelper().addListener(stateChangedListener); - prevMapLinkedToLocation = app.getMapViewTrackingUtilities().isMapLinkedToLocation(); - OsmandMapTileView mapView = app.getOsmandMap().getMapView(); - savedCompassMode = app.getSettings().getCompassMode(); + getApp().getRoutingHelper().addListener(this); + getApp().getTargetPointsHelper().addListener(stateChangedListener); + prevMapLinkedToLocation = getApp().getMapViewTrackingUtilities().isMapLinkedToLocation(); + OsmandMapTileView mapView = getApp().getOsmandMap().getMapView(); + savedCompassMode = getApp().getSettings().getCompassMode(); prevZoom = mapView.getBaseZoom(); prevRotationAngle = mapView.getRotate(); + getApp().getSettings().setCompassMode(CompassMode.NORTH_IS_UP); prevElevationAngle = mapView.normalizeElevationAngle(mapView.getElevationAngle()); NavigationSession navigationSession = getSession(); if (calculateRoute) { @@ -226,7 +221,7 @@ public Template onGetTemplate() { listBuilder.addItem(row); } RoutePreviewNavigationTemplate.Builder builder = new RoutePreviewNavigationTemplate.Builder(); - if (calculating) { + if (getApp().getRoutingHelper().isRouteBeingCalculated()) { builder.setLoading(true); } else { builder.setLoading(false); @@ -282,11 +277,13 @@ public void routeWasCancelled() { public void routeWasFinished() { } - @Override protected void adjustMapToRect(@NonNull LatLon location, @NonNull QuadRect mapRect) { -// OsmandMapTileView mapView = getApp().getOsmandMap().getMapView(); -// mapView.setElevationAngle(90f); + OsmandMapTileView mapView = getApp().getOsmandMap().getMapView(); + mapView.setElevationAngle(90f); + getApp().getMapViewTrackingUtilities().setMapLinkedToLocation(false); + mapView.setRotate(0f, true); super.adjustMapToRect(location, mapRect); + getApp().getMapViewTrackingUtilities().getMapDisplayPositionManager().updateMapDisplayPosition(); } }