Add ui check for map orientation change in following mode

This commit is contained in:
Chumva 2019-06-20 15:55:21 +03:00
parent fd0c061cbf
commit 29c28aab0c
2 changed files with 13 additions and 1 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="press_again_to_change_the_map_orientation">Press again to change the map orientation</string>
<string name="process_downloading_service">OsmAnd downloading service</string>
<string name="shared_string_color_magenta">Magenta</string>
<string name="shared_string_icon">Icon</string>

View file

@ -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,15 @@ 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 (compassPressed + COMPASS_PRESSED_TIME_INTERVAL_MS > System.currentTimeMillis() || !followingMode) {
compassPressed = 0;
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
} else {
compassPressed = System.currentTimeMillis();
app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation));
}
}
});