public void setDeviatePath(int deviatePath) {
   if (RouteInfoWidgetsFactory.distChanged(deviatePath, this.deviatedPath)) {
     this.deviatedPath = deviatePath;
     updateDistance();
   }
 }
 public void setTurnDistance(int nextTurnDistance) {
   if (RouteInfoWidgetsFactory.distChanged(nextTurnDistance, this.nextTurnDistance)) {
     this.nextTurnDistance = nextTurnDistance;
     updateDistance();
   }
 }
Exemple #3
0
  public void registerAllControls() {
    statusBar = new LinearLayout(view.getContext());
    statusBar.setOrientation(LinearLayout.HORIZONTAL);
    RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory(scaleCoefficient);
    MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory(scaleCoefficient);
    OsmandApplication app = view.getApplication();
    lanesControl = ric.createLanesControl(app.getRoutingHelper(), view);
    lanesControl.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));

    alarmControl = ric.createAlarmInfoControl(app, map);
    // register right stack

    RoutingHelper routingHelper = app.getRoutingHelper();
    NextTurnInfoWidget bigInfoControl =
        ric.createNextInfoControl(
            routingHelper, app, view.getSettings(), paintText, paintSubText, false);
    mapInfoControls.registerSideWidget(
        bigInfoControl,
        R.drawable.widget_next_turn,
        R.string.map_widget_next_turn,
        "next_turn",
        true,
        5);
    NextTurnInfoWidget smallInfoControl =
        ric.createNextInfoControl(
            routingHelper, app, view.getSettings(), paintSmallText, paintSmallSubText, true);
    mapInfoControls.registerSideWidget(
        smallInfoControl,
        R.drawable.widget_next_turn,
        R.string.map_widget_next_turn_small,
        "next_turn_small",
        true,
        10);
    NextTurnInfoWidget nextNextInfoControl =
        ric.createNextNextInfoControl(
            routingHelper, app, view.getSettings(), paintSmallText, paintSmallSubText, true);
    mapInfoControls.registerSideWidget(
        nextNextInfoControl,
        R.drawable.widget_next_turn,
        R.string.map_widget_next_next_turn,
        "next_next_turn",
        true,
        15);
    // MiniMapControl miniMap = ric.createMiniMapControl(routingHelper, view);
    // mapInfoControls.registerSideWidget(miniMap, R.drawable.widget_next_turn,
    // R.string.map_widget_mini_route, "mini_route", true, none, none, 20);
    // right stack
    TextInfoWidget intermediateDist =
        ric.createIntermediateDistanceControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        intermediateDist,
        R.drawable.widget_intermediate,
        R.string.map_widget_intermediate_distance,
        "intermediate_distance",
        false,
        3);
    TextInfoWidget dist = ric.createDistanceControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        dist, R.drawable.widget_target, R.string.map_widget_distance, "distance", false, 5);
    TextInfoWidget time = ric.createTimeControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        time, R.drawable.widget_time, R.string.map_widget_time, "time", false, 10);
    TextInfoWidget speed = ric.createSpeedControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, 15);
    TextInfoWidget gpsInfo = mic.createGPSInfoControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        gpsInfo, R.drawable.widget_gps_info, R.string.map_widget_gps_info, "gps_info", false, 17);
    TextInfoWidget maxspeed = ric.createMaxSpeedControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        maxspeed,
        R.drawable.widget_max_speed,
        R.string.map_widget_max_speed,
        "max_speed",
        false,
        18);
    TextInfoWidget alt = mic.createAltitudeControl(map, paintText, paintSubText);
    mapInfoControls.registerSideWidget(
        alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, 20);

    // Top widgets
    ImageViewWidget compassView = mic.createCompassView(map);
    mapInfoControls.registerTopWidget(
        compassView,
        R.drawable.widget_compass,
        R.string.map_widget_compass,
        "compass",
        MapWidgetRegistry.LEFT_CONTROL,
        5);
    View config = createConfiguration();
    mapInfoControls
        .registerTopWidget(
            config,
            R.drawable.widget_config,
            R.string.map_widget_config,
            "config",
            MapWidgetRegistry.RIGHT_CONTROL,
            10)
        .required(ApplicationMode.DEFAULT);
    mapInfoControls.registerTopWidget(
        monitoringServices.createMonitoringWidget(view, map),
        R.drawable.widget_monitoring,
        R.string.map_widget_monitoring_services,
        "monitoring_services",
        MapWidgetRegistry.LEFT_CONTROL,
        12);
    mapInfoControls.registerTopWidget(
        mic.createLockInfo(map),
        R.drawable.widget_lock_screen,
        R.string.bg_service_screen_lock,
        "bgService",
        MapWidgetRegistry.LEFT_CONTROL,
        15);
    backToLocation = mic.createBackToLocation(map);
    mapInfoControls.registerTopWidget(
        backToLocation,
        R.drawable.widget_backtolocation,
        R.string.map_widget_back_to_loc,
        "back_to_location",
        MapWidgetRegistry.RIGHT_CONTROL,
        5);

    View globus = createLayer();
    mapInfoControls.registerTopWidget(
        globus,
        R.drawable.widget_layer,
        R.string.menu_layers,
        "layers",
        MapWidgetRegistry.RIGHT_CONTROL,
        15);

    topText = mic.createStreetView(app, map, paintText);
    mapInfoControls.registerTopWidget(
        topText,
        R.drawable.street_name,
        R.string.map_widget_top_text,
        "street_name",
        MapWidgetRegistry.MAIN_CONTROL,
        100);

    // Register appearance widgets
    AppearanceWidgetsFactory.INSTANCE.registerAppearanceWidgets(map, this, mapInfoControls);
  }