diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 982d13e8b0..910c3c8d48 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Press again to change the map orientation OsmAnd downloading service Magenta Icon diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index b1a8c0591f..692c6e06f1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -79,6 +79,8 @@ 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; @@ -120,6 +122,7 @@ public class MapControlsLayer extends OsmandMapLayer { private MapQuickActionLayer mapQuickActionLayer; private boolean forceShowCompass; private LatLon requestedLatLon; + private long compassPressed; public MapControlsLayer(MapActivity activity) { this.mapActivity = activity; @@ -271,7 +274,20 @@ public class MapControlsLayer extends OsmandMapLayer { compass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); + 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(); + } } });