From e2231dd05e2fbfeec48cd6405d914175bc2c40be Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jun 2016 12:04:04 +0300 Subject: [PATCH] Add application modes --- OsmAnd/res/values/strings.xml | 3 ++- OsmAnd/src/net/osmand/plus/ApplicationMode.java | 13 ++++++++++--- .../src/net/osmand/plus/routing/RoutingHelper.java | 9 ++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 106ed8c397..8f5b34b316 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,7 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - + Bus + Train Current track Battery level Change marker\'s position diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java index 9f11d54050..5dc94c8840 100644 --- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java @@ -23,7 +23,7 @@ public class ApplicationMode { public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation(). icon(R.drawable.ic_browse_map, R.drawable.ic_world_globe_dark).reg(); - public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).arrivalDistance(90).carLocation(). + public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).carLocation(). icon(R.drawable.ic_car, R.drawable.ic_action_car_dark).reg(); public static final ApplicationMode BICYCLE = create(R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).bicycleLocation(). @@ -48,10 +48,17 @@ public class ApplicationMode { public static final ApplicationMode TRUCK = create(R.string.app_mode_truck, "truck").speed(15.3f, 40). carLocation().parent(CAR). icon(R.drawable.ic_truck, R.drawable.ic_action_truck_dark).reg(); + + public static final ApplicationMode BUS = create(R.string.app_mode_bus, "bus").speed(15.3f, 40). + carLocation().parent(CAR). + icon(R.drawable.ic_action_bus2, R.drawable.ic_action_bus_dark).reg(); + + public static final ApplicationMode TRAIN = create(R.string.app_mode_train, "train").speed(25f, 40). + carLocation().icon(R.drawable.ic_action_train, R.drawable.ic_action_train).reg(); static { - ApplicationMode[] exceptDefault = new ApplicationMode[] { CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT }; - ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[] { CAR, BICYCLE, BOAT, AIRCRAFT }; + ApplicationMode[] exceptDefault = new ApplicationMode[] { CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN }; + ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[] { CAR, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN }; ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[] { CAR, BICYCLE, PEDESTRIAN }; ApplicationMode[] pedestrian = new ApplicationMode[] { PEDESTRIAN }; ApplicationMode[] pedestrianBicycle = new ApplicationMode[] { PEDESTRIAN, BICYCLE }; diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index bdb8b76c9e..8d5e1eb599 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -472,8 +472,7 @@ public class RoutingHelper { // 2. check if intermediate found if(route.getIntermediatePointsToPass() > 0 - && route.getDistanceToNextIntermediate(lastFixedLocation) < POSITION_TOLERANCE * 2 * settings.ARRIVAL_DISTANCE_FACTOR.get() - && !isRoutePlanningMode) { + && route.getDistanceToNextIntermediate(lastFixedLocation) < getArrivalDistance() * 2f && !isRoutePlanningMode) { showMessage(app.getString(R.string.arrived_at_intermediate_point)); route.passIntermediatePoint(); TargetPointsHelper targets = app.getTargetPointsHelper(); @@ -505,7 +504,7 @@ public class RoutingHelper { // 3. check if destination found Location lastPoint = routeNodes.get(routeNodes.size() - 1); if (currentRoute > routeNodes.size() - 3 - && currentLocation.distanceTo(lastPoint) < (((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.get()) + && currentLocation.distanceTo(lastPoint) < getArrivalDistance() && !isRoutePlanningMode) { //showMessage(app.getString(R.string.arrived_at_destination)); TargetPointsHelper targets = app.getTargetPointsHelper(); @@ -534,6 +533,10 @@ public class RoutingHelper { } return false; } + + private float getArrivalDistance() { + return ((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.get(); + } public boolean identifyUTurnIsNeeded(Location currentLocation, float posTolerance) {