public NextTurnInfoWidget createNextInfoControl( final Activity activity, final OsmandApplication app, boolean horisontalMini) { final OsmandSettings settings = app.getSettings(); final RoutingHelper routingHelper = app.getRoutingHelper(); final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) { NextDirectionInfo calc1 = new NextDirectionInfo(); @Override public boolean updateInfo(DrawSettings drawSettings) { boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating(); TurnType turnType = null; boolean deviatedFromRoute = false; int turnImminent = 0; int nextTurnDistance = 0; if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) { deviatedFromRoute = routingHelper.isDeviatedFromRoute(); if (deviatedFromRoute) { turnImminent = 0; turnType = TurnType.valueOf(TurnType.OFFR, settings.DRIVING_REGION.get().leftHandDriving); setDeviatePath((int) routingHelper.getRouteDeviation()); } else { NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true); if (r != null && r.distanceTo > 0 && r.directionInfo != null) { turnType = r.directionInfo.getTurnType(); nextTurnDistance = r.distanceTo; turnImminent = r.imminent; } } } setTurnType(turnType); setTurnImminent(turnImminent, deviatedFromRoute); setTurnDistance(nextTurnDistance); return true; } }; nextTurnInfo.setOnClickListener( new View.OnClickListener() { // int i = 0; // boolean leftSide = false; @Override public void onClick(View v) { // for test rendering purposes // final int l = TurnType.predefinedTypes.length; // final int exits = 5; // i++; // if (i % (l + exits) >= l ) { // nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1), // leftSide); // float a = leftSide? -180 + (i % (l + exits) - l + 1) * 50: 180 - (i % (l + // exits) - l + 1) * 50; // nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a); // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+""; // } else { // nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % // (TurnType.predefinedTypes.length + exits)], leftSide); // nextTurnInfo.exitOut = ""; // } // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; // nextTurnInfo.nextTurnDirection = 580; // TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, // nextTurnInfo.turnType,nextTurnInfo.pathTransform); if (routingHelper.isRouteCalculated()) { routingHelper.getVoiceRouter().announceCurrentDirection(null); } } }); // initial state return nextTurnInfo; }
public NextTurnInfoWidget createNextNextInfoControl( final Activity activity, final OsmandApplication app, boolean horisontalMini) { final RoutingHelper routingHelper = app.getRoutingHelper(); final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) { NextDirectionInfo calc1 = new NextDirectionInfo(); @Override public boolean updateInfo(DrawSettings drawSettings) { boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating(); TurnType turnType = null; boolean deviatedFromRoute = false; int turnImminent = 0; int nextTurnDistance = 0; if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) { deviatedFromRoute = routingHelper.isDeviatedFromRoute(); NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true); if (!deviatedFromRoute) { if (r != null) { // next turn is very close (show next next with false to speak) // if (r.imminent >= 0 && r.imminent < 2) { // r = routingHelper.getNextRouteDirectionInfoAfter(r, calc1, false); // } else { r = routingHelper.getNextRouteDirectionInfo(calc1, true); if (r != null) { r = routingHelper.getNextRouteDirectionInfoAfter(r, calc1, true); } // } } } if (r != null && r.distanceTo > 0 && r.directionInfo != null) { turnType = r.directionInfo.getTurnType(); turnImminent = r.imminent; nextTurnDistance = r.distanceTo; } } setTurnType(turnType); setTurnImminent(turnImminent, deviatedFromRoute); setTurnDistance(nextTurnDistance); return true; } }; nextTurnInfo.setOnClickListener( new View.OnClickListener() { // int i = 0; @Override public void onClick(View v) { // uncomment to test turn info rendering // final int l = TurnType.predefinedTypes.length; // final int exits = 5; // i++; // if (i % (l + exits) >= l ) { // nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1), // true); // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+""; // float a = 180 - (i % (l + exits) - l + 1) * 50; // nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a); // } else { // nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % // (TurnType.predefinedTypes.length + exits)], true); // nextTurnInfo.exitOut = ""; // } // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; // nextTurnInfo.nextTurnDirection = 580; // TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, // nexsweepAngletTurnInfo.turnType,nextTurnInfo.pathTransform); // showMiniMap = true; } }); // initial state return nextTurnInfo; }