Fix #11184
This commit is contained in:
parent
432f0e6abd
commit
b42a69e53f
3 changed files with 22 additions and 18 deletions
|
@ -92,6 +92,8 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
|||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_C) {
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
} else if (keyCode == KeyEvent.KEYCODE_D) {
|
||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
|
||||
// Parrot device has only dpad left and right
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||
|
|
|
@ -39,6 +39,8 @@ import java.util.Map;
|
|||
|
||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
||||
OsmAndCompassListener, MapMarkerChangedListener {
|
||||
|
||||
private static final int COMPASS_REQUEST_TIME_INTERVAL_MS = 5000;
|
||||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||
|
||||
private long lastTimeAutoZooming = 0;
|
||||
|
@ -59,6 +61,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
private Float heading;
|
||||
private boolean drivingRegionUpdated = false;
|
||||
private boolean movingToMyLocation = false;
|
||||
private long compassRequest;
|
||||
|
||||
public MapViewTrackingUtilities(OsmandApplication app){
|
||||
this.app = app;
|
||||
|
@ -424,7 +427,22 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
setMapLinkedToLocation(false);
|
||||
}
|
||||
|
||||
public void switchRotateMapMode(){
|
||||
public void switchRotateMapMode() {
|
||||
if (app.getRoutingHelper().isFollowingMode()) {
|
||||
if (compassRequest + COMPASS_REQUEST_TIME_INTERVAL_MS > System.currentTimeMillis()) {
|
||||
compassRequest = 0;
|
||||
switchRotateMapModeImpl();
|
||||
} else {
|
||||
compassRequest = System.currentTimeMillis();
|
||||
app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation));
|
||||
}
|
||||
} else {
|
||||
compassRequest = 0;
|
||||
switchRotateMapModeImpl();
|
||||
}
|
||||
}
|
||||
|
||||
private void switchRotateMapModeImpl(){
|
||||
if (mapView != null) {
|
||||
String rotMode = app.getString(R.string.rotate_map_none_opt);
|
||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) {
|
||||
|
|
|
@ -97,8 +97,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
|
||||
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
|
||||
|
||||
private static final int COMPASS_PRESSED_TIME_INTERVAL_MS = 5000;
|
||||
|
||||
public MapHudButton createHudButton(View iv, int resId, String id) {
|
||||
MapHudButton mc = new MapHudButton();
|
||||
mc.iv = iv;
|
||||
|
@ -139,7 +137,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private MapQuickActionLayer mapQuickActionLayer;
|
||||
private boolean forceShowCompass;
|
||||
private LatLon requestedLatLon;
|
||||
private long compassPressed;
|
||||
private Set<String> themeInfoProviderTags = new HashSet<>();
|
||||
|
||||
public MapControlsLayer(MapActivity activity) {
|
||||
|
@ -292,20 +289,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
compass.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean followingMode = app.getRoutingHelper().isFollowingMode();
|
||||
|
||||
if (followingMode) {
|
||||
if (compassPressed + COMPASS_PRESSED_TIME_INTERVAL_MS > System.currentTimeMillis()) {
|
||||
compassPressed = 0;
|
||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||
} else {
|
||||
compassPressed = System.currentTimeMillis();
|
||||
app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation));
|
||||
}
|
||||
} else {
|
||||
compassPressed = 0;
|
||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||
}
|
||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue