Merge pull request #7071 from osmandapp/CompassControlsImprovements

Add ui check for map orientation change in following mode
This commit is contained in:
Alexey 2019-06-21 11:47:10 +03:00 committed by GitHub
commit 44c89a1913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy 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="process_downloading_service">OsmAnd downloading service</string>
<string name="shared_string_color_magenta">Magenta</string> <string name="shared_string_color_magenta">Magenta</string>
<string name="shared_string_icon">Icon</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_NAVIGATION_FAB_PERMISSION = 201;
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; 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) { public MapHudButton createHudButton(View iv, int resId, String id) {
MapHudButton mc = new MapHudButton(); MapHudButton mc = new MapHudButton();
mc.iv = iv; mc.iv = iv;
@ -120,6 +122,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private MapQuickActionLayer mapQuickActionLayer; private MapQuickActionLayer mapQuickActionLayer;
private boolean forceShowCompass; private boolean forceShowCompass;
private LatLon requestedLatLon; private LatLon requestedLatLon;
private long compassPressed;
public MapControlsLayer(MapActivity activity) { public MapControlsLayer(MapActivity activity) {
this.mapActivity = activity; this.mapActivity = activity;
@ -271,7 +274,20 @@ public class MapControlsLayer extends OsmandMapLayer {
compass.setOnClickListener(new View.OnClickListener() { compass.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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();
}
} }
}); });