Merge pull request #10155 from osmandapp/markers_backup

Markers backup
This commit is contained in:
alex-osm 2020-11-11 14:24:06 +03:00 committed by GitHub
commit d246284cba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 1065 additions and 483 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="markers_history">Markers history</string>
<string name="subscription_on_hold_title">OsmAnd Live subscription is on hold</string>
<string name="subscription_paused_title">OsmAnd Live subscription has been paused</string>
<string name="subscription_expired_title">OsmAnd Live subscription has been expired</string>

View file

@ -55,8 +55,8 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.SQLiteTileSource;

View file

@ -41,6 +41,7 @@ import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.inapp.InAppPurchaseHelperImpl;
import net.osmand.plus.liveupdates.LiveUpdatesHelper;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.monitoring.LiveMonitoringHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.poi.PoiFiltersHelper;

View file

@ -16,7 +16,8 @@ import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import net.osmand.util.Algorithms;

View file

@ -23,7 +23,8 @@ import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;

View file

@ -63,6 +63,7 @@ import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.monitoring.LiveMonitoringHelper;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.quickaction.QuickActionRegistry;

View file

@ -27,8 +27,8 @@ import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;

View file

@ -41,7 +41,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -67,8 +67,8 @@ import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OnDismissDialogFragmentListener;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationSimulation;

View file

@ -39,8 +39,8 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.ContextMenuItem.ItemBuilder;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;

View file

@ -13,8 +13,8 @@ import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.IMapLocationListener;
import net.osmand.map.WorldRegion;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
@ -88,7 +88,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
@Override
public void onMapMarkerChanged(MapMarkersHelper.MapMarker mapMarker) {
public void onMapMarkerChanged(MapMarker mapMarker) {
}
@Override

View file

@ -31,8 +31,8 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;

View file

@ -11,7 +11,7 @@ import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.map.TileSourceManager;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -207,7 +207,7 @@ public class IntentHelper {
if (intent.hasExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS)) {
Bundle openMapMarkersGroupsExtra = intent.getBundleExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS);
if (openMapMarkersGroupsExtra != null) {
MapMarkersDialogFragment.showInstance(mapActivity, openMapMarkersGroupsExtra.getString(MapMarkersHelper.MapMarkersGroup.MARKERS_SYNC_GROUP_ID));
MapMarkersDialogFragment.showInstance(mapActivity, openMapMarkersGroupsExtra.getString(MapMarkersGroup.MARKERS_SYNC_GROUP_ID));
}
mapActivity.setIntent(null);
}

View file

@ -10,7 +10,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;

View file

@ -25,8 +25,8 @@ import net.osmand.data.TransportStop;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;

View file

@ -32,7 +32,7 @@ import net.osmand.data.TransportStop;
import net.osmand.map.OsmandRegions;
import net.osmand.map.WorldRegion;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;

View file

@ -12,7 +12,7 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -14,8 +14,8 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -11,8 +11,8 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -11,8 +11,8 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.PointImageDrawable;

View file

@ -2,7 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors;
import androidx.annotation.NonNull;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.activities.MapActivity;
public class MapMarkerEditor extends PointEditor {

View file

@ -14,7 +14,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -17,8 +17,8 @@ import net.osmand.GPXUtilities.WptPt;
import net.osmand.data.LatLon;
import net.osmand.data.WptLocationPoint;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -20,8 +20,8 @@ import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.data.LatLon;
import net.osmand.data.WptLocationPoint;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;

View file

@ -0,0 +1,24 @@
package net.osmand.plus.mapmarkers;
import androidx.annotation.DrawableRes;
public class CategoriesSubHeader {
@DrawableRes
private int iconRes;
private MapMarkersGroup group;
public CategoriesSubHeader(int iconRes, MapMarkersGroup group) {
this.iconRes = iconRes;
this.group = group;
}
@DrawableRes
public int getIconRes() {
return iconRes;
}
public MapMarkersGroup getGroup() {
return group;
}
}

View file

@ -63,7 +63,6 @@ import net.osmand.GPXUtilities.WptPt;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
@ -79,7 +78,6 @@ import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM;
import net.osmand.plus.mapmarkers.CoordinateInputFormats.DMS;
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
import net.osmand.plus.mapmarkers.adapters.CoordinateInputAdapter;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.widgets.EditTextEx;
import net.osmand.util.Algorithms;
import net.osmand.util.LocationParser;
@ -171,7 +169,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private void syncGpx(GPXFile gpxFile) {
MapMarkersHelper helper = getMyApplication().getMapMarkersHelper();
MapMarkersHelper.MapMarkersGroup group = helper.getMarkersGroup(gpxFile);
MapMarkersGroup group = helper.getMarkersGroup(gpxFile);
if (group != null) {
helper.runSynchronization(group);
}

View file

@ -0,0 +1,24 @@
package net.osmand.plus.mapmarkers;
import androidx.annotation.DrawableRes;
public class GroupHeader {
@DrawableRes
private int iconRes;
private MapMarkersGroup group;
public GroupHeader(int iconRes, MapMarkersGroup group) {
this.iconRes = iconRes;
this.group = group;
}
@DrawableRes
public int getIconRes() {
return iconRes;
}
public MapMarkersGroup getGroup() {
return group;
}
}

View file

@ -3,7 +3,6 @@ package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.view.View;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;

View file

@ -0,0 +1,149 @@
package net.osmand.plus.mapmarkers;
import android.content.Context;
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
public class MapMarker implements LocationPoint {
private static int[] colors;
public String id;
public LatLon point;
private PointDescription pointDescription;
public int colorIndex;
public int index;
public boolean history;
public boolean selected;
public int dist;
public long creationDate;
public long visitedDate;
public String nextKey;
public String groupKey;
public String groupName;
public WptPt wptPt;
public FavouritePoint favouritePoint;
public String mapObjectName;
public MapMarker(LatLon point, PointDescription name, int colorIndex, boolean selected, int index) {
this.point = point;
this.pointDescription = name;
this.colorIndex = colorIndex;
this.selected = selected;
this.index = index;
}
public int getType() {
return favouritePoint == null ?
(wptPt == null ? MapMarkersGroup.ANY_TYPE : MapMarkersGroup.GPX_TYPE) :
MapMarkersGroup.FAVORITES_TYPE;
}
public PointDescription getPointDescription(Context ctx) {
return new PointDescription(POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), getOnlyName());
}
public String getName(Context ctx) {
String name;
PointDescription pd = getPointDescription(ctx);
if (Algorithms.isEmpty(pd.getName())) {
name = pd.getTypeName();
} else {
name = pd.getName();
}
return name;
}
public PointDescription getOriginalPointDescription() {
return pointDescription;
}
public void setOriginalPointDescription(PointDescription pointDescription) {
this.pointDescription = pointDescription;
}
public String getOnlyName() {
return pointDescription == null ? "" : pointDescription.getName();
}
public double getLatitude() {
return point.getLatitude();
}
public double getLongitude() {
return point.getLongitude();
}
@Override
public int getColor() {
return 0;
}
@Override
public boolean isVisible() {
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MapMarker mapMarker = (MapMarker) o;
return colorIndex == mapMarker.colorIndex && point.equals(mapMarker.point);
}
@Override
public int hashCode() {
int result = point.hashCode();
result = 31 * result + colorIndex;
return result;
}
private static final int[] colorsIds = new int[] {
R.color.marker_blue,
R.color.marker_green,
R.color.marker_orange,
R.color.marker_red,
R.color.marker_yellow,
R.color.marker_teal,
R.color.marker_purple
};
public static int[] getColors(Context context) {
if (colors != null) {
return colors;
}
colors = new int[colorsIds.length];
for (int i = 0; i < colorsIds.length; i++) {
colors[i] = ContextCompat.getColor(context, colorsIds[i]);
}
return colors;
}
public static int getColorId(int colorIndex) {
return (colorIndex >= 0 && colorIndex < colorsIds.length) ? colorsIds[colorIndex] : colorsIds[0];
}
public static int getColorIndex(Context context, @ColorInt int color) {
int[] colors = getColors(context);
for (int i = 0; i < colors.length; i++) {
if (color == colors[i]) {
return i;
}
}
return 0;
}
}

View file

@ -15,7 +15,6 @@ import androidx.annotation.Nullable;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -21,7 +21,6 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.WptLocationPoint;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;

View file

@ -4,8 +4,6 @@ import androidx.annotation.Nullable;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
@ -13,7 +11,6 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;

View file

@ -29,9 +29,8 @@ import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersSortByDef;
import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef;
import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
@ -430,7 +429,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS
public void moveAllToHistoryOnClick() {
if (mapActivity != null) {
final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
final List<MapMarkersHelper.MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
final List<MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
helper.moveAllActiveMarkersToHistory();
if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) {
activeFragment.updateAdapter();
@ -482,7 +481,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS
@Override
public void saveGpx(final String fileName) {
final String gpxPath = mapActivity.getMyApplication().getMapMarkersHelper().generateGpx(fileName);
final String gpxPath = mapActivity.getMyApplication().getMapMarkersHelper().saveMarkersToFile(fileName);
snackbar = Snackbar.make(viewPager, String.format(getString(R.string.shared_string_file_is_saved), fileName) + ".", Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_show, new View.OnClickListener() {
@Override

View file

@ -0,0 +1,183 @@
package net.osmand.plus.mapmarkers;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class MapMarkersGroup {
public static final int ANY_TYPE = -1;
public static final int FAVORITES_TYPE = 0;
public static final int GPX_TYPE = 1;
public static final String MARKERS_SYNC_GROUP_ID = "markers_sync_group_id";
private String id;
private String name;
private int type = ANY_TYPE;
private Set<String> wptCategories;
private long creationDate;
private boolean disabled;
private boolean visible = true;
private boolean wasShown = false;
private boolean visibleUntilRestart;
private List<MapMarker> markers = new ArrayList<>();
private TravelArticle wikivoyageArticle;
// TODO should be removed from this class:
private GroupHeader header;
private CategoriesSubHeader categoriesSubHeader;
private ShowHideHistoryButton showHideHistoryButton;
public MapMarkersGroup() {
}
public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) {
this.id = id;
this.name = name;
this.type = type;
}
public String getId() {
return id;
}
public String getGpxPath() {
return id;
}
public TravelArticle getWikivoyageArticle() {
return wikivoyageArticle;
}
public long getCreationDate() {
return creationDate;
}
public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public void setMarkers(List<MapMarker> markers) {
this.markers = markers;
}
public void setHeader(GroupHeader header) {
this.header = header;
}
public void setCategoriesSubHeader(CategoriesSubHeader categoriesSubHeader) {
this.categoriesSubHeader = categoriesSubHeader;
}
public void setShowHideHistoryButton(ShowHideHistoryButton showHideHistoryButton) {
this.showHideHistoryButton = showHideHistoryButton;
}
public boolean isWasShown() {
return wasShown;
}
public boolean isVisibleUntilRestart() {
return visibleUntilRestart;
}
public void setWikivoyageArticle(TravelArticle wikivoyageArticle) {
this.wikivoyageArticle = wikivoyageArticle;
}
public String getName() {
return name;
}
public int getType() {
return type;
}
public void setWptCategories(Set<String> wptCategories) {
this.wptCategories = wptCategories;
}
public Set<String> getWptCategories() {
return wptCategories;
}
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public boolean isVisible() {
return visible;
}
public boolean wasShown() {
return wasShown;
}
public void setWasShown(boolean wasShown) {
this.wasShown = wasShown;
}
public void setVisibleUntilRestart(boolean visibleUntilRestart) {
this.visibleUntilRestart = visibleUntilRestart;
}
public List<MapMarker> getMarkers() {
return markers;
}
public GroupHeader getGroupHeader() {
return header;
}
public CategoriesSubHeader getCategoriesSubHeader() {
return categoriesSubHeader;
}
public ShowHideHistoryButton getShowHideHistoryButton() {
return showHideHistoryButton;
}
@Nullable
public String getWptCategoriesString() {
if (wptCategories != null) {
return Algorithms.encodeStringSet(wptCategories);
}
return null;
}
public List<MapMarker> getActiveMarkers() {
List<MapMarker> markers = new ArrayList<>(this.markers);
List<MapMarker> activeMarkers = new ArrayList<>(markers.size());
for (MapMarker marker : markers) {
if (!marker.history) {
activeMarkers.add(marker);
}
}
return activeMarkers;
}
public List<MapMarker> getHistoryMarkers() {
List<MapMarker> historyMarkers = new ArrayList<>();
for (MapMarker marker : markers) {
if (marker.history) {
historyMarkers.add(marker);
}
}
return historyMarkers;
}
}

View file

@ -28,7 +28,6 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.WptLocationPoint;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;

View file

@ -1,6 +1,5 @@
package net.osmand.plus;
package net.osmand.plus.mapmarkers;
import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.IntDef;
@ -16,13 +15,16 @@ import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.GPXDatabase;
import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
import net.osmand.util.Algorithms;
@ -57,6 +59,9 @@ public class MapMarkersHelper {
public static final int BY_DATE_ADDED_ASC = 4;
public static final String VISITED_DATE = "visited_date";
public static final String CREATION_DATE = "creation_date";
private static final Log LOG = PlatformUtil.getLog(MapMarkersHelper.class);
@Retention(RetentionPolicy.SOURCE)
@ -148,12 +153,12 @@ public class MapMarkersHelper {
if (group == null) {
if (noGroup == null) {
noGroup = new MapMarkersGroup();
noGroup.creationDate = Long.MAX_VALUE;
noGroup.setCreationDate(Long.MAX_VALUE);
}
noGroup.getMarkers().add(marker);
} else {
if (marker.creationDate < group.creationDate) {
group.creationDate = marker.creationDate;
if (marker.creationDate < group.getCreationDate()) {
group.setCreationDate(marker.creationDate);
}
group.getMarkers().add(marker);
}
@ -190,16 +195,17 @@ public class MapMarkersHelper {
}
private void lookupAddress(final MapMarker mapMarker) {
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
if (mapMarker != null && mapMarker.getOriginalPointDescription().isSearchingAddress(ctx)) {
cancelPointAddressRequests(mapMarker.point);
AddressLookupRequest lookupRequest = new AddressLookupRequest(mapMarker.point,
new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
PointDescription pointDescription = mapMarker.getOriginalPointDescription();
if (Algorithms.isEmpty(address)) {
mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
} else {
mapMarker.pointDescription.setName(address);
pointDescription.setName(address);
}
markersDbHelper.updateMarker(mapMarker);
refreshMarker(mapMarker);
@ -291,7 +297,6 @@ public class MapMarkersHelper {
});
}
public void runSynchronization(final @NonNull MapMarkersGroup group) {
ctx.runInUIThread(new Runnable() {
@Override
@ -301,19 +306,17 @@ public class MapMarkersHelper {
});
}
public MapMarkersGroup getMarkersGroup(GPXFile gpx) {
if(gpx == null || gpx.path == null) {
if (gpx == null || gpx.path == null) {
return null;
}
return getMapMarkerGroupById(getMarkerGroupId(new File(gpx.path)), MapMarkersGroup.GPX_TYPE);
}
public MapMarkersGroup getMarkersGroup(FavoriteGroup favGroup) {
return getMapMarkerGroupById(getMarkerGroupId(favGroup), MapMarkersGroup.FAVORITES_TYPE);
}
public MapMarkersGroup addOrEnableGpxGroup(@NonNull File file) {
updateGpxShowAsMarkers(file);
MapMarkersGroup gr = getMapMarkerGroupById(getMarkerGroupId(file), MapMarkersGroup.GPX_TYPE);
@ -324,7 +327,7 @@ public class MapMarkersHelper {
enableGroup(gr);
return gr;
}
public MapMarkersGroup addOrEnableGroup(@NonNull GPXFile file) {
updateGpxShowAsMarkers(new File(file.path));
MapMarkersGroup gr = getMarkersGroup(file);
@ -336,7 +339,6 @@ public class MapMarkersHelper {
return gr;
}
public MapMarkersGroup addOrEnableGroup(@NonNull FavoriteGroup group) {
MapMarkersGroup gr = getMarkersGroup(group);
if (gr == null) {
@ -346,10 +348,10 @@ public class MapMarkersHelper {
enableGroup(gr);
return gr;
}
public void enableGroup(@NonNull MapMarkersGroup gr) {
// check if group doesn't exist internally
if(!mapMarkersGroups.contains(gr)) {
if (!mapMarkersGroups.contains(gr)) {
addGroupInternally(gr);
}
if (gr.isDisabled()) {
@ -393,14 +395,14 @@ public class MapMarkersHelper {
String id = group.getId();
if (id != null) {
markersDbHelper.updateGroupDisabled(id, disabled);
group.disabled = disabled;
group.setDisabled(disabled);
}
}
public void updateGroupWptCategories(@NonNull MapMarkersGroup group, Set<String> wptCategories) {
String id = group.getId();
if (id != null) {
group.wptCategories = wptCategories;
group.setWptCategories(wptCategories);
if (wptCategories != null) {
markersDbHelper.updateGroupCategories(id, group.getWptCategoriesString());
}
@ -412,7 +414,7 @@ public class MapMarkersHelper {
markersDbHelper.removeActiveMarkersFromGroup(group.getId());
removeFromMapMarkersList(group.getActiveMarkers());
if (updateGroup) {
group.markers = group.getHistoryMarkers();
group.setMarkers(group.getHistoryMarkers());
updateGroup(group);
}
reorderActiveMarkersIfNeeded();
@ -435,12 +437,12 @@ public class MapMarkersHelper {
ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton();
if (showHideHistoryButton != null) {
if (historyMarkersCount == 0) {
mapMarkersGroup.showHideHistoryButton = null;
mapMarkersGroup.setShowHideHistoryButton(null);
}
} else if (historyMarkersCount > 0) {
showHideHistoryButton = new ShowHideHistoryButton();
showHideHistoryButton.showHistory = false;
mapMarkersGroup.showHideHistoryButton = showHideHistoryButton;
mapMarkersGroup.setShowHideHistoryButton(showHideHistoryButton);
}
}
@ -460,10 +462,8 @@ public class MapMarkersHelper {
sortMarkers(mapMarkersGroup.getMarkers(), false, BY_DATE_ADDED_DESC);
}
} else {
mapMarkersGroup = new MapMarkersGroup();
mapMarkersGroup.id = marker.groupKey;
mapMarkersGroup.name = marker.groupName;
mapMarkersGroup.creationDate = Long.MAX_VALUE;
mapMarkersGroup = new MapMarkersGroup(marker.groupKey, marker.groupName, MapMarkersGroup.ANY_TYPE);
mapMarkersGroup.setCreationDate(Long.MAX_VALUE);
mapMarkersGroup.getMarkers().add(marker);
addToGroupsList(mapMarkersGroup);
sortGroups();
@ -473,18 +473,19 @@ public class MapMarkersHelper {
}
private void createHeadersInGroup(@NonNull MapMarkersGroup group) {
GroupHeader header = new GroupHeader();
CategoriesSubHeader categoriesSubHeader = new CategoriesSubHeader();
int type = group.getType();
int headerIconId = 0;
int subHeaderIconId = 0;
if (type != -1) {
header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE
headerIconId = type == MapMarkersGroup.FAVORITES_TYPE
? R.drawable.ic_action_favorite : R.drawable.ic_action_polygom_dark;
categoriesSubHeader.iconRes = R.drawable.ic_action_filter;
subHeaderIconId = R.drawable.ic_action_filter;
}
header.group = group;
categoriesSubHeader.group = group;
group.header = header;
group.categoriesSubHeader = categoriesSubHeader;
GroupHeader header = new GroupHeader(headerIconId, group);
CategoriesSubHeader categoriesSubHeader = new CategoriesSubHeader(subHeaderIconId, group);
group.setHeader(header);
group.setCategoriesSubHeader(categoriesSubHeader);
}
private void removeMarkerFromGroup(MapMarker marker) {
@ -502,8 +503,8 @@ public class MapMarkersHelper {
Collections.sort(mapMarkersGroups, new Comparator<MapMarkersGroup>() {
@Override
public int compare(MapMarkersGroup group1, MapMarkersGroup group2) {
long t1 = group1.creationDate;
long t2 = group2.creationDate;
long t1 = group1.getCreationDate();
long t2 = group2.getCreationDate();
return (t1 > t2) ? -1 : ((t1 == t2) ? 0 : 1);
}
});
@ -515,7 +516,7 @@ public class MapMarkersHelper {
for (MapMarkersGroup group : mapMarkersGroups) {
if ((id == null && group.getId() == null)
|| (group.getId() != null && group.getId().equals(id))) {
if(type == MapMarkersGroup.ANY_TYPE || type == group.type) {
if (type == MapMarkersGroup.ANY_TYPE || type == group.getType()) {
return group;
}
}
@ -528,7 +529,7 @@ public class MapMarkersHelper {
Algorithms.getFileNameWithoutExtension(fl.getName()),
MapMarkersGroup.GPX_TYPE);
}
private MapMarkersGroup createFavMarkerGroup(FavoriteGroup favGroup) {
return new MapMarkersGroup(favGroup.getName(), favGroup.getName(), MapMarkersGroup.FAVORITES_TYPE);
}
@ -536,11 +537,11 @@ public class MapMarkersHelper {
private String getMarkerGroupId(File gpx) {
return gpx.getAbsolutePath();
}
private String getMarkerGroupId(FavoriteGroup group) {
return group.getName();
}
@NonNull
public List<MapMarkersGroup> getGroupsForDisplayedGpx() {
List<MapMarkersGroup> res = new ArrayList<>();
@ -549,28 +550,28 @@ public class MapMarkersHelper {
MapMarkersGroup search = getMarkersGroup(selected.getGpxFile());
if (search == null && selected.getGpxFile() != null && selected.getGpxFile().path != null) {
MapMarkersGroup group = createGPXMarkerGroup(new File(selected.getGpxFile().path));
group.disabled = true;
group.setDisabled(true);
createHeadersInGroup(group);
res.add(group);
}
}
return res;
}
@NonNull
public List<MapMarkersGroup> getGroupsForSavedArticlesTravelBook() {
List<MapMarkersGroup> res = new ArrayList<>();
TravelDbHelper travelDbHelper = ctx.getTravelDbHelper();
if(travelDbHelper.getSelectedTravelBook() != null) {
if (travelDbHelper.getSelectedTravelBook() != null) {
List<TravelArticle> savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles();
for (TravelArticle art : savedArticles) {
String gpxName = travelDbHelper.getGPXName(art);
File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
LOG.debug("Article group " + path.getAbsolutePath() + " " + path.exists()) ;
LOG.debug("Article group " + path.getAbsolutePath() + " " + path.exists());
MapMarkersGroup search = getMapMarkerGroupById(getMarkerGroupId(path), MapMarkersGroup.GPX_TYPE);
if (search == null) {
MapMarkersGroup group = createGPXMarkerGroup(path);
group.disabled = true;
group.setDisabled(true);
createHeadersInGroup(group);
res.add(group);
}
@ -1004,7 +1005,8 @@ public class MapMarkersHelper {
});
}
public String generateGpx(String fileName) {
public String saveMarkersToFile(String fileName) {
GPXFile gpxFile = generateGpx();
String dirName = IndexConstants.GPX_INDEX_DIR + IndexConstants.MAP_MARKERS_INDEX_DIR;
File dir = ctx.getAppPath(dirName);
if (!dir.exists()) {
@ -1012,18 +1014,54 @@ public class MapMarkersHelper {
}
String uniqueFileName = FileUtils.createUniqueFileName(ctx, fileName, dirName, IndexConstants.GPX_FILE_EXT);
File fout = new File(dir, uniqueFileName + IndexConstants.GPX_FILE_EXT);
GPXUtilities.writeGpxFile(fout, gpxFile);
GPXFile file = new GPXFile(Version.getFullVersion(ctx));
for (MapMarker marker : mapMarkers) {
return fout.getAbsolutePath();
}
public GPXFile generateGpx() {
return generateGpx(mapMarkers, false);
}
public GPXFile generateGpx(List<MapMarker> markers, boolean completeBackup) {
GPXFile gpxFile = new GPXFile(Version.getFullVersion(ctx));
for (MapMarker marker : markers) {
WptPt wpt = new WptPt();
wpt.lat = marker.getLatitude();
wpt.lon = marker.getLongitude();
wpt.setColor(ctx.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
wpt.name = marker.getOnlyName();
file.addPoint(wpt);
wpt.setColor(ContextCompat.getColor(ctx, MapMarker.getColorId(marker.colorIndex)));
if (completeBackup) {
if (marker.creationDate != 0) {
wpt.getExtensionsToWrite().put(CREATION_DATE, String.valueOf(marker.creationDate));
}
if (marker.visitedDate != 0) {
wpt.getExtensionsToWrite().put(VISITED_DATE, String.valueOf(marker.visitedDate));
}
}
gpxFile.addPoint(wpt);
}
GPXUtilities.writeGpxFile(fout, file);
return fout.getAbsolutePath();
return gpxFile;
}
public List<MapMarker> readMarkersFromGpx(GPXFile gpxFile, boolean history) {
List<MapMarker> mapMarkers = new ArrayList<>();
for (WptPt point : gpxFile.getPoints()) {
LatLon latLon = new LatLon(point.lat, point.lon);
int colorIndex = MapMarker.getColorIndex(ctx, point.getColor());
PointDescription name = new PointDescription(PointDescription.POINT_TYPE_LOCATION, point.name);
MapMarker marker = new MapMarker(latLon, name, colorIndex, false, 0);
String visitedDateStr = point.getExtensionsToRead().get(VISITED_DATE);
String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE);
marker.visitedDate = Algorithms.parseLongSilently(visitedDateStr, 0);
marker.creationDate = Algorithms.parseLongSilently(creationDateStr, 0);
marker.nextKey = history ? MapMarkersDbHelper.HISTORY_NEXT_VALUE : MapMarkersDbHelper.TAIL_NEXT_VALUE;
mapMarkers.add(marker);
}
return mapMarkers;
}
// ---------------------------------------------------------------------------------------------
@ -1155,7 +1193,7 @@ public class MapMarkersHelper {
if (favGroup == null) {
return;
}
group.visible = favGroup.isVisible();
group.setVisible(favGroup.isVisible());
if (!group.isVisible() || group.isDisabled()) {
removeGroupActiveMarkers(group, true);
return;
@ -1175,17 +1213,17 @@ public class MapMarkersHelper {
String gpxPath = group.getId();
SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(gpxPath);
GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile();
group.visible = gpx != null || group.visibleUntilRestart;
group.setVisible(gpx != null || group.isVisibleUntilRestart());
if (gpx == null || group.isDisabled()) {
removeGroupActiveMarkers(group, true);
return;
}
boolean addAll = group.wptCategories == null || group.wptCategories.isEmpty();
boolean addAll = group.getWptCategories() == null || group.getWptCategories().isEmpty();
List<WptPt> gpxPoints = new ArrayList<>(gpx.getPoints());
for (WptPt pt : gpxPoints) {
if (addAll || group.wptCategories.contains(pt.category)
|| (pt.category == null && group.wptCategories.contains(""))) {
if (addAll || group.getWptCategories().contains(pt.category)
|| (pt.category == null && group.getWptCategories().contains(""))) {
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(pt.lat, pt.lon), pt.name, null, pt);
}
}
@ -1208,295 +1246,4 @@ public class MapMarkersHelper {
}
}
}
public static class MapMarkersGroup {
public static final int ANY_TYPE = -1;
public static final int FAVORITES_TYPE = 0;
public static final int GPX_TYPE = 1;
public static final String MARKERS_SYNC_GROUP_ID = "markers_sync_group_id";
private String id;
private String name;
private int type = -1;
private Set<String> wptCategories;
private long creationDate;
private boolean disabled;
private boolean visible = true;
private boolean wasShown = false;
private boolean visibleUntilRestart;
private List<MapMarker> markers = new ArrayList<>();
private TravelArticle wikivoyageArticle;
// TODO should be removed from this class:
private GroupHeader header;
private CategoriesSubHeader categoriesSubHeader;
private ShowHideHistoryButton showHideHistoryButton;
public MapMarkersGroup() {
}
public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) {
this.id = id;
this.name = name;
this.type = type;
}
public String getId() {
return id;
}
public String getGpxPath() {
return id;
}
public TravelArticle getWikivoyageArticle() {
return wikivoyageArticle;
}
public void setWikivoyageArticle(TravelArticle wikivoyageArticle) {
this.wikivoyageArticle = wikivoyageArticle;
}
public String getName() {
return name;
}
public int getType() {
return type;
}
public void setWptCategories(Set<String> wptCategories) {
this.wptCategories = wptCategories;
}
public Set<String> getWptCategories() {
return wptCategories;
}
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public boolean isVisible() {
return visible;
}
public boolean wasShown() {
return wasShown;
}
public void setWasShown(boolean wasShown) {
this.wasShown = wasShown;
}
public void setVisibleUntilRestart(boolean visibleUntilRestart) {
this.visibleUntilRestart = visibleUntilRestart;
}
public List<MapMarker> getMarkers() {
return markers;
}
public GroupHeader getGroupHeader() {
return header;
}
public CategoriesSubHeader getCategoriesSubHeader() {
return categoriesSubHeader;
}
public ShowHideHistoryButton getShowHideHistoryButton() {
return showHideHistoryButton;
}
@Nullable
public String getWptCategoriesString() {
if (wptCategories != null) {
return Algorithms.encodeStringSet(wptCategories);
}
return null;
}
public List<MapMarker> getActiveMarkers() {
List<MapMarker> markers = new ArrayList<>(this.markers);
List<MapMarker> activeMarkers = new ArrayList<>(markers.size());
for (MapMarker marker : markers) {
if (!marker.history) {
activeMarkers.add(marker);
}
}
return activeMarkers;
}
public List<MapMarker> getHistoryMarkers() {
List<MapMarker> historyMarkers = new ArrayList<>();
for (MapMarker marker : markers) {
if (marker.history) {
historyMarkers.add(marker);
}
}
return historyMarkers;
}
}
public static class ShowHideHistoryButton {
public boolean showHistory;
}
public static class GroupHeader {
private int iconRes;
private MapMarkersGroup group;
public int getIconRes() {
return iconRes;
}
public MapMarkersGroup getGroup() {
return group;
}
}
public static class CategoriesSubHeader {
private int iconRes;
private MapMarkersGroup group;
public int getIconRes() {
return iconRes;
}
public MapMarkersGroup getGroup() {
return group;
}
}
public static class MapMarker implements LocationPoint {
private static int[] colors;
public String id;
public LatLon point;
private PointDescription pointDescription;
public int colorIndex;
public int index;
public boolean history;
public boolean selected;
public int dist;
public long creationDate;
public long visitedDate;
public String nextKey;
public String groupKey;
public String groupName;
public WptPt wptPt;
public FavouritePoint favouritePoint;
public String mapObjectName;
public MapMarker(LatLon point, PointDescription name, int colorIndex, boolean selected, int index) {
this.point = point;
this.pointDescription = name;
this.colorIndex = colorIndex;
this.selected = selected;
this.index = index;
}
public int getType() {
return favouritePoint == null ?
(wptPt == null ? MapMarkersGroup.ANY_TYPE : MapMarkersGroup.GPX_TYPE) :
MapMarkersGroup.FAVORITES_TYPE;
}
public PointDescription getPointDescription(Context ctx) {
return new PointDescription(POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), getOnlyName());
}
public String getName(Context ctx) {
String name;
PointDescription pd = getPointDescription(ctx);
if (Algorithms.isEmpty(pd.getName())) {
name = pd.getTypeName();
} else {
name = pd.getName();
}
return name;
}
public PointDescription getOriginalPointDescription() {
return pointDescription;
}
public void setOriginalPointDescription(PointDescription pointDescription) {
this.pointDescription = pointDescription;
}
public String getOnlyName() {
return pointDescription == null ? "" : pointDescription.getName();
}
public double getLatitude() {
return point.getLatitude();
}
public double getLongitude() {
return point.getLongitude();
}
@Override
public int getColor() {
return 0;
}
@Override
public boolean isVisible() {
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MapMarker mapMarker = (MapMarker) o;
return colorIndex == mapMarker.colorIndex && point.equals(mapMarker.point);
}
@Override
public int hashCode() {
int result = point.hashCode();
result = 31 * result + colorIndex;
return result;
}
private static final int[] colorsIds = new int[]{
R.color.marker_blue,
R.color.marker_green,
R.color.marker_orange,
R.color.marker_red,
R.color.marker_yellow,
R.color.marker_teal,
R.color.marker_purple
};
public static int[] getColors(Context context) {
if (colors != null) {
return colors;
}
colors = new int[colorsIds.length];
for (int i = 0; i < colorsIds.length; i++) {
colors[i] = ContextCompat.getColor(context, colorsIds[i]);
}
return colors;
}
public static int getColorId(int colorIndex) {
return (colorIndex >= 0 && colorIndex < colorsIds.length) ? colorsIds[colorIndex] : colorsIds[0];
}
}
}
}

View file

@ -20,8 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;

View file

@ -7,7 +7,6 @@ import net.osmand.data.LatLon;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.routing.RouteCalculationParams;
import net.osmand.plus.routing.RouteCalculationResult;

View file

@ -4,8 +4,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersSortByDef;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;

View file

@ -39,8 +39,6 @@ import net.osmand.TspAnt;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;

View file

@ -13,8 +13,6 @@ import net.osmand.GPXUtilities.WptPt;
import net.osmand.IndexConstants;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;

View file

@ -0,0 +1,5 @@
package net.osmand.plus.mapmarkers;
public class ShowHideHistoryButton {
public boolean showHistory;
}

View file

@ -13,9 +13,8 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
@ -215,7 +214,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
final int pos = holder.getAdapterPosition();
final MapMarker marker = getItem(pos);
mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory(marker);
MapMarkersHelper.MapMarkersGroup group = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkerGroupById(marker.groupKey,
MapMarkersGroup group = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkerGroupById(marker.groupKey,
MapMarkersGroup.ANY_TYPE);
if (group != null) {
mapActivity.getMyApplication().getMapMarkersHelper().updateGroup(group);

View file

@ -21,11 +21,12 @@ import net.osmand.IndexConstants;
import net.osmand.data.LatLon;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.GroupHeader;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton;
import net.osmand.plus.mapmarkers.CategoriesSubHeader;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.GroupHeader;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.mapmarkers.ShowHideHistoryButton;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -159,7 +160,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
items.add(header);
if (!group.isDisabled()) {
if (group.getWptCategories() != null && !group.getWptCategories().isEmpty()) {
MapMarkersHelper.CategoriesSubHeader categoriesSubHeader = group.getCategoriesSubHeader();
CategoriesSubHeader categoriesSubHeader = group.getCategoriesSubHeader();
items.add(categoriesSubHeader);
}
TravelDbHelper travelDbHelper = mapActivity.getMyApplication().getTravelDbHelper();
@ -526,8 +527,8 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} else if (holder instanceof MapMarkerCategoriesViewHolder) {
final MapMarkerCategoriesViewHolder categoriesViewHolder = (MapMarkerCategoriesViewHolder) holder;
final Object header = getItem(position);
if (header instanceof MapMarkersHelper.CategoriesSubHeader) {
final MapMarkersHelper.CategoriesSubHeader categoriesSubHeader = (MapMarkersHelper.CategoriesSubHeader) header;
if (header instanceof CategoriesSubHeader) {
final CategoriesSubHeader categoriesSubHeader = (CategoriesSubHeader) header;
final MapMarkersGroup group = categoriesSubHeader.getGroup();
View.OnClickListener openChooseCategoriesDialog = new View.OnClickListener() {
@Override
@ -599,7 +600,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
return HEADER_TYPE;
} else if (item instanceof ShowHideHistoryButton) {
return SHOW_HIDE_HISTORY_TYPE;
} else if (item instanceof MapMarkersHelper.CategoriesSubHeader) {
} else if (item instanceof CategoriesSubHeader) {
return CATEGORIES_TYPE;
} else {
throw new IllegalArgumentException("Unsupported view type");

View file

@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;

View file

@ -17,7 +17,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;

View file

@ -28,8 +28,8 @@ import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.EditFavoriteGroupDialogFragment.FavoriteColorAdapter;

View file

@ -54,8 +54,8 @@ import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;

View file

@ -27,8 +27,8 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;

View file

@ -51,7 +51,7 @@ import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -14,7 +14,7 @@ import androidx.appcompat.view.ContextThemeWrapper;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities;

View file

@ -16,5 +16,7 @@ public enum ExportSettingsType {
OFFLINE_MAPS,
FAVORITES,
TTS_VOICE,
VOICE
VOICE,
ACTIVE_MARKERS,
HISTORY_MARKERS
}

View file

@ -16,10 +16,7 @@ import net.osmand.plus.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@ -69,11 +66,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
return ctx.getString(R.string.shared_string_favorites);
}
@NonNull
public String getDefaultFileName() {
return getName() + getDefaultFileExtension();
}
@NonNull
public String getDefaultFileExtension() {
return GPX_FILE_EXT;
@ -177,21 +169,9 @@ public class FavoritesSettingsItem extends CollectionSettingsItem<FavoriteGroup>
@Nullable
@Override
SettingsItemWriter<FavoritesSettingsItem> getWriter() {
return new SettingsItemWriter<FavoritesSettingsItem>(this) {
@Override
public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException {
List<FavouritePoint> favourites = getPointsFromGroups(items);
GPXFile gpxFile = favoritesHelper.asGpxFile(favourites);
Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile);
if (error != null) {
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed write to gpx file", error);
return false;
}
return true;
}
};
SettingsItemWriter<? extends SettingsItem> getWriter() {
List<FavouritePoint> favourites = getPointsFromGroups(items);
GPXFile gpxFile = favoritesHelper.asGpxFile(favourites);
return getGpxWriter(gpxFile);
}
}

View file

@ -0,0 +1,160 @@
package net.osmand.plus.settings.backend.backup;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.util.Algorithms;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.IndexConstants.GPX_FILE_EXT;
public class HistoryMarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
private MapMarkersHelper markersHelper;
public HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List<MapMarker> items) {
super(app, null, items);
}
public HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @Nullable HistoryMarkersSettingsItem baseItem, @NonNull List<MapMarker> items) {
super(app, baseItem, items);
}
HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
super(app, json);
}
@Override
protected void init() {
super.init();
markersHelper = app.getMapMarkersHelper();
existingItems = new ArrayList<>(markersHelper.getMapMarkersHistory());
}
@NonNull
@Override
public SettingsItemType getType() {
return SettingsItemType.HISTORY_MARKERS;
}
@NonNull
@Override
public String getName() {
return "history_markers";
}
@NonNull
@Override
public String getPublicName(@NonNull Context ctx) {
return ctx.getString(R.string.markers_history);
}
@NonNull
public String getDefaultFileExtension() {
return GPX_FILE_EXT;
}
@Override
public void apply() {
List<MapMarker> newItems = getNewItems();
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
appliedItems = new ArrayList<>(newItems);
for (MapMarker duplicate : duplicateItems) {
if (shouldReplace) {
MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point);
markersHelper.removeMarker(existingMarker);
}
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
}
for (MapMarker marker : appliedItems) {
markersHelper.moveMapMarkerToHistory(marker);
}
}
}
@Override
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
for (MapMarker marker : existingItems) {
if (marker.equals(mapMarker)
&& Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) {
return true;
}
}
return false;
}
@Override
public boolean shouldReadOnCollecting() {
return true;
}
@NonNull
@Override
public MapMarker renameItem(@NonNull MapMarker item) {
int number = 0;
while (true) {
number++;
String name = item.getOnlyName() + "_" + number;
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index);
if (!isDuplicate(renamedMarker)) {
renamedMarker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
return renamedMarker;
}
}
}
public MapMarkersGroup getMarkersGroup() {
String name = app.getString(R.string.markers_history);
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
markersGroup.setMarkers(items);
return markersGroup;
}
@Nullable
@Override
SettingsItemReader<HistoryMarkersSettingsItem> getReader() {
return new SettingsItemReader<HistoryMarkersSettingsItem>(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException {
GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream);
if (gpxFile.error != null) {
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error);
} else {
List<MapMarker> mapMarkers = markersHelper.readMarkersFromGpx(gpxFile, true);
items.addAll(mapMarkers);
}
}
};
}
@Nullable
@Override
SettingsItemWriter<? extends SettingsItem> getWriter() {
GPXFile gpxFile = markersHelper.generateGpx(items, true);
return getGpxWriter(gpxFile);
}
}

View file

@ -0,0 +1,160 @@
package net.osmand.plus.settings.backend.backup;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.util.Algorithms;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.IndexConstants.GPX_FILE_EXT;
public class MarkersSettingsItem extends CollectionSettingsItem<MapMarker> {
private MapMarkersHelper markersHelper;
public MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List<MapMarker> items) {
super(app, null, items);
}
public MarkersSettingsItem(@NonNull OsmandApplication app, @Nullable MarkersSettingsItem baseItem, @NonNull List<MapMarker> items) {
super(app, baseItem, items);
}
MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
super(app, json);
}
@Override
protected void init() {
super.init();
markersHelper = app.getMapMarkersHelper();
existingItems = new ArrayList<>(markersHelper.getMapMarkers());
}
@NonNull
@Override
public SettingsItemType getType() {
return SettingsItemType.ACTIVE_MARKERS;
}
@NonNull
@Override
public String getName() {
return "markers";
}
@NonNull
@Override
public String getPublicName(@NonNull Context ctx) {
return ctx.getString(R.string.map_markers);
}
@NonNull
public String getDefaultFileExtension() {
return GPX_FILE_EXT;
}
@Override
public void apply() {
List<MapMarker> newItems = getNewItems();
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
appliedItems = new ArrayList<>(newItems);
for (MapMarker duplicate : duplicateItems) {
if (shouldReplace) {
MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point);
markersHelper.removeMarker(existingMarker);
}
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
}
for (MapMarker marker : appliedItems) {
markersHelper.addMarker(marker);
}
}
}
@Override
public boolean isDuplicate(@NonNull MapMarker mapMarker) {
for (MapMarker marker : existingItems) {
if (marker.equals(mapMarker)
&& Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) {
return true;
}
}
return false;
}
@Override
public boolean shouldReadOnCollecting() {
return true;
}
@NonNull
@Override
public MapMarker renameItem(@NonNull MapMarker item) {
int number = 0;
while (true) {
number++;
String name = item.getOnlyName() + "_" + number;
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name);
MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index);
if (!isDuplicate(renamedMarker)) {
renamedMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
return renamedMarker;
}
}
}
public MapMarkersGroup getMarkersGroup() {
String name = app.getString(R.string.map_markers);
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
markersGroup.setMarkers(items);
return markersGroup;
}
@Nullable
@Override
SettingsItemReader<MarkersSettingsItem> getReader() {
return new SettingsItemReader<MarkersSettingsItem>(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException {
GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream);
if (gpxFile.error != null) {
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error);
} else {
List<MapMarker> mapMarkers = markersHelper.readMarkersFromGpx(gpxFile, false);
items.addAll(mapMarkers);
}
}
};
}
@Nullable
@Override
SettingsItemWriter<? extends SettingsItem> getWriter() {
GPXFile gpxFile = markersHelper.generateGpx(items, true);
return getGpxWriter(gpxFile);
}
}

View file

@ -18,6 +18,7 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo;
@ -28,6 +29,8 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmedit.OsmNotesPoint;
@ -594,6 +597,22 @@ public class SettingsHelper {
if (!files.isEmpty()) {
dataList.put(ExportSettingsType.VOICE, files);
}
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers();
if (!mapMarkers.isEmpty()) {
String name = app.getString(R.string.map_markers);
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
markersGroup.setMarkers(mapMarkers);
dataList.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
}
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersHistory();
if (!markersHistory.isEmpty()) {
String name = app.getString(R.string.shared_string_history);
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE);
markersGroup.setMarkers(markersHistory);
dataList.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
}
return dataList;
}
@ -633,6 +652,8 @@ public class SettingsHelper {
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
for (Object object : data) {
if (object instanceof QuickAction) {
@ -657,6 +678,13 @@ public class SettingsHelper {
osmEditsPointList.add((OpenstreetmapPoint) object);
} else if (object instanceof FavoriteGroup) {
favoriteGroups.add((FavoriteGroup) object);
} else if (object instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
markersGroups.add((MapMarkersGroup) object);
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
markersHistoryGroups.add((MapMarkersGroup) object);
}
}
}
if (!quickActions.isEmpty()) {
@ -688,6 +716,20 @@ public class SettingsHelper {
if (!favoriteGroups.isEmpty()) {
settingsItems.add(new FavoritesSettingsItem(app, favoriteGroups));
}
if (!markersGroups.isEmpty()) {
List<MapMarker> mapMarkers = new ArrayList<>();
for (MapMarkersGroup group : markersGroups) {
mapMarkers.addAll(group.getMarkers());
}
settingsItems.add(new MarkersSettingsItem(app, mapMarkers));
}
if (!markersHistoryGroups.isEmpty()) {
List<MapMarker> mapMarkers = new ArrayList<>();
for (MapMarkersGroup group : markersHistoryGroups) {
mapMarkers.addAll(group.getMarkers());
}
settingsItems.add(new HistoryMarkersSettingsItem(app, mapMarkers));
}
return settingsItems;
}
@ -709,6 +751,8 @@ public class SettingsHelper {
List<OsmNotesPoint> notesPointList = new ArrayList<>();
List<OpenstreetmapPoint> editsPointList = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
for (SettingsItem item : settingsItems) {
switch (item.getType()) {
@ -788,6 +832,14 @@ public class SettingsHelper {
FavoritesSettingsItem favoritesSettingsItem = (FavoritesSettingsItem) item;
favoriteGroups.addAll(favoritesSettingsItem.getItems());
break;
case ACTIVE_MARKERS:
MarkersSettingsItem markersSettingsItem = (MarkersSettingsItem) item;
markersGroups.add(markersSettingsItem.getMarkersGroup());
break;
case HISTORY_MARKERS:
HistoryMarkersSettingsItem historyMarkersSettingsItem = (HistoryMarkersSettingsItem) item;
markersHistoryGroups.add(historyMarkersSettingsItem.getMarkersGroup());
break;
default:
break;
}
@ -841,6 +893,12 @@ public class SettingsHelper {
if (!voiceFilesList.isEmpty()) {
settingsToOperate.put(ExportSettingsType.VOICE, voiceFilesList);
}
if (!markersGroups.isEmpty()) {
settingsToOperate.put(ExportSettingsType.ACTIVE_MARKERS, markersGroups);
}
if (!markersGroups.isEmpty()) {
settingsToOperate.put(ExportSettingsType.HISTORY_MARKERS, markersHistoryGroups);
}
return settingsToOperate;
}

View file

@ -5,7 +5,10 @@ import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import org.json.JSONException;
@ -17,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
@ -205,6 +209,7 @@ public abstract class SettingsItem {
String s = json.toString(2);
outputStream.write(s.getBytes("UTF-8"));
} catch (JSONException e) {
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed to write json to stream", e);
}
return true;
@ -214,6 +219,22 @@ public abstract class SettingsItem {
};
}
@NonNull
SettingsItemWriter<? extends SettingsItem> getGpxWriter(@NonNull final GPXFile gpxFile) {
return new SettingsItemWriter<SettingsItem>(this) {
@Override
public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException {
Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile);
if (error != null) {
warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed write to gpx file", error);
return false;
}
return true;
}
};
}
@Override
public int hashCode() {
return (getType().name() + getName()).hashCode();

View file

@ -15,5 +15,7 @@ public enum SettingsItemType {
DOWNLOADS,
OSM_NOTES,
OSM_EDITS,
FAVOURITES
FAVOURITES,
ACTIVE_MARKERS,
HISTORY_MARKERS
}

View file

@ -134,6 +134,12 @@ class SettingsItemsFactory {
case FAVOURITES:
item = new FavoritesSettingsItem(app, json);
break;
case ACTIVE_MARKERS:
item = new MarkersSettingsItem(app, json);
break;
case HISTORY_MARKERS:
item = new HistoryMarkersSettingsItem(app, json);
break;
}
return item;
}

View file

@ -14,20 +14,21 @@ import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.map.ITileSource;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -35,7 +36,7 @@ import org.apache.commons.logging.Log;
import java.io.File;
import java.util.List;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype;
public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -155,6 +156,10 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
} else if (currentItem instanceof FavoriteGroup) {
itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
} else if (currentItem instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) currentItem;
itemHolder.title.setText(markersGroup.getName());
itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
}
itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
}

View file

@ -302,6 +302,14 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
setupIcon(icon, R.drawable.ic_action_volume_up, itemSelected);
break;
case ACTIVE_MARKERS:
title.setText(R.string.map_markers);
setupIcon(icon, R.drawable.ic_action_flag, itemSelected);
break;
case HISTORY_MARKERS:
title.setText(R.string.markers_history);
setupIcon(icon, R.drawable.ic_action_flag, itemSelected);
break;
default:
return child;
}
@ -402,6 +410,10 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
return R.string.local_indexes_cat_tts;
case VOICE:
return R.string.local_indexes_cat_voice;
case ACTIVE_MARKERS:
return R.string.map_markers;
case HISTORY_MARKERS:
return R.string.markers_history;
default:
return R.string.access_empty_list;
}

View file

@ -32,11 +32,13 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.plus.settings.backend.backup.SettingsHelper;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
@ -48,7 +50,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*;
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype;
import static net.osmand.plus.settings.fragments.ImportSettingsFragment.IMPORT_SETTINGS_TAG;
@ -200,6 +202,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>();
List<File> mapFilesList = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
for (Object object : duplicatesList) {
if (object instanceof ApplicationMode.ApplicationModeBean) {
@ -236,6 +240,13 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
osmNotesPointList.add((OsmNotesPoint) object);
} else if (object instanceof OpenstreetmapPoint) {
osmEditsPointList.add((OpenstreetmapPoint) object);
} else if (object instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
markersGroups.add(markersGroup);
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
markersHistoryGroups.add(markersGroup);
}
}
}
if (!profiles.isEmpty()) {
@ -298,6 +309,14 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment {
duplicates.add(getString(R.string.local_indexes_cat_voice));
duplicates.addAll(voiceFilesList);
}
if (!markersGroups.isEmpty()) {
duplicates.add(getString(R.string.map_markers));
duplicates.addAll(markersGroups);
}
if (!markersHistoryGroups.isEmpty()) {
duplicates.add(getString(R.string.markers_history));
duplicates.addAll(markersHistoryGroups);
}
return duplicates;
}

View file

@ -41,25 +41,29 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.settings.backend.ExportSettingsType;
import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem;
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsHelper;
import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
import net.osmand.plus.settings.backend.backup.QuickActionsSettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsHelper;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType;
import net.osmand.plus.settings.backend.backup.SettingsItem;
import net.osmand.plus.settings.backend.backup.SettingsItemType;
import net.osmand.plus.widgets.TextViewEx;
@ -436,6 +440,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<MapMarkersGroup> markersGroups = new ArrayList<>();
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
for (Object object : data) {
if (object instanceof ApplicationModeBean) {
appModeBeans.add((ApplicationModeBean) object);
@ -459,6 +465,13 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
favoriteGroups.add((FavoriteGroup) object);
} else if (object instanceof GlobalSettingsItem) {
settingsItems.add((GlobalSettingsItem) object);
} else if (object instanceof MapMarkersGroup) {
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
markersGroups.add((MapMarkersGroup) object);
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
markersHistoryGroups.add((MapMarkersGroup) object);
}
}
}
if (!appModeBeans.isEmpty()) {
@ -490,6 +503,23 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class);
settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups));
}
if (!markersGroups.isEmpty()) {
List<MapMarker> mapMarkers = new ArrayList<>();
for (MapMarkersGroup group : markersGroups) {
mapMarkers.addAll(group.getMarkers());
}
MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.ACTIVE_MARKERS, MarkersSettingsItem.class);
settingsItems.add(new MarkersSettingsItem(app, baseItem, mapMarkers));
}
if (!markersHistoryGroups.isEmpty()) {
List<MapMarker> mapMarkers = new ArrayList<>();
for (MapMarkersGroup group : markersHistoryGroups) {
mapMarkers.addAll(group.getMarkers());
}
HistoryMarkersSettingsItem baseItem = getBaseItem(SettingsItemType.HISTORY_MARKERS, HistoryMarkersSettingsItem.class);
settingsItems.add(new HistoryMarkersSettingsItem(app, baseItem, mapMarkers));
}
return settingsItems;
}

View file

@ -142,6 +142,14 @@ public class ImportedSettingsItemsAdapter extends
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_settings, activeColorRes));
holder.title.setText(R.string.general_settings_2);
break;
case ACTIVE_MARKERS:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_flag, activeColorRes));
holder.title.setText(R.string.map_markers);
break;
case HISTORY_MARKERS:
holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_flag, activeColorRes));
holder.title.setText(R.string.markers_history);
break;
}
}

View file

@ -17,8 +17,8 @@ import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.PointImageDrawable;

View file

@ -37,9 +37,9 @@ import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;

View file

@ -31,8 +31,8 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;

View file

@ -9,8 +9,8 @@ import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;

View file

@ -12,7 +12,7 @@ import android.view.View;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;