From b42a69e53f27d54955b82d959f83a5ef9708d609 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 1 Apr 2021 19:34:03 +0300 Subject: [PATCH 1/3] Fix #11184 --- .../activities/MapActivityKeyListener.java | 2 ++ .../plus/base/MapViewTrackingUtilities.java | 20 ++++++++++++++++++- .../plus/views/layers/MapControlsLayer.java | 18 +---------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java index 46ce19e3c2..08004ec9ab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityKeyListener.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 14a6623eae..d220b8bec1 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 22c077f02d..a4158feced 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -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 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(); } }); From 98887aba71a56349487d5fc55adeb41a960970a7 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 2 Apr 2021 16:24:58 +0300 Subject: [PATCH 2/3] Remove phrase --- OsmAnd/res/values/phrases.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index bfe9be1e13..fe727f7ad7 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -284,7 +284,6 @@ Ship chandler Sporting goods Stationery store - Tableware store Ticket sales Tobacco store Toyshop From 1a18eb5b58a332103c70c0cedae9fa10e4bcd99c Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 2 Apr 2021 17:24:17 +0300 Subject: [PATCH 3/3] Add missing phrase (fix https://github.com/osmandapp/OsmAnd/issues/11322) --- OsmAnd/res/values/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index fe727f7ad7..10ea9f7ae6 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4378,4 +4378,6 @@ Horseshoes Kickboxing + Diplomatic office +