From 11699b247a900448995b5924dd5462449413a5d4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 20 Apr 2012 01:22:31 +0200 Subject: [PATCH] Update view --- .../src/net/osmand/plus/routing/RoutingHelper.java | 14 ++++++++------ OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java | 13 ++++++++++--- .../net/osmand/plus/views/NextTurnInfoControl.java | 8 +++----- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 927664c4b5..b2f9aabdfd 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -70,20 +70,22 @@ public class RoutingHelper { private Handler uiHandler; - public static boolean makeUturnWhenPossible = false; - public static boolean suppressTurnPrompt = false; - public static int turnImminent = 0; + + // TODO vshcherb review ! + private boolean makeUturnWhenPossible = false; + private boolean suppressTurnPrompt = false; + private int turnImminent = 0; private long makeUTwpDetected = 0; - public static boolean makeUturnWhenPossible() { + public boolean makeUturnWhenPossible() { return makeUturnWhenPossible; } - public static boolean suppressTurnPrompt() { + public boolean suppressTurnPrompt() { return suppressTurnPrompt; } - public static int turnImminent() { + public int turnImminent() { return turnImminent; } diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 456d2e8f17..f1c8a31acb 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -6,6 +6,7 @@ import net.osmand.OsmAndFormatter; import net.osmand.osm.LatLon; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper.TurnType; import android.content.Context; @@ -425,17 +426,19 @@ public class MapInfoLayer extends OsmandMapLayer { return miniMapControl; } + private NextTurnInfoControl createNextInfoControl() { + final RoutingHelper routingHelper = routeLayer.getHelper(); final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText) { @Override public boolean updateInfo() { boolean visible = false; - if (routeLayer != null && routeLayer.getHelper().isRouterEnabled() && routeLayer.getHelper().isFollowingMode()) { + if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) { int d = routeLayer.getHelper().getDistanceToNextRouteDirection(); - // Issue 863 - if (routeLayer.getHelper().makeUturnWhenPossible() == true) { + makeUturnWhenPossible = routingHelper.makeUturnWhenPossible(); + if (routingHelper.makeUturnWhenPossible() == true) { if (!showMiniMap) { visible = true; turnType = TurnType.valueOf(TurnType.TU); @@ -465,6 +468,10 @@ public class MapInfoLayer extends OsmandMapLayer { invalidate(); nextTurnDirection = d; } + if(turnImminent != routingHelper.turnImminent()){ + turnImminent = routingHelper.turnImminent(); + invalidate(); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/views/NextTurnInfoControl.java b/OsmAnd/src/net/osmand/plus/views/NextTurnInfoControl.java index a44c556b78..fc5db2de37 100644 --- a/OsmAnd/src/net/osmand/plus/views/NextTurnInfoControl.java +++ b/OsmAnd/src/net/osmand/plus/views/NextTurnInfoControl.java @@ -1,6 +1,7 @@ package net.osmand.plus.views; import net.osmand.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.TurnType; @@ -31,8 +32,8 @@ public class NextTurnInfoControl extends MapInfoControl { private Paint paintBlack; private Paint paintRouteDirection; - private boolean makeUturnWhenPossible; - private int turnImminent; + protected boolean makeUturnWhenPossible; + protected int turnImminent; public NextTurnInfoControl(Context ctx, Paint textPaint, Paint subtextPaint) { super(ctx); @@ -66,7 +67,6 @@ public class NextTurnInfoControl extends MapInfoControl { protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (pathForTurn != null) { - turnImminent = RoutingHelper.turnImminent(); if (turnImminent == 1) { paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_imminent)); } else if (turnImminent == 0) { @@ -85,8 +85,6 @@ public class NextTurnInfoControl extends MapInfoControl { String text = OsmAndFormatter.getFormattedDistance(nextTurnDirection, getContext()); String subtext = null; - // Issue 863: distance "as soon as possible" should be displayed for unscheduled U-turn - makeUturnWhenPossible = RoutingHelper.makeUturnWhenPossible(); if (makeUturnWhenPossible == true) { text = "ASAP"; }