Fix #3692
This commit is contained in:
parent
ef3b497f7b
commit
1c1a6d869b
2 changed files with 23 additions and 19 deletions
|
@ -33,8 +33,8 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
||||||
OsmAndCompassListener, IRouteInformationListener, MapMarkerChangedListener {
|
OsmAndCompassListener, IRouteInformationListener, MapMarkerChangedListener {
|
||||||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||||
|
|
||||||
private long lastTimeAutoZooming = 0;
|
private long lastTimeAutoZooming = 0;
|
||||||
private boolean sensorRegistered = false;
|
private boolean sensorRegistered = false;
|
||||||
private OsmandMapTileView mapView;
|
private OsmandMapTileView mapView;
|
||||||
|
@ -71,12 +71,12 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
|
|
||||||
private void addTargetPointListener(OsmandApplication app) {
|
private void addTargetPointListener(OsmandApplication app) {
|
||||||
app.getTargetPointsHelper().addListener(new StateChangedListener<Void>() {
|
app.getTargetPointsHelper().addListener(new StateChangedListener<Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(Void change) {
|
public void stateChanged(Void change) {
|
||||||
if(mapView != null) {
|
if(mapView != null) {
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
contextMenu.updateCompassValue(val);
|
contextMenu.updateCompassValue(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashboard(DashboardOnMap dashboard) {
|
public void setDashboard(DashboardOnMap dashboard) {
|
||||||
this.dashboard = dashboard;
|
this.dashboard = dashboard;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
||||||
}
|
}
|
||||||
} else if(location != null) {
|
} else if(location != null) {
|
||||||
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null &&
|
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null &&
|
||||||
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
tb.containsLatLon(location.getLatitude(), location.getLongitude()));
|
||||||
registerUnregisterSensor(location);
|
registerUnregisterSensor(location);
|
||||||
}
|
}
|
||||||
|
@ -244,8 +244,8 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
public boolean isShowViewAngle() {
|
public boolean isShowViewAngle() {
|
||||||
return showViewAngle;
|
return showViewAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void switchToRoutePlanningMode() {
|
public void switchToRoutePlanningMode() {
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
routePlanningMode = routingHelper.isRoutePlanningMode();
|
routePlanningMode = routingHelper.isRoutePlanningMode();
|
||||||
|
@ -253,7 +253,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
if(!routePlanningMode && followingMode) {
|
if(!routePlanningMode && followingMode) {
|
||||||
backToLocationImpl();
|
backToLocationImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSettings(){
|
public void updateSettings(){
|
||||||
|
@ -268,7 +268,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
|
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerUnregisterSensor(net.osmand.Location location) {
|
private void registerUnregisterSensor(net.osmand.Location location) {
|
||||||
|
|
||||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||||
|
@ -295,7 +295,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
// check if 17, 18 is correct?
|
// check if 17, 18 is correct?
|
||||||
return zoomDelta;
|
return zoomDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<Integer, Double> autozoom(Location location) {
|
public Pair<Integer, Double> autozoom(Location location) {
|
||||||
if (location.hasSpeed()) {
|
if (location.hasSpeed()) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
@ -328,8 +328,12 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void backToLocationImpl() {
|
public void backToLocationImpl() {
|
||||||
|
backToLocationImpl(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void backToLocationImpl(int zoom) {
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
OsmAndLocationProvider locationProvider = app.getLocationProvider();
|
OsmAndLocationProvider locationProvider = app.getLocationProvider();
|
||||||
if (!isMapLinkedToLocation()) {
|
if (!isMapLinkedToLocation()) {
|
||||||
|
@ -337,7 +341,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
if (locationProvider.getLastKnownLocation() != null) {
|
if (locationProvider.getLastKnownLocation() != null) {
|
||||||
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||||
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
|
||||||
int fZoom = mapView.getZoom() < 15 ? 15 : mapView.getZoom();
|
int fZoom = mapView.getZoom() < zoom ? zoom : mapView.getZoom();
|
||||||
movingToMyLocation = true;
|
movingToMyLocation = true;
|
||||||
thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
||||||
fZoom, false, new Runnable() {
|
fZoom, false, new Runnable() {
|
||||||
|
@ -354,7 +358,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void backToLocationWithDelay(int delay) {
|
private void backToLocationWithDelay(int delay) {
|
||||||
app.runMessageInUIThreadAndCancelPrevious(AUTO_FOLLOW_MSG_ID, new Runnable() {
|
app.runMessageInUIThreadAndCancelPrevious(AUTO_FOLLOW_MSG_ID, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -366,11 +370,11 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
}, delay * 1000);
|
}, delay * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMapLinkedToLocation(){
|
public boolean isMapLinkedToLocation(){
|
||||||
return isMapLinkedToLocation;
|
return isMapLinkedToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapLinkedToLocation(boolean isMapLinkedToLocation) {
|
public void setMapLinkedToLocation(boolean isMapLinkedToLocation) {
|
||||||
if (!isMapLinkedToLocation) {
|
if (!isMapLinkedToLocation) {
|
||||||
int autoFollow = settings.AUTO_FOLLOW_ROUTE.get();
|
int autoFollow = settings.AUTO_FOLLOW_ROUTE.get();
|
||||||
|
@ -380,13 +384,13 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
}
|
}
|
||||||
this.isMapLinkedToLocation = isMapLinkedToLocation;
|
this.isMapLinkedToLocation = isMapLinkedToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void locationChanged(double newLatitude, double newLongitude, Object source) {
|
public void locationChanged(double newLatitude, double newLongitude, Object source) {
|
||||||
// when user start dragging
|
// when user start dragging
|
||||||
setMapLinkedToLocation(false);
|
setMapLinkedToLocation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchRotateMapMode(){
|
public void switchRotateMapMode(){
|
||||||
String rotMode = app.getString(R.string.rotate_map_none_opt);
|
String rotMode = app.getString(R.string.rotate_map_none_opt);
|
||||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) {
|
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) {
|
||||||
|
|
|
@ -663,7 +663,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
touchEvent = 0;
|
touchEvent = 0;
|
||||||
app.logEvent(mapActivity, "start_navigation");
|
app.logEvent(mapActivity, "start_navigation");
|
||||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(17);
|
||||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||||
routingHelper.setFollowingMode(true);
|
routingHelper.setFollowingMode(true);
|
||||||
routingHelper.setRoutePlanningMode(false);
|
routingHelper.setRoutePlanningMode(false);
|
||||||
|
|
Loading…
Reference in a new issue