Search in sources :

Example 1 with AvoidPTTypesRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter in project Osmand by osmandapp.

the class RouteOptionsBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(app.getString(R.string.shared_string_settings), ColorUtilities.getActiveColorId(nightMode)));
    OsmAndAppCustomization customization = app.getAppCustomization();
    List<LocalRoutingParameter> list = getRoutingParameters(applicationMode);
    for (final LocalRoutingParameter optionsItem : list) {
        if (!dialogMode.isAvailableParameter(optionsItem) || !customization.isFeatureEnabled(optionsItem.getKey())) {
            continue;
        }
        if (optionsItem instanceof DividerItem) {
            if (isDividerRequired()) {
                items.add(new DividerStartItem(app));
            }
        } else if (optionsItem instanceof MuteSoundRoutingParameter) {
            items.add(createMuteSoundItem(optionsItem));
        } else if (optionsItem instanceof ShowAlongTheRouteItem) {
            items.add(createShowAlongTheRouteItem(optionsItem));
        } else if (optionsItem instanceof RouteSimulationItem) {
            items.add(createRouteSimulationItem(optionsItem));
        } else if (optionsItem instanceof AvoidPTTypesRoutingParameter) {
            items.add(createAvoidPTTypesItem(optionsItem));
        } else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
            items.add(createAvoidRoadsItem(optionsItem));
        } else if (optionsItem instanceof GpxLocalRoutingParameter) {
            items.add(createGpxRoutingItem(optionsItem));
        } else if (optionsItem instanceof TimeConditionalRoutingItem) {
            items.add(createTimeConditionalRoutingItem(optionsItem));
        } else if (optionsItem instanceof OtherSettingsRoutingParameter) {
            items.add(createOtherSettingsRoutingItem(optionsItem));
        } else if (optionsItem instanceof CustomizeRouteLineRoutingParameter) {
            items.add(createCustomizeRouteLineRoutingItem(optionsItem));
        } else if (USE_HEIGHT_OBSTACLES.equals(optionsItem.getKey()) && hasReliefParameters()) {
            items.add(inflateElevationParameter(optionsItem));
        } else {
            inflateRoutingParameter(optionsItem);
        }
    }
}
Also used : OtherSettingsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) TimeConditionalRoutingItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem) RouteSimulationItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) DividerStartItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem) CustomizeRouteLineRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.CustomizeRouteLineRoutingParameter) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) ShowAlongTheRouteItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem) DividerItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem)

Example 2 with AvoidPTTypesRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter in project Osmand by osmandapp.

the class MapRouteInfoMenu method updateCards.

private void updateCards() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null) {
        return;
    }
    OsmandApplication app = mapActivity.getMyApplication();
    nightMode = app.getDaynightHelper().isNightModeForMapControls();
    TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
    RoutingHelper routingHelper = app.getRoutingHelper();
    boolean hasPrecalculatedMissingMaps = hasPrecalculatedMissingMaps();
    boolean hasCalculatedMissingMaps = hasCalculatedMissingMaps(app);
    List<BaseCard> menuCards = new ArrayList<>();
    boolean bottomShadowVisible = true;
    if (isBasicRouteCalculated()) {
        GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), app);
        SimpleRouteCard simpleRouteCard = new SimpleRouteCard(mapActivity, gpx);
        simpleRouteCard.setListener(this);
        menuCards.add(simpleRouteCard);
        bottomShadowVisible = false;
    } else if (isTransportRouteCalculated()) {
        TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
        List<TransportRouteResult> routes = transportRoutingHelper.getRoutes();
        if (routes != null && routes.size() > 0) {
            TransportRouteResult route = routes.get(0);
            int walkTimeReal = transportRoutingHelper.getWalkingTime(route.getSegments());
            int walkTimePT = (int) route.getWalkTime();
            int walkTime = walkTimeReal > 0 ? walkTimeReal : walkTimePT;
            int travelTime = (int) route.getTravelTime() + walkTime;
            LatLon startLocation = transportRoutingHelper.getStartLocation();
            LatLon endLocation = transportRoutingHelper.getEndLocation();
            int approxPedestrianTime = (int) MapUtils.getDistance(startLocation, endLocation);
            boolean showPedestrianCard = approxPedestrianTime < travelTime + 60 && approxPedestrianTime < MAX_PEDESTRIAN_ROUTE_DURATION;
            boolean hasTopCard = false;
            if (routes.size() > 1 && routeSelected) {
                int currentRoute = app.getTransportRoutingHelper().getCurrentRoute();
                if (currentRoute >= 0 && currentRoute < routes.size()) {
                    route = routes.get(currentRoute);
                    PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, currentRoute);
                    card.setRouteInfoVisible(false);
                    card.setRouteButtonsVisible(false);
                    card.setShowBottomShadow(false);
                    card.setShowTopShadow(false);
                    card.setListener(this);
                    menuCards.add(card);
                    hasTopCard = true;
                }
            }
            for (int i = 0; i < routes.size(); i++) {
                route = routes.get(i);
                PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, i);
                card.setShowButtonCustomTitle(mapActivity.getString(R.string.shared_string_show_on_map));
                card.setShowBottomShadow(i == routes.size() - 1 && !showPedestrianCard);
                card.setShowTopShadow(i != 0 || hasTopCard);
                card.setListener(this);
                menuCards.add(card);
            }
            if (showPedestrianCard) {
                PedestrianRouteCard pedestrianRouteCard = new PedestrianRouteCard(mapActivity, approxPedestrianTime);
                pedestrianRouteCard.setListener(this);
                menuCards.add(pedestrianRouteCard);
            }
            bottomShadowVisible = routes.size() == 0;
        } else {
            RouteMenuAppModes mode = app.getRoutingOptionsHelper().getRouteMenuAppMode(routingHelper.getAppMode());
            boolean avoidPTTypesCustomized = false;
            for (LocalRoutingParameter parameter : mode.parameters) {
                if (parameter instanceof AvoidPTTypesRoutingParameter) {
                    avoidPTTypesCustomized = true;
                    break;
                }
            }
            if (avoidPTTypesCustomized) {
                PublicTransportNotFoundSettingsWarningCard warningCard = new PublicTransportNotFoundSettingsWarningCard(mapActivity);
                warningCard.setListener(this);
                menuCards.add(warningCard);
            } else {
                PublicTransportNotFoundWarningCard warningCard = new PublicTransportNotFoundWarningCard(mapActivity);
                warningCard.setListener(this);
                menuCards.add(warningCard);
            }
        }
    } else if (routeCalculationInProgress) {
        if (app.getRoutingHelper().isPublicTransportMode()) {
            menuCards.add(new PublicTransportBetaWarningCard(mapActivity));
        } else if (app.getRoutingHelper().isBoatMode()) {
            menuCards.add(new NauticalBridgeHeightWarningCard(mapActivity));
        } else if (hasPrecalculatedMissingMaps || suggestedMapsOnlineSearch) {
            menuCards.add(new SuggestionsMapsDownloadWarningCard(mapActivity));
        } else if (app.getTargetPointsHelper().hasTooLongDistanceToNavigate() && !hasCalculatedMissingMaps) {
            menuCards.add(new LongDistanceWarningCard(mapActivity));
        }
    } else {
        if (hasCalculatedMissingMaps) {
            menuCards.add(new SuggestionsMapsDownloadWarningCard(mapActivity));
        } else {
            // Home/work card
            HomeWorkCard homeWorkCard = new HomeWorkCard(mapActivity);
            menuCards.add(homeWorkCard);
            // Previous route card
            boolean historyEnabled = app.getSettings().NAVIGATION_HISTORY.get();
            if (historyEnabled) {
                TargetPoint startBackup = targetPointsHelper.getPointToStartBackup();
                if (startBackup == null) {
                    startBackup = targetPointsHelper.getMyLocationToStart();
                }
                TargetPoint destinationBackup = targetPointsHelper.getPointToNavigateBackup();
                if (startBackup != null && destinationBackup != null) {
                    PreviousRouteCard previousRouteCard = new PreviousRouteCard(mapActivity);
                    previousRouteCard.setListener(this);
                    menuCards.add(previousRouteCard);
                }
            }
            // Gpx card
            List<SelectedGpxFile> selectedGPXFiles = app.getSelectedGpxHelper().getSelectedGPXFiles();
            final List<GPXFile> gpxFiles = new ArrayList<>();
            for (SelectedGpxFile gs : selectedGPXFiles) {
                if (!gs.isShowCurrentTrack()) {
                    if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkPt()) {
                        gpxFiles.add(gs.getGpxFile());
                    }
                }
            }
            if (gpxFiles.size() > 0) {
                TracksCard tracksCard = new TracksCard(mapActivity, gpxFiles);
                tracksCard.setListener(this);
                menuCards.add(tracksCard);
            }
            // Map markers card
            List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers();
            if (mapMarkers.size() > 0) {
                MapMarkersCard mapMarkersCard = new MapMarkersCard(mapActivity, mapMarkers);
                menuCards.add(mapMarkersCard);
            }
            // History card
            if (historyEnabled) {
                try {
                    SearchResultCollection res = app.getSearchUICore().getCore().shallowSearch(SearchHistoryAPI.class, "", null, false, false);
                    if (res != null) {
                        List<SearchResult> results = res.getCurrentSearchResults();
                        if (results.size() > 0) {
                            HistoryCard historyCard = new HistoryCard(mapActivity, results);
                            historyCard.setListener(this);
                            menuCards.add(historyCard);
                        }
                    }
                } catch (IOException e) {
                    LOG.error(e);
                }
            }
        }
    }
    applyCardsState(menuCards, this.menuCards);
    this.menuCards = menuCards;
    setBottomShadowVisible(bottomShadowVisible);
    setupCards();
}
Also used : RouteMenuAppModes(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteMenuAppModes) OsmandApplication(net.osmand.plus.OsmandApplication) MapMarker(net.osmand.plus.mapmarkers.MapMarker) PedestrianRouteCard(net.osmand.plus.routepreparationmenu.cards.PedestrianRouteCard) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) SuggestionsMapsDownloadWarningCard(net.osmand.plus.routepreparationmenu.cards.SuggestionsMapsDownloadWarningCard) ArrayList(java.util.ArrayList) TransportRouteResult(net.osmand.router.TransportRouteResult) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) PublicTransportBetaWarningCard(net.osmand.plus.routepreparationmenu.cards.PublicTransportBetaWarningCard) BaseCard(net.osmand.plus.routepreparationmenu.cards.BaseCard) MapMarkersCard(net.osmand.plus.routepreparationmenu.cards.MapMarkersCard) ArrayList(java.util.ArrayList) List(java.util.List) NauticalBridgeHeightWarningCard(net.osmand.plus.routepreparationmenu.cards.NauticalBridgeHeightWarningCard) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) MapActivity(net.osmand.plus.activities.MapActivity) TracksCard(net.osmand.plus.routepreparationmenu.cards.TracksCard) PublicTransportNotFoundSettingsWarningCard(net.osmand.plus.routepreparationmenu.cards.PublicTransportNotFoundSettingsWarningCard) PreviousRouteCard(net.osmand.plus.routepreparationmenu.cards.PreviousRouteCard) LongDistanceWarningCard(net.osmand.plus.routepreparationmenu.cards.LongDistanceWarningCard) SearchResult(net.osmand.search.core.SearchResult) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) PublicTransportNotFoundWarningCard(net.osmand.plus.routepreparationmenu.cards.PublicTransportNotFoundWarningCard) HomeWorkCard(net.osmand.plus.routepreparationmenu.cards.HomeWorkCard) IOException(java.io.IOException) LatLon(net.osmand.data.LatLon) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) SearchResultCollection(net.osmand.search.SearchUICore.SearchResultCollection) HistoryCard(net.osmand.plus.routepreparationmenu.cards.HistoryCard) GPXFile(net.osmand.GPXUtilities.GPXFile) SimpleRouteCard(net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard) PublicTransportCard(net.osmand.plus.routepreparationmenu.cards.PublicTransportCard)

Aggregations

AvoidPTTypesRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter)2 LocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GPXFile (net.osmand.GPXUtilities.GPXFile)1 LatLon (net.osmand.data.LatLon)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 MapActivity (net.osmand.plus.activities.MapActivity)1 DividerStartItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem)1 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)1 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)1 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)1 MapMarker (net.osmand.plus.mapmarkers.MapMarker)1 AvoidRoadsRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter)1 CustomizeRouteLineRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.CustomizeRouteLineRoutingParameter)1 DividerItem (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem)1 GpxLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter)1 MuteSoundRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter)1 OtherLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter)1