Search in sources :

Example 6 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class RoutingDataUtils method getOnlineEngineByKey.

@Nullable
public ProfileDataObject getOnlineEngineByKey(String stringKey) {
    OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
    OnlineRoutingEngine engine = helper.getEngineByKey(stringKey);
    if (engine != null) {
        return convertOnlineEngineToDataObject(engine);
    }
    return null;
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) Nullable(androidx.annotation.Nullable)

Example 7 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class ExportItemsBottomSheet method setupBottomSheetItem.

private void setupBottomSheetItem(BottomSheetItemWithCompoundButton item, Object object) {
    if (object instanceof ApplicationModeBean) {
        ApplicationModeBean modeBean = (ApplicationModeBean) object;
        String profileName = modeBean.userProfileName;
        if (Algorithms.isEmpty(profileName)) {
            ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
            if (appMode != null) {
                profileName = appMode.toHumanString();
            } else {
                profileName = Algorithms.capitalizeFirstLetter(modeBean.stringKey);
            }
        }
        item.setTitle(profileName);
        String routingProfile = "";
        String routingProfileValue = modeBean.routingProfile;
        if (!routingProfileValue.isEmpty()) {
            try {
                routingProfile = getString(RoutingProfilesResources.valueOf(routingProfileValue.toUpperCase()).getStringRes());
                routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfile);
            } catch (IllegalArgumentException e) {
                routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfileValue);
                LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
            }
        }
        if (!Algorithms.isEmpty(routingProfile)) {
            item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile));
        } else {
            item.setDescription(getString(R.string.profile_type_osmand_string));
        }
        int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
        ProfileIconColors iconColor = modeBean.iconColor;
        Integer customIconColor = modeBean.customIconColor;
        int actualIconColor;
        if (selectedItems.contains(object)) {
            actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
        } else {
            actualIconColor = ContextCompat.getColor(app, secondaryColorRes);
        }
        int iconRes = profileIconRes != 0 ? profileIconRes : R.drawable.ic_world_globe_dark;
        item.setIcon(uiUtilities.getPaintedIcon(iconRes, actualIconColor));
    } else if (object instanceof QuickAction) {
        QuickAction quickAction = (QuickAction) object;
        item.setTitle(quickAction.getName(app));
        item.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), getItemIconColor(object)));
    } else if (object instanceof PoiUIFilter) {
        PoiUIFilter poiUIFilter = (PoiUIFilter) object;
        item.setTitle(poiUIFilter.getName());
        int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId());
        item.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
    } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
        ITileSource tileSource = (ITileSource) object;
        item.setTitle(tileSource.getName());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_map, getItemIconColor(object)));
    } else if (object instanceof File) {
        setupBottomSheetItemForFile(item, (File) object);
    } else if (object instanceof GpxSettingsItem) {
        GpxSettingsItem settingsItem = (GpxSettingsItem) object;
        setupBottomSheetItemForGpx(item, settingsItem.getFile(), settingsItem.getAppearanceInfo());
    } else if (object instanceof FileSettingsItem) {
        FileSettingsItem settingsItem = (FileSettingsItem) object;
        setupBottomSheetItemForFile(item, settingsItem.getFile());
    } else if (object instanceof AvoidRoadInfo) {
        AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object;
        item.setTitle(avoidRoadInfo.name);
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, getItemIconColor(object)));
    } else if (object instanceof OsmNotesPoint) {
        OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object;
        item.setTitle(osmNotesPoint.getText());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, getItemIconColor(object)));
    } else if (object instanceof OpenstreetmapPoint) {
        OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object;
        item.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, getItemIconColor(object)));
    } else if (object instanceof FavoriteGroup) {
        FavoriteGroup group = (FavoriteGroup) object;
        item.setTitle(group.getDisplayName(app));
        int color;
        if (selectedItems.contains(object)) {
            color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
        } else {
            color = ContextCompat.getColor(app, secondaryColorRes);
        }
        item.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color));
        int points = group.getPoints().size();
        String itemsDescr = getString(R.string.shared_string_gpx_points);
        item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points));
    } else if (object instanceof GlobalSettingsItem) {
        GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object;
        item.setTitle(globalSettingsItem.getPublicName(app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, getItemIconColor(object)));
    } else if (object instanceof MapMarkersGroup) {
        MapMarkersGroup markersGroup = (MapMarkersGroup) object;
        if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
            item.setTitle(getString(R.string.map_markers));
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object)));
        } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
            item.setTitle(getString(R.string.markers_history));
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
        } else {
            String groupName = markersGroup.getName();
            if (Algorithms.isEmpty(groupName)) {
                if (markersGroup.getType() == ItineraryType.FAVOURITES) {
                    groupName = app.getString(R.string.shared_string_favorites);
                } else if (markersGroup.getType() == ItineraryType.MARKERS) {
                    groupName = app.getString(R.string.map_markers);
                }
            }
            item.setTitle(groupName);
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object)));
        }
        int selectedMarkers = markersGroup.getMarkers().size();
        String itemsDescr = getString(R.string.shared_string_items);
        item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers));
    } else if (object instanceof HistoryEntry) {
        HistoryEntry historyEntry = (HistoryEntry) object;
        item.setTitle(historyEntry.getName().getName());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
    } else if (object instanceof OnlineRoutingEngine) {
        OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object;
        item.setTitle(onlineRoutingEngine.getName(app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, getItemIconColor(object)));
    }
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) ProfileIconColors(net.osmand.plus.profiles.ProfileIconColors) TileSourceTemplate(net.osmand.map.TileSourceManager.TileSourceTemplate) ApplicationModeBean(net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) GpxSettingsItem(net.osmand.plus.settings.backend.backup.items.GpxSettingsItem) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) SQLiteTileSource(net.osmand.plus.resources.SQLiteTileSource) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) GlobalSettingsItem(net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) File(java.io.File)

Example 8 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class ImportDuplicatesFragment method prepareDuplicates.

protected List<Object> prepareDuplicates(List<? super Object> duplicatesList) {
    List<? super Object> duplicates = new ArrayList<>();
    List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
    List<QuickAction> actions = new ArrayList<>();
    List<PoiUIFilter> filters = new ArrayList<>();
    List<ITileSource> tileSources = new ArrayList<>();
    List<File> renderFilesList = new ArrayList<>();
    List<File> routingFilesList = new ArrayList<>();
    List<File> multimediaFilesList = new ArrayList<>();
    List<File> trackFilesList = new ArrayList<>();
    List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
    List<FavoriteGroup> favoriteGroups = new ArrayList<>();
    List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
    List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
    List<File> ttsVoiceFilesList = new ArrayList<>();
    List<File> voiceFilesList = new ArrayList<>();
    List<File> mapFilesList = new ArrayList<>();
    List<MapMarker> mapMarkers = new ArrayList<>();
    List<MapMarker> mapMarkersHistory = new ArrayList<>();
    List<HistoryEntry> historyEntries = new ArrayList<>();
    List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
    List<MapMarkersGroup> itineraryGroups = new ArrayList<>();
    for (Object object : duplicatesList) {
        if (object instanceof ApplicationMode.ApplicationModeBean) {
            profiles.add((ApplicationMode.ApplicationModeBean) object);
        } else if (object instanceof QuickAction) {
            actions.add((QuickAction) object);
        } else if (object instanceof PoiUIFilter) {
            filters.add((PoiUIFilter) object);
        } else if (object instanceof ITileSource) {
            tileSources.add((ITileSource) object);
        } else if (object instanceof File) {
            File file = (File) object;
            FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
            if (fileSubtype == FileSubtype.RENDERING_STYLE) {
                renderFilesList.add(file);
            } else if (fileSubtype == FileSubtype.ROUTING_CONFIG) {
                routingFilesList.add(file);
            } else if (fileSubtype == FileSubtype.MULTIMEDIA_NOTES) {
                multimediaFilesList.add(file);
            } else if (fileSubtype == FileSubtype.GPX) {
                trackFilesList.add(file);
            } else if (fileSubtype.isMap()) {
                mapFilesList.add(file);
            } else if (fileSubtype == FileSubtype.TTS_VOICE) {
                ttsVoiceFilesList.add(file);
            } else if (fileSubtype == FileSubtype.VOICE) {
                voiceFilesList.add(file);
            }
        } else if (object instanceof AvoidRoadInfo) {
            avoidRoads.add((AvoidRoadInfo) object);
        } else if (object instanceof FavoriteGroup) {
            favoriteGroups.add((FavoriteGroup) object);
        } else if (object instanceof OsmNotesPoint) {
            osmNotesPointList.add((OsmNotesPoint) object);
        } else if (object instanceof OpenstreetmapPoint) {
            osmEditsPointList.add((OpenstreetmapPoint) object);
        } else if (object instanceof MapMarker) {
            MapMarker mapMarker = (MapMarker) object;
            if (mapMarker.history) {
                mapMarkersHistory.add(mapMarker);
            } else {
                mapMarkers.add(mapMarker);
            }
        } else if (object instanceof HistoryEntry) {
            historyEntries.add((HistoryEntry) object);
        } else if (object instanceof OnlineRoutingEngine) {
            onlineRoutingEngines.add((OnlineRoutingEngine) object);
        } else if (object instanceof MapMarkersGroup) {
            itineraryGroups.add((MapMarkersGroup) object);
        }
    }
    if (!profiles.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_profiles));
        duplicates.addAll(profiles);
    }
    if (!actions.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_quick_actions));
        duplicates.addAll(actions);
    }
    if (!filters.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_poi_types));
        duplicates.addAll(filters);
    }
    if (!tileSources.isEmpty()) {
        duplicates.add(getString(R.string.quick_action_map_source_title));
        duplicates.addAll(tileSources);
    }
    if (!routingFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_routing));
        duplicates.addAll(routingFilesList);
    }
    if (!renderFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_rendering_style));
        duplicates.addAll(renderFilesList);
    }
    if (!multimediaFilesList.isEmpty()) {
        duplicates.add(getString(R.string.audionotes_plugin_name));
        duplicates.addAll(multimediaFilesList);
    }
    if (!trackFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_tracks));
        duplicates.addAll(trackFilesList);
    }
    if (!avoidRoads.isEmpty()) {
        duplicates.add(getString(R.string.avoid_road));
        duplicates.addAll(avoidRoads);
    }
    if (!favoriteGroups.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_favorites));
        duplicates.addAll(favoriteGroups);
    }
    if (!osmNotesPointList.isEmpty()) {
        duplicates.add(getString(R.string.osm_notes));
        duplicates.addAll(osmNotesPointList);
    }
    if (!osmEditsPointList.isEmpty()) {
        duplicates.add(getString(R.string.osm_edits));
        duplicates.addAll(osmEditsPointList);
    }
    if (!mapFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_maps));
        duplicates.addAll(mapFilesList);
    }
    if (!ttsVoiceFilesList.isEmpty()) {
        duplicates.add(getString(R.string.local_indexes_cat_tts));
        duplicates.addAll(ttsVoiceFilesList);
    }
    if (!voiceFilesList.isEmpty()) {
        duplicates.add(getString(R.string.local_indexes_cat_voice));
        duplicates.addAll(voiceFilesList);
    }
    if (!mapMarkers.isEmpty()) {
        duplicates.add(getString(R.string.map_markers));
        duplicates.addAll(mapMarkers);
    }
    if (!mapMarkersHistory.isEmpty()) {
        duplicates.add(getString(R.string.markers_history));
        duplicates.addAll(mapMarkersHistory);
    }
    if (!onlineRoutingEngines.isEmpty()) {
        duplicates.add(getString(R.string.online_routing_engines));
        duplicates.addAll(onlineRoutingEngines);
    }
    if (!historyEntries.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_search_history));
        duplicates.addAll(historyEntries);
    }
    if (!itineraryGroups.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_itinerary));
        duplicates.addAll(itineraryGroups);
    }
    return duplicates;
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) MapMarker(net.osmand.plus.mapmarkers.MapMarker) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) FileSubtype(net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype) File(java.io.File)

Example 9 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class OnlineRoutingEngineFragment method createInitStateEngine.

private OnlineRoutingEngine createInitStateEngine() {
    OnlineRoutingEngine engine;
    OnlineRoutingEngine editedEngine = helper.getEngineByKey(editedEngineKey);
    if (editedEngine != null) {
        engine = (OnlineRoutingEngine) editedEngine.clone();
    } else {
        engine = EngineType.values()[0].newInstance(null);
        String vehicle = engine.getAllowedVehicles().get(0).getKey();
        engine.put(EngineParameter.VEHICLE_KEY, vehicle);
        if (editedEngineKey != null) {
            engine.put(EngineParameter.KEY, editedEngineKey);
        }
    }
    return engine;
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)

Example 10 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class OnlineRoutingEngineFragment method restoreState.

private void restoreState(@NonNull Bundle savedState) {
    editedEngineKey = savedState.getString(EngineParameter.KEY.name());
    initEngine = createInitStateEngine();
    String typeKey = savedState.getString(ENGINE_TYPE_KEY);
    OnlineRoutingEngine type = EngineType.getTypeByName(typeKey);
    Map<String, String> params = new HashMap<>();
    for (EngineParameter key : EngineParameter.values()) {
        String value = savedState.getString(key.name());
        if (value != null) {
            params.put(key.name(), value);
        }
    }
    engine = type.newInstance(params);
    customVehicleKey = savedState.getString(ENGINE_CUSTOM_VEHICLE_KEY);
    selectedLocation = ExampleLocation.valueOf(savedState.getString(EXAMPLE_LOCATION_KEY));
    appMode = ApplicationMode.valueOfStringKey(savedState.getString(APP_MODE_KEY), null);
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) EngineParameter(net.osmand.plus.onlinerouting.EngineParameter) HashMap(java.util.HashMap)

Aggregations

OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)22 ArrayList (java.util.ArrayList)8 File (java.io.File)6 ITileSource (net.osmand.map.ITileSource)6 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)5 QuickAction (net.osmand.plus.quickaction.QuickAction)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)4 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)4 ApplicationModeBean (net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean)4 NonNull (androidx.annotation.NonNull)3 MapMarker (net.osmand.plus.mapmarkers.MapMarker)3 OnlineRoutingHelper (net.osmand.plus.onlinerouting.OnlineRoutingHelper)3 SQLiteTileSource (net.osmand.plus.resources.SQLiteTileSource)3 FileSettingsItem (net.osmand.plus.settings.backend.backup.items.FileSettingsItem)3 GlobalSettingsItem (net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem)3