Merge pull request #11317 from osmandapp/Fix_11184

Fix #11184
This commit is contained in:
Vitaliy 2021-04-02 09:29:33 +03:00 committed by GitHub
commit adf6f49266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View file

@ -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) {

View file

@ -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;
@ -425,6 +428,21 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
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) {

View file

@ -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();
}
}
});