Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aa zoom #21347

Open
wants to merge 14 commits into
base: r4.9
Choose a base branch
from
10 changes: 4 additions & 6 deletions OsmAnd/src/net/osmand/plus/auto/screens/BaseAndroidAutoScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ abstract class BaseAndroidAutoScreen(carContext: CarContext) : Screen(carContext
RoutePreviewScreen(carContext, settingsAction, result, true)
) { obj: Any? ->
obj?.let {
onSearchResultSelected(result)
startNavigation()
finish()
}
Expand All @@ -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()
Expand Down Expand Up @@ -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
)
Expand Down
27 changes: 12 additions & 15 deletions OsmAnd/src/net/osmand/plus/auto/screens/RoutePreviewScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}
Loading