Search in sources :

Example 1 with NextTurnWidget

use of net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget in project Osmand by osmandapp.

the class MapInfoLayer method registerAllControls.

private void registerAllControls(@NonNull MapActivity map) {
    rulerWidgets = new ArrayList<>();
    RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
    MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
    MapMarkersWidgetsFactory mwf = map.getMapLayers().getMapMarkersLayer().getWidgetsFactory();
    OsmandApplication app = view.getApplication();
    lanesControl = RouteInfoWidgetsFactory.createLanesControl(map, view);
    TextState ts = calculateTextState();
    streetNameView = new TopTextView(map.getMyApplication(), map);
    updateStreetName(false, ts);
    topCoordinatesView = new TopCoordinatesView(map.getMyApplication(), map);
    updateTopCoordinates(false, ts);
    topToolbarView = new TopToolbarView(map);
    updateTopToolbar(false);
    alarmControl = RouteInfoWidgetsFactory.createAlarmInfoControl(app, map);
    alarmControl.setVisibility(false);
    elevationProfileWidget = new ElevationProfileWidget(map);
    setupRulerWidget(mapRulerLayout);
    // register left stack
    registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
    NextTurnWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
    registerSideWidget(bigInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn, WIDGET_NEXT_TURN, true, 5);
    NextTurnWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
    registerSideWidget(smallInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn_small, WIDGET_NEXT_TURN_SMALL, true, 6);
    NextTurnWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true);
    registerSideWidget(nextNextInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_next_turn, WIDGET_NEXT_NEXT_TURN, true, 7);
    // register right stack
    // priorityOrder: 10s navigation-related, 20s position-related, 30s recording- and other plugin-related, 40s general device information, 50s debugging-purpose
    TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map);
    registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, WIDGET_INTERMEDIATE_DISTANCE, false, 13);
    TextInfoWidget intermediateTime = ric.createTimeControl(map, true);
    registerSideWidget(intermediateTime, new TimeWidgetState(app, true), WIDGET_INTERMEDIATE_TIME, false, 14);
    TextInfoWidget dist = ric.createDistanceControl(map);
    registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, WIDGET_DISTANCE, false, 15);
    TextInfoWidget time = ric.createTimeControl(map, false);
    registerSideWidget(time, new TimeWidgetState(app, false), WIDGET_TIME, false, 16);
    TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
    registerSideWidget(marker, R.drawable.ic_action_flag, R.string.map_marker_1st, WIDGET_MARKER_1, false, 17);
    TextInfoWidget bearing = ric.createBearingControl(map);
    registerSideWidget(bearing, new BearingWidgetState(app), WIDGET_BEARING, false, 18);
    TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false);
    registerSideWidget(marker2nd, R.drawable.ic_action_flag, R.string.map_marker_2nd, WIDGET_MARKER_2, false, 19);
    TextInfoWidget speed = ric.createSpeedControl(map);
    registerSideWidget(speed, R.drawable.ic_action_speed, R.string.map_widget_speed, WIDGET_SPEED, false, 20);
    TextInfoWidget maxspeed = ric.createMaxSpeedControl(map);
    registerSideWidget(maxspeed, R.drawable.ic_action_speed_limit, R.string.map_widget_max_speed, WIDGET_MAX_SPEED, false, 21);
    TextInfoWidget alt = mic.createAltitudeControl(map);
    registerSideWidget(alt, R.drawable.ic_action_altitude, R.string.map_widget_altitude, WIDGET_ALTITUDE, false, 23);
    TextInfoWidget gpsInfo = mic.createGPSInfoControl(map);
    registerSideWidget(gpsInfo, R.drawable.ic_action_gps_info, R.string.map_widget_gps_info, WIDGET_GPS_INFO, false, 28);
    TextInfoWidget plainTime = ric.createPlainTimeControl(map);
    registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, WIDGET_PLAIN_TIME, false, 41);
    TextInfoWidget battery = ric.createBatteryControl(map);
    registerSideWidget(battery, R.drawable.ic_action_battery, R.string.map_widget_battery, WIDGET_BATTERY, false, 42);
    TextInfoWidget radiusRuler = mic.createRadiusRulerControl(map);
    registerSideWidget(radiusRuler, new CompassRulerWidgetState(app), WIDGET_RADIUS_RULER, false, 43);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) MapInfoWidgetsFactory(net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory) BearingWidgetState(net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState) RouteInfoWidgetsFactory(net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory) CompassRulerWidgetState(net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState) MapMarkersWidgetsFactory(net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory) TextInfoWidget(net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget) TimeWidgetState(net.osmand.plus.views.mapwidgets.widgetstates.TimeWidgetState) ElevationProfileWidget(net.osmand.plus.views.mapwidgets.widgets.ElevationProfileWidget) TopCoordinatesView(net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView) TopTextView(net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView) TopToolbarView(net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView) NextTurnWidget(net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget)

Example 2 with NextTurnWidget

use of net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget in project Osmand by osmandapp.

the class RouteInfoWidgetsFactory method createNextInfoControl.

public NextTurnWidget createNextInfoControl(final Activity activity, final OsmandApplication app, boolean horisontalMini) {
    final OsmandSettings settings = app.getSettings();
    final RoutingHelper routingHelper = app.getRoutingHelper();
    final NextTurnWidget nextTurnInfo = new NextTurnWidget(activity, app, horisontalMini) {

        final 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.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) {
            // TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nextTurnInfo.turnType,nextTurnInfo.pathTransform);
            if (routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
                routingHelper.getVoiceRouter().announceCurrentDirection(null);
            }
        }
    });
    // initial state
    return nextTurnInfo;
}
Also used : NextDirectionInfo(net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TurnType(net.osmand.router.TurnType) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) View(android.view.View) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) NextTurnWidget(net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget) DrawSettings(net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)

Example 3 with NextTurnWidget

use of net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget in project Osmand by osmandapp.

the class RouteInfoWidgetsFactory method createNextNextInfoControl.

public NextTurnWidget createNextNextInfoControl(final Activity activity, final OsmandApplication app, boolean horisontalMini) {
    final RoutingHelper routingHelper = app.getRoutingHelper();
    final NextTurnWidget nextTurnInfo = new NextTurnWidget(activity, app, horisontalMini) {

        final 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.isRouteCalculated() && followingMode) {
                deviatedFromRoute = routingHelper.isDeviatedFromRoute();
                NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
                if (!deviatedFromRoute) {
                    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;
}
Also used : NextDirectionInfo(net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TurnType(net.osmand.router.TurnType) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) View(android.view.View) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) NextTurnWidget(net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget) DrawSettings(net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)

Aggregations

NextTurnWidget (net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget)3 View (android.view.View)2 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)2 NextDirectionInfo (net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo)2 RoutingHelper (net.osmand.plus.routing.RoutingHelper)2 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)2 DrawSettings (net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)2 TurnType (net.osmand.router.TurnType)2 OsmandApplication (net.osmand.plus.OsmandApplication)1 OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)1 MapInfoWidgetsFactory (net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory)1 TopCoordinatesView (net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView)1 TopTextView (net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView)1 TopToolbarView (net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView)1 MapMarkersWidgetsFactory (net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory)1 RouteInfoWidgetsFactory (net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory)1 ElevationProfileWidget (net.osmand.plus.views.mapwidgets.widgets.ElevationProfileWidget)1 TextInfoWidget (net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget)1 BearingWidgetState (net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState)1 CompassRulerWidgetState (net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState)1