saving elevation angle state

This commit is contained in:
veliymolfar 2020-01-14 11:34:44 +02:00
parent e0e99057d4
commit 8e12147196
4 changed files with 28 additions and 2 deletions

View file

@ -2288,6 +2288,7 @@ public class OsmandSettings {
public static final String LAST_KNOWN_MAP_LAT = "last_known_map_lat"; //$NON-NLS-1$ public static final String LAST_KNOWN_MAP_LAT = "last_known_map_lat"; //$NON-NLS-1$
public static final String LAST_KNOWN_MAP_LON = "last_known_map_lon"; //$NON-NLS-1$ public static final String LAST_KNOWN_MAP_LON = "last_known_map_lon"; //$NON-NLS-1$
public static final String LAST_KNOWN_MAP_ZOOM = "last_known_map_zoom"; //$NON-NLS-1$ public static final String LAST_KNOWN_MAP_ZOOM = "last_known_map_zoom"; //$NON-NLS-1$
public static final String LAST_KNOWN_MAP_ELEVATION = "last_known_map_elevation"; //$NON-NLS-1$
public static final String MAP_LABEL_TO_SHOW = "map_label_to_show"; //$NON-NLS-1$ public static final String MAP_LABEL_TO_SHOW = "map_label_to_show"; //$NON-NLS-1$
public static final String MAP_LAT_TO_SHOW = "map_lat_to_show"; //$NON-NLS-1$ public static final String MAP_LAT_TO_SHOW = "map_lat_to_show"; //$NON-NLS-1$
@ -2401,6 +2402,14 @@ public class OsmandSettings {
settingsAPI.edit(globalPreferences).putInt(LAST_KNOWN_MAP_ZOOM, zoom).commit(); settingsAPI.edit(globalPreferences).putInt(LAST_KNOWN_MAP_ZOOM, zoom).commit();
} }
public float getLastKnownMapElevation() {
return settingsAPI.getFloat(globalPreferences, LAST_KNOWN_MAP_ELEVATION, 90);
}
public void setLastKnownMapElevation(float elevation) {
settingsAPI.edit(globalPreferences).putFloat(LAST_KNOWN_MAP_ELEVATION, elevation).commit();
}
public final static String POINT_NAVIGATE_LAT = "point_navigate_lat"; //$NON-NLS-1$ public final static String POINT_NAVIGATE_LAT = "point_navigate_lat"; //$NON-NLS-1$
public final static String POINT_NAVIGATE_LON = "point_navigate_lon"; //$NON-NLS-1$ public final static String POINT_NAVIGATE_LON = "point_navigate_lon"; //$NON-NLS-1$
public final static String POINT_NAVIGATE_ROUTE = "point_navigate_route_integer"; //$NON-NLS-1$ public final static String POINT_NAVIGATE_ROUTE = "point_navigate_route_integer"; //$NON-NLS-1$

View file

@ -475,7 +475,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
OsmAndMapLayersView ml = (OsmAndMapLayersView) findViewById(R.id.MapLayersView); OsmAndMapLayersView ml = (OsmAndMapLayersView) findViewById(R.id.MapLayersView);
ml.setVisibility(View.VISIBLE); ml.setVisibility(View.VISIBLE);
atlasMapRendererView.setAzimuth(0); atlasMapRendererView.setAzimuth(0);
atlasMapRendererView.setElevationAngle(90); atlasMapRendererView.setElevationAngle(app.getSettings().getLastKnownMapElevation());
NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView); NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
ml.setMapView(mapView); ml.setMapView(mapView);
mapViewTrackingUtilities.setMapView(mapView); mapViewTrackingUtilities.setMapView(mapView);
@ -1497,6 +1497,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
settings.setLastKnownMapZoom(mapView.getZoom()); settings.setLastKnownMapZoom(mapView.getZoom());
settings.setLastKnownMapElevation(mapView.getElevationAngle());
settings.MAP_ACTIVITY_ENABLED.set(false); settings.MAP_ACTIVITY_ENABLED.set(false);
app.getResourceManager().interruptRendering(); app.getResourceManager().interruptRendering();
OsmandPlugin.onMapActivityPause(this); OsmandPlugin.onMapActivityPause(this);

View file

@ -38,6 +38,8 @@ public class MultiTouchSupport {
public void onActionCancel(); public void onActionCancel();
public void onChangingViewAngle(float angle); public void onChangingViewAngle(float angle);
public void onChangeViewAngleStarted();
} }
private boolean multiTouchAPISupported = false; private boolean multiTouchAPISupported = false;
@ -165,6 +167,7 @@ public class MultiTouchSupport {
&& dy1 > TILT_Y_THRESHOLD_PX && dy2 > TILT_Y_THRESHOLD_PX && dy1 > TILT_Y_THRESHOLD_PX && dy2 > TILT_Y_THRESHOLD_PX
&& startDy < TILT_Y_THRESHOLD_PX * 6 && startDy < TILT_Y_THRESHOLD_PX * 6
&& Math.abs(dy2 - dy1) < TILT_DY_THRESHOLD_PX) { && Math.abs(dy2 - dy1) < TILT_DY_THRESHOLD_PX) {
listener.onChangeViewAngleStarted();
inTiltMode = true; inTiltMode = true;
} else if (dx1 > TILT_X_THRESHOLD_PX || dx2 > TILT_X_THRESHOLD_PX } else if (dx1 > TILT_X_THRESHOLD_PX || dx2 > TILT_X_THRESHOLD_PX
|| Math.abs(dy2 - dy1) > TILT_DY_THRESHOLD_PX || Math.abs(dy2 - dy1) > TILT_DY_THRESHOLD_PX

View file

@ -186,6 +186,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private long multiTouchStartTime; private long multiTouchStartTime;
private long multiTouchEndTime; private long multiTouchEndTime;
private boolean wasZoomInMultiTouch; private boolean wasZoomInMultiTouch;
private float elevationAngle;
public OsmandMapTileView(MapActivity activity, int w, int h) { public OsmandMapTileView(MapActivity activity, int w, int h) {
this.activity = activity; this.activity = activity;
@ -257,6 +258,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
} }
}; };
elevationAngle = settings.getLastKnownMapElevation();
} }
public void setView(View view) { public void setView(View view) {
@ -439,6 +441,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return currentViewport.getZoom(); return currentViewport.getZoom();
} }
public float getElevationAngle() {
return elevationAngle;
}
public double getZoomFractionalPart() { public double getZoomFractionalPart() {
return currentViewport.getZoomFloatPart(); return currentViewport.getZoomFloatPart();
} }
@ -1127,6 +1133,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private LatLon initialCenterLatLon; private LatLon initialCenterLatLon;
private boolean startRotating = false; private boolean startRotating = false;
private static final float ANGLE_THRESHOLD = 30; private static final float ANGLE_THRESHOLD = 30;
private float initialElevation;
@Override @Override
public void onZoomOrRotationEnded(double relativeToStart, float angleRelative) { public void onZoomOrRotationEnded(double relativeToStart, float angleRelative) {
@ -1201,7 +1208,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
@Override @Override
public void onChangingViewAngle(float angle) { public void onChangingViewAngle(float angle) {
setElevationAngle(angle); setElevationAngle(initialElevation - angle);
}
@Override
public void onChangeViewAngleStarted() {
initialElevation = elevationAngle;
} }
@Override @Override
@ -1298,6 +1310,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} else if (angle > 90f) { } else if (angle > 90f) {
angle = 90f; angle = 90f;
} }
this.elevationAngle = angle;
((MapActivity) activity).setMapElevation(angle); ((MapActivity) activity).setMapElevation(angle);
} }