use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class SettingsHelper method getMyPlacesItems.
private Map<ExportSettingsType, List<?>> getMyPlacesItems(@Nullable List<ExportSettingsType> settingsTypes, boolean addEmptyItems) {
Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
List<FavoriteGroup> favoriteGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.FAVORITES) ? app.getFavoritesHelper().getFavoriteGroups() : Collections.emptyList();
if (!favoriteGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.FAVORITES, favoriteGroups);
}
List<GpxDataItem> gpxItems = settingsTypes == null || settingsTypes.contains(ExportSettingsType.TRACKS) ? app.getGpxDbHelper().getItems() : Collections.emptyList();
if (!gpxItems.isEmpty() || addEmptyItems) {
List<File> files = new ArrayList<>();
for (GpxDataItem gpxItem : gpxItems) {
File file = gpxItem.getFile();
if (file.exists() && !file.isDirectory()) {
files.add(file);
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.TRACKS, files);
}
}
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getActivePlugin(OsmEditingPlugin.class);
if (osmEditingPlugin != null) {
List<OsmNotesPoint> notesPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_NOTES) ? osmEditingPlugin.getDBBug().getOsmbugsPoints() : Collections.emptyList();
if (!notesPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_NOTES, notesPointList);
}
List<OpenstreetmapPoint> editsPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_EDITS) ? osmEditingPlugin.getDBPOI().getOpenstreetmapPoints() : Collections.emptyList();
if (!editsPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_EDITS, editsPointList);
}
}
AudioVideoNotesPlugin avNotesPlugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
if (avNotesPlugin != null) {
List<File> files = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.MULTIMEDIA_NOTES)) {
for (Recording rec : avNotesPlugin.getAllRecordings()) {
File file = rec.getFile();
if (file != null && file.exists()) {
files.add(file);
}
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.MULTIMEDIA_NOTES, files);
}
}
List<MapMarker> mapMarkers = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ACTIVE_MARKERS) ? app.getMapMarkersHelper().getMapMarkers() : Collections.emptyList();
if (!mapMarkers.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.map_markers);
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(mapMarkers);
myPlacesItems.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
}
List<MapMarker> markersHistory = settingsTypes == null || settingsTypes.contains(ExportSettingsType.HISTORY_MARKERS) ? app.getMapMarkersHelper().getMapMarkersHistory() : Collections.emptyList();
if (!markersHistory.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.shared_string_history);
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(markersHistory);
myPlacesItems.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
}
List<HistoryEntry> historyEntries = settingsTypes == null || settingsTypes.contains(ExportSettingsType.SEARCH_HISTORY) ? SearchHistoryHelper.getInstance(app).getHistoryEntries(false) : Collections.emptyList();
if (!historyEntries.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
}
List<MapMarkersGroup> markersGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ITINERARY_GROUPS) ? app.getMapMarkersHelper().getVisibleMapMarkersGroups() : Collections.emptyList();
if (!markersGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.ITINERARY_GROUPS, markersGroups);
}
return myPlacesItems;
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup 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)));
}
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class ExportSettingsAdapter method getSelectedTypeDescr.
private String getSelectedTypeDescr(ExportSettingsType type, List<?> items) {
long itemsSize = 0;
int selectedTypes = 0;
List<?> selectedItems = selectedItemsMap.get(type);
if (selectedItems != null) {
for (int i = 0; i < items.size(); i++) {
Object object = items.get(i);
if (selectedItems.contains(object)) {
selectedTypes++;
if (object instanceof FileSettingsItem) {
itemsSize += ((FileSettingsItem) object).getSize();
} else if (object instanceof File) {
itemsSize += ((File) object).length();
} else if (object instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
if (Algorithms.stringsEqual(markersGroup.getId(), ExportSettingsType.ACTIVE_MARKERS.name()) || Algorithms.stringsEqual(markersGroup.getId(), ExportSettingsType.HISTORY_MARKERS.name())) {
itemsSize += ((MapMarkersGroup) object).getMarkers().size();
}
}
}
}
if (itemsSize > 0 && type == ExportSettingsType.ACTIVE_MARKERS) {
String itemsDescr = app.getString(R.string.shared_string_items);
return app.getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, String.valueOf(itemsSize));
}
}
String description;
if (selectedTypes == 0) {
description = app.getString(Algorithms.isEmpty(items) ? R.string.shared_string_empty : R.string.shared_string_none);
} else if (selectedTypes == items.size()) {
description = app.getString(R.string.shared_string_all);
if (itemsSize == 0) {
description = app.getString(R.string.ltr_or_rtl_combine_via_comma, description, String.valueOf(items.size()));
}
} else {
description = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedTypes), String.valueOf(items.size()));
}
String formattedSize = AndroidUtils.formatSize(app, itemsSize);
return itemsSize == 0 ? description : app.getString(R.string.ltr_or_rtl_combine_via_comma, description, formattedSize);
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup 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;
}
use of net.osmand.plus.mapmarkers.MapMarkersGroup in project Osmand by osmandapp.
the class WptPtEditorFragmentNew method syncGpx.
private void syncGpx(GPXFile gpxFile) {
OsmandApplication app = getMyApplication();
if (app != null) {
MapMarkersHelper helper = app.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(gpxFile);
if (group != null) {
helper.runSynchronization(group);
}
}
}
Aggregations