From f411eaf2dd6979d3d9820b8f333df87f3e1b12bd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 7 Sep 2012 15:08:36 +0200 Subject: [PATCH 1/3] Fix metrics fix --- OsmAnd/src/net/osmand/OsmAndFormatter.java | 16 ++++++++++++---- .../plus/parkingpoint/ParkingPositionPlugin.java | 2 +- .../net/osmand/plus/views/RouteInfoControls.java | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/OsmAndFormatter.java b/OsmAnd/src/net/osmand/OsmAndFormatter.java index be81463f3b..fd2a98aae1 100644 --- a/OsmAnd/src/net/osmand/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/OsmAndFormatter.java @@ -104,15 +104,23 @@ public class OsmAndFormatter { if (kmh >= 15 || (am == ApplicationMode.CAR)) { return ((int) kmh) + " " + ctx.getString(R.string.km_h); } - kmh = ((int) kmh * 10f) / 10f; - return kmh + " " + ctx.getString(R.string.km_h); + int kmh10 = (int) (kmh * 10f); + if (kmh10 % 10 == 0) { + return (kmh10 / 10) + " " + ctx.getString(R.string.km_h); + } else { + return (kmh10 / 10f) + " " + ctx.getString(R.string.km_h); + } } else { float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE; if (mph >= 10) { return ((int) (mph)) + " " + ctx.getString(R.string.mile_per_hour); } else { - mph = ((int) mph * 10f) / 10f; - return mph + " " + ctx.getString(R.string.mile_per_hour); + int mph10 = (int) (mph * 10f); + if(mph10 % 10 == 0) { + return (mph10 / 10) + " " + ctx.getString(R.string.mile_per_hour); + } else { + return (mph10 / 10f) + " " + ctx.getString(R.string.mile_per_hour); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index e4876794d1..b45def4450 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -409,7 +409,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { * @return */ private boolean distChanged(int oldDist, int dist){ - if(oldDist != 0 && oldDist - dist < 30){ + if(oldDist != 0 && Math.abs(oldDist - dist) > 30){ return false; } return true; diff --git a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java index e797fc4023..f7bd4e9766 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java @@ -603,7 +603,7 @@ public class RouteInfoControls { public boolean distChanged(int oldDist, int dist){ - if(oldDist != 0 && oldDist - dist < 10){ + if(oldDist != 0 && Math.abs(oldDist - dist) > 10){ return false; } return true; From 383c14aa6effc860d6993056669daf57c28acea6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 7 Sep 2012 15:14:42 +0200 Subject: [PATCH 2/3] Fix metrics fix --- .../src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index b45def4450..a823b937e4 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -409,7 +409,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { * @return */ private boolean distChanged(int oldDist, int dist){ - if(oldDist != 0 && Math.abs(oldDist - dist) > 30){ + if(oldDist != 0 && Math.abs(oldDist - dist) < 30){ return false; } return true; diff --git a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java index f7bd4e9766..91e91a3e74 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java @@ -603,7 +603,7 @@ public class RouteInfoControls { public boolean distChanged(int oldDist, int dist){ - if(oldDist != 0 && Math.abs(oldDist - dist) > 10){ + if(oldDist != 0 && Math.abs(oldDist - dist) < 10){ return false; } return true; From fb81616a16664fe95e88faacaf54c05b0b92b6b0 Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 7 Sep 2012 18:37:05 +0200 Subject: [PATCH 3/3] Fix bug where PREV_APPLICATION_MODE is incorrectly overwritten --- .../net/osmand/plus/activities/MapActivityActions.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 5f9c36d46d..f1c0da5fef 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -463,7 +463,10 @@ public class MapActivityActions implements DialogProvider { return; } routingHelper.setAppMode(mode); - settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); + // Do not overwrite PREV_APPLICATION_MODE if already navigating + if (!routingHelper.isFollowingMode()) { + settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); + } settings.FOLLOW_THE_ROUTE.set(false); settings.FOLLOW_THE_GPX_ROUTE.set(null); routingHelper.setFollowingMode(false); @@ -492,7 +495,10 @@ public class MapActivityActions implements DialogProvider { } ApplicationMode mode = getAppMode(buttons, settings); // change global settings - settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); + // Do not overwrite PREV_APPLICATION_MODE if already navigating + if (!routingHelper.isFollowingMode()) { + settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); + } boolean changed = settings.APPLICATION_MODE.set(mode); if (changed) { mapActivity.updateApplicationModeSettings();