use of net.osmand.plus.track.helpers.GpxSelectionHelper in project Osmand by osmandapp.
the class MapLayerMenuListener method onContextMenuClick.
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters();
final ContextMenuItem item = menuAdapter.getItem(pos);
if (item.getSelected() != null) {
item.setColor(mapActivity, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
}
if (itemId == R.string.layer_poi) {
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
poiFiltersHelper.clearSelectedPoiFilters(wiki);
if (isChecked) {
showPoiFilterDialog(adapter, adapter.getItem(pos));
} else {
adapter.getItem(pos).setDescription(poiFiltersHelper.getSelectedPoiFiltersName(wiki));
}
} else if (itemId == R.string.layer_amenity_label) {
settings.SHOW_POI_LABEL.set(isChecked);
} else if (itemId == R.string.shared_string_favorites) {
settings.SHOW_FAVORITES.set(isChecked);
} else if (itemId == R.string.layer_gpx_layer) {
final GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
if (selectedGpxHelper.isShowingAnyGpxFiles()) {
selectedGpxHelper.clearAllGpxFilesToShow(true);
adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription());
} else {
showGpxSelectionDialog(adapter, adapter.getItem(pos));
}
} else if (itemId == R.string.rendering_category_transport) {
boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication());
TransportLinesMenu.toggleTransportLines(mapActivity, !selected, result -> {
item.setSelected(result);
item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
return true;
});
} else if (itemId == R.string.map_markers) {
settings.SHOW_MAP_MARKERS.set(isChecked);
} else if (itemId == R.string.layer_map) {
if (!OsmandPlugin.isActive(OsmandRasterMapsPlugin.class)) {
PluginsFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
ContextMenuItem it = adapter.getItem(pos);
mapActivity.getMapLayers().selectMapLayer(mapActivity, it, adapter);
}
return false;
}
adapter.notifyDataSetChanged();
mapActivity.updateLayers();
mapActivity.refreshMap();
return false;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper in project Osmand by osmandapp.
the class WptPtEditorFragmentNew method doAddWpt.
private void doAddWpt(String name, String category, String description) {
WptPt wpt = getWpt();
WptPtEditor editor = getWptPtEditor();
if (wpt != null && editor != null) {
wpt.name = name;
wpt.category = category;
wpt.desc = description;
if (color != 0) {
wpt.setColor(color);
} else {
wpt.removeColor();
}
wpt.setBackgroundType(backgroundTypeName);
wpt.setIconName(iconName);
GPXFile gpx = editor.getGpxFile();
SavingTrackHelper savingTrackHelper = getSavingTrackHelper();
GpxSelectionHelper selectedGpxHelper = getSelectedGpxHelper();
if (gpx != null && savingTrackHelper != null && selectedGpxHelper != null) {
if (gpx.showCurrentTrack) {
this.wpt = savingTrackHelper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color, iconName, backgroundTypeName);
if (!editor.isGpxSelected()) {
selectedGpxHelper.setGpxFileToDisplay(gpx);
}
} else {
addWpt(gpx, description, name, category, color, iconName, backgroundTypeName);
saveGpx(getMyApplication(), gpx, editor.isGpxSelected());
}
syncGpx(gpx);
}
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper in project Osmand by osmandapp.
the class WptPtMenuBuilder method buildWaypointsView.
private void buildWaypointsView(View view) {
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedGPXFile(wpt);
if (selectedGpxFile != null) {
List<WptPt> points = selectedGpxFile.getGpxFile().getPoints();
GPXUtilities.GPXFile gpx = selectedGpxFile.getGpxFile();
if (points.size() > 0) {
String title = view.getContext().getString(R.string.context_menu_points_of_group);
File file = new File(gpx.path);
String gpxName = file.getName().replace(IndexConstants.GPX_FILE_EXT, "").replace("/", " ").replace("_", " ");
int color = getPointColor(wpt, getFileColor(selectedGpxFile));
buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName, true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt), false, 0, false, null, false);
}
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper in project Osmand by osmandapp.
the class MapMarkersGroupsAdapter method switchGpxVisibility.
private void switchGpxVisibility(@NonNull GPXFile gpxFile, @Nullable SelectedGpxFile selectedGpxFile, boolean visible) {
GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
if (!visible && selectedGpxFile != null && selectedGpxFile.selectedByUser) {
return;
}
gpxHelper.selectGpxFile(gpxFile, visible, false, false, false, false);
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper in project Osmand by osmandapp.
the class MapMarkersHelper method syncGpxPassedPoints.
private void syncGpxPassedPoints(MapMarker marker, Set<GPXFile> gpxFiles) {
GpxSelectionHelper gpxHelper = ctx.getSelectedGpxHelper();
File file = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR + marker.groupKey);
if (file.exists()) {
SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(file.getAbsolutePath());
if (selectedGpxFile != null) {
boolean passedPoint = marker.wptPt.getExtensionsToWrite().containsKey(VISITED_DATE);
if (marker.history && !passedPoint) {
marker.wptPt.getExtensionsToWrite().put(VISITED_DATE, GPXUtilities.formatTime(System.currentTimeMillis()));
gpxFiles.add(selectedGpxFile.getGpxFile());
} else if (!marker.history && passedPoint) {
marker.wptPt.getExtensionsToWrite().remove(VISITED_DATE);
gpxFiles.add(selectedGpxFile.getGpxFile());
}
}
}
}
Aggregations