From 29c28aab0cc22a8c98c0d52a027b1a524639be9b Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 20 Jun 2019 15:55:21 +0300 Subject: [PATCH 1/2] Add ui check for map orientation change in following mode --- OsmAnd/res/values/strings.xml | 1 + .../src/net/osmand/plus/views/MapControlsLayer.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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..40491a8855 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,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)); + } } }); From 503ba1c08740332247933e79139832a0f2046479 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 21 Jun 2019 11:24:16 +0300 Subject: [PATCH 2/2] refactor check for compass pressed --- .../src/net/osmand/plus/views/MapControlsLayer.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 40491a8855..692c6e06f1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -276,12 +276,17 @@ public class MapControlsLayer extends OsmandMapLayer { public void onClick(View v) { boolean followingMode = app.getRoutingHelper().isFollowingMode(); - if (compassPressed + COMPASS_PRESSED_TIME_INTERVAL_MS > System.currentTimeMillis() || !followingMode) { + 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(); - } else { - compassPressed = System.currentTimeMillis(); - app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation)); } } });