Mark as passed to favorites
This commit is contained in:
parent
e7d2e9d2f4
commit
4ca520005a
8 changed files with 98 additions and 155 deletions
|
@ -16,14 +16,16 @@ import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.BooleanPreference;
|
|
||||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
|
import net.osmand.plus.settings.backend.BooleanPreference;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import static net.osmand.plus.itinerary.ItineraryHelper.PASSED_TIMESTAMP;
|
||||||
|
|
||||||
|
|
||||||
public class FavouritePoint implements Serializable, LocationPoint {
|
public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
private static final long serialVersionUID = 729654300829771466L;
|
private static final long serialVersionUID = 729654300829771466L;
|
||||||
|
@ -47,6 +49,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
private BackgroundType backgroundType = null;
|
private BackgroundType backgroundType = null;
|
||||||
private double altitude = Double.NaN;
|
private double altitude = Double.NaN;
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
private long passedTimestamp;
|
||||||
|
|
||||||
public FavouritePoint() {
|
public FavouritePoint() {
|
||||||
}
|
}
|
||||||
|
@ -90,6 +93,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
this.backgroundType = favouritePoint.backgroundType;
|
this.backgroundType = favouritePoint.backgroundType;
|
||||||
this.altitude = favouritePoint.altitude;
|
this.altitude = favouritePoint.altitude;
|
||||||
this.timestamp = favouritePoint.timestamp;
|
this.timestamp = favouritePoint.timestamp;
|
||||||
|
this.passedTimestamp = favouritePoint.passedTimestamp;
|
||||||
initPersonalType();
|
initPersonalType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +241,14 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getPassedTimestamp() {
|
||||||
|
return passedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassedTimestamp(long passedTimestamp) {
|
||||||
|
this.passedTimestamp = passedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
@ -322,8 +334,11 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
} else if (!originObjectName.equals(fp.originObjectName))
|
} else if (!originObjectName.equals(fp.originObjectName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (this.latitude == fp.latitude) && (this.longitude == fp.longitude) &&
|
return (this.latitude == fp.latitude)
|
||||||
(this.altitude == fp.altitude) && (this.timestamp == fp.timestamp);
|
&& (this.longitude == fp.longitude)
|
||||||
|
&& (this.altitude == fp.altitude)
|
||||||
|
&& (this.timestamp == fp.timestamp)
|
||||||
|
&& (this.passedTimestamp == fp.passedTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,6 +349,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
result = prime * result + (int) Math.floor(longitude * 10000);
|
result = prime * result + (int) Math.floor(longitude * 10000);
|
||||||
result = prime * result + (int) Math.floor(altitude * 10000);
|
result = prime * result + (int) Math.floor(altitude * 10000);
|
||||||
result = prime * result + (int) Math.floor(timestamp * 10000);
|
result = prime * result + (int) Math.floor(timestamp * 10000);
|
||||||
|
result = prime * result + (int) Math.floor(passedTimestamp * 10000);
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((category == null) ? 0 : category.hashCode());
|
result = prime * result + ((category == null) ? 0 : category.hashCode());
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
@ -467,6 +483,11 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
if (iconName != null) {
|
if (iconName != null) {
|
||||||
fp.setIconIdFromName(ctx, iconName);
|
fp.setIconIdFromName(ctx, iconName);
|
||||||
}
|
}
|
||||||
|
if (pt.getExtensionsToWrite().containsKey(PASSED_TIMESTAMP)) {
|
||||||
|
String time = pt.getExtensionsToWrite().get(PASSED_TIMESTAMP);
|
||||||
|
fp.setPassedTimestamp(Algorithms.parseLongSilently(time, 0));
|
||||||
|
}
|
||||||
|
|
||||||
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), null);
|
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), null);
|
||||||
fp.setBackgroundType(backgroundType);
|
fp.setBackgroundType(backgroundType);
|
||||||
return fp;
|
return fp;
|
||||||
|
@ -484,6 +505,9 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
||||||
if (isAddressSpecified()) {
|
if (isAddressSpecified()) {
|
||||||
pt.getExtensionsToWrite().put(ADDRESS_EXTENSION, getAddress());
|
pt.getExtensionsToWrite().put(ADDRESS_EXTENSION, getAddress());
|
||||||
}
|
}
|
||||||
|
if (getPassedTimestamp() != 0) {
|
||||||
|
pt.getExtensionsToWrite().put(PASSED_TIMESTAMP, String.valueOf(getPassedTimestamp()));
|
||||||
|
}
|
||||||
if (iconId != 0) {
|
if (iconId != 0) {
|
||||||
pt.setIconName(getIconEntryName(ctx).substring(3));
|
pt.setIconName(getIconEntryName(ctx).substring(3));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
import net.osmand.data.FavouritePoint.SpecialPointType;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
|
||||||
import net.osmand.plus.itinerary.ItineraryHelper;
|
import net.osmand.plus.itinerary.ItineraryHelper;
|
||||||
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
|
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
|
||||||
|
@ -238,7 +239,7 @@ public class FavouritesDbHelper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public FavouritePoint getSpecialPoint(FavouritePoint.SpecialPointType pointType) {
|
public FavouritePoint getSpecialPoint(SpecialPointType pointType) {
|
||||||
for (FavouritePoint fp : cachedFavoritePoints) {
|
for (FavouritePoint fp : cachedFavoritePoints) {
|
||||||
if (fp.getSpecialPointType() == pointType) {
|
if (fp.getSpecialPointType() == pointType) {
|
||||||
return fp;
|
return fp;
|
||||||
|
@ -710,6 +711,17 @@ public class FavouritesDbHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public FavouritePoint getFavByLatLon(@NonNull LatLon latLon, String name) {
|
||||||
|
for (FavouritePoint fav : cachedFavoritePoints) {
|
||||||
|
if (latLon.equals(new LatLon(fav.getLatitude(), fav.getLongitude()))
|
||||||
|
&& Algorithms.stringsEqual(fav.getName(), name)) {
|
||||||
|
return fav;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FavoriteGroup> getFavoriteGroups() {
|
public List<FavoriteGroup> getFavoriteGroups() {
|
||||||
return favoriteGroups;
|
return favoriteGroups;
|
||||||
}
|
}
|
||||||
|
@ -943,7 +955,7 @@ public class FavouritesDbHelper {
|
||||||
public void onUpgrade(SQLiteConnection db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteConnection db, int oldVersion, int newVersion) {
|
||||||
if (oldVersion == 1) {
|
if (oldVersion == 1) {
|
||||||
db.execSQL("ALTER TABLE " + FAVOURITE_TABLE_NAME + " ADD " + FAVOURITE_COL_CATEGORY + " text");
|
db.execSQL("ALTER TABLE " + FAVOURITE_TABLE_NAME + " ADD " + FAVOURITE_COL_CATEGORY + " text");
|
||||||
db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET category = ?", new Object[]{""}); //$NON-NLS-1$ //$NON-NLS-2$
|
db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET category = ?", new Object[] {""}); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,108 +996,4 @@ public class FavouritesDbHelper {
|
||||||
recalculateCachedFavPoints();
|
recalculateCachedFavPoints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteFavouriteDB(FavouritePoint p) {
|
|
||||||
SQLiteConnection db = openConnection(false);
|
|
||||||
if (db != null) {
|
|
||||||
try {
|
|
||||||
db.execSQL(
|
|
||||||
"DELETE FROM " + FAVOURITE_TABLE_NAME + " WHERE category = ? AND " + whereNameLatLon(), new Object[]{p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
FavouritePoint fp = findFavoriteByAllProperties(p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude());
|
|
||||||
if (fp != null) {
|
|
||||||
FavoriteGroup group = flatGroups.get(p.getCategory());
|
|
||||||
if (group != null) {
|
|
||||||
group.points.remove(fp);
|
|
||||||
}
|
|
||||||
cachedFavoritePoints.remove(fp);
|
|
||||||
}
|
|
||||||
saveCurrentPointsIntoFile();
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean addFavouriteDB(FavouritePoint p) {
|
|
||||||
if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SQLiteConnection db = openConnection(false);
|
|
||||||
if (db != null) {
|
|
||||||
try {
|
|
||||||
db.execSQL(
|
|
||||||
"INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", "
|
|
||||||
+ FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[]{p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
FavoriteGroup group = getOrCreateGroup(p, 0);
|
|
||||||
if (!p.getName().isEmpty()) {
|
|
||||||
p.setVisible(group.visible);
|
|
||||||
p.setColor(group.color);
|
|
||||||
group.points.add(p);
|
|
||||||
cachedFavoritePoints.add(p);
|
|
||||||
}
|
|
||||||
saveCurrentPointsIntoFile();
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean editFavouriteNameDB(FavouritePoint p, String newName, String category) {
|
|
||||||
SQLiteConnection db = openConnection(false);
|
|
||||||
if (db != null) {
|
|
||||||
try {
|
|
||||||
String oldCategory = p.getCategory();
|
|
||||||
db.execSQL(
|
|
||||||
"UPDATE " + FAVOURITE_TABLE_NAME + " SET " + FAVOURITE_COL_NAME + " = ?, " + FAVOURITE_COL_CATEGORY + "= ? WHERE " + whereNameLatLon(), new Object[]{newName, category, p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
p.setName(newName);
|
|
||||||
p.setCategory(category);
|
|
||||||
if (!oldCategory.equals(category)) {
|
|
||||||
FavoriteGroup old = flatGroups.get(oldCategory);
|
|
||||||
if (old != null) {
|
|
||||||
old.points.remove(p);
|
|
||||||
}
|
|
||||||
FavoriteGroup pg = getOrCreateGroup(p, 0);
|
|
||||||
p.setVisible(pg.visible);
|
|
||||||
p.setColor(pg.color);
|
|
||||||
pg.points.add(p);
|
|
||||||
}
|
|
||||||
sortAll();
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean editFavouriteDB(FavouritePoint p, double lat, double lon) {
|
|
||||||
SQLiteConnection db = openConnection(false);
|
|
||||||
if (db != null) {
|
|
||||||
try {
|
|
||||||
db.execSQL(
|
|
||||||
"UPDATE " + FAVOURITE_TABLE_NAME + " SET latitude = ?, longitude = ? WHERE " + whereNameLatLon(), new Object[]{lat, lon, p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
p.setLatitude(lat);
|
|
||||||
p.setLongitude(lon);
|
|
||||||
saveCurrentPointsIntoFile();
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String whereNameLatLon() {
|
|
||||||
String singleFavourite = " " + FAVOURITE_COL_NAME + "= ? AND " + FAVOURITE_COL_LAT + " = ? AND " + FAVOURITE_COL_LON + " = ?";
|
|
||||||
return singleFavourite;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
@ -51,6 +52,8 @@ public class ItineraryHelper {
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(ItineraryHelper.class);
|
private static final Log log = PlatformUtil.getLog(ItineraryHelper.class);
|
||||||
|
|
||||||
|
public static final String PASSED_TIMESTAMP = "passed_timestamp";
|
||||||
|
|
||||||
private static final String CATEGORIES_SPLIT = ",";
|
private static final String CATEGORIES_SPLIT = ",";
|
||||||
private static final String FILE_TO_SAVE = "itinerary.gpx";
|
private static final String FILE_TO_SAVE = "itinerary.gpx";
|
||||||
private static final String FILE_TO_BACKUP = "itinerary_bak.gpx";
|
private static final String FILE_TO_BACKUP = "itinerary_bak.gpx";
|
||||||
|
@ -75,12 +78,14 @@ public class ItineraryHelper {
|
||||||
|
|
||||||
public static class ItineraryItem {
|
public static class ItineraryItem {
|
||||||
|
|
||||||
public Object object;
|
public final Object object;
|
||||||
public ItineraryType type;
|
public final ItineraryType type;
|
||||||
|
public final ItineraryGroup group;
|
||||||
|
|
||||||
public ItineraryItem(Object object, ItineraryType type) {
|
public ItineraryItem(ItineraryGroup group, Object object, ItineraryType type) {
|
||||||
this.object = object;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.group = group;
|
||||||
|
this.object = object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ public class ItineraryHelper {
|
||||||
|
|
||||||
public String id;
|
public String id;
|
||||||
public String name;
|
public String name;
|
||||||
public ItineraryType type = ItineraryType.MARKERS;
|
public ItineraryType type = ItineraryType.POINTS;
|
||||||
public Set<String> wptCategories;
|
public Set<String> wptCategories;
|
||||||
public boolean disabled;
|
public boolean disabled;
|
||||||
|
|
||||||
|
@ -135,8 +140,10 @@ public class ItineraryHelper {
|
||||||
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(markersGroup.getId());
|
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(markersGroup.getId());
|
||||||
if (favoriteGroup != null) {
|
if (favoriteGroup != null) {
|
||||||
for (FavouritePoint favouritePoint : favoriteGroup.getPoints()) {
|
for (FavouritePoint favouritePoint : favoriteGroup.getPoints()) {
|
||||||
ItineraryItem itineraryItem = new ItineraryItem(favouritePoint, ItineraryType.FAVOURITES);
|
if (favouritePoint.getPassedTimestamp() == 0) {
|
||||||
itineraryGroup.itineraryItems.add(itineraryItem);
|
ItineraryItem itineraryItem = new ItineraryItem(itineraryGroup, favouritePoint, ItineraryType.FAVOURITES);
|
||||||
|
itineraryGroup.itineraryItems.add(itineraryItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
itineraryGroups.add(itineraryGroup);
|
itineraryGroups.add(itineraryGroup);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +162,7 @@ public class ItineraryHelper {
|
||||||
if (gpxFile != null && gpxFile.error == null) {
|
if (gpxFile != null && gpxFile.error == null) {
|
||||||
for (WptPt wptPt : gpxFile.getPoints()) {
|
for (WptPt wptPt : gpxFile.getPoints()) {
|
||||||
if (shouldAddWpt(wptPt, itineraryGroup.wptCategories)) {
|
if (shouldAddWpt(wptPt, itineraryGroup.wptCategories)) {
|
||||||
ItineraryItem itineraryItem = new ItineraryItem(wptPt, ItineraryType.TRACK);
|
ItineraryItem itineraryItem = new ItineraryItem(itineraryGroup, wptPt, ItineraryType.TRACK);
|
||||||
itineraryGroup.itineraryItems.add(itineraryItem);
|
itineraryGroup.itineraryItems.add(itineraryItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,16 +173,22 @@ public class ItineraryHelper {
|
||||||
|
|
||||||
private void syncMarkersGroup(ItineraryGroup itineraryGroup, MapMarkersGroup markersGroup) {
|
private void syncMarkersGroup(ItineraryGroup itineraryGroup, MapMarkersGroup markersGroup) {
|
||||||
for (MapMarker marker : markersGroup.getMarkers()) {
|
for (MapMarker marker : markersGroup.getMarkers()) {
|
||||||
ItineraryItem itineraryItem = new ItineraryItem(marker, ItineraryType.MARKERS);
|
if (!marker.history) {
|
||||||
itineraryGroup.itineraryItems.add(itineraryItem);
|
PointDescription pointDescription = marker.getOriginalPointDescription();
|
||||||
|
if (pointDescription == null || !pointDescription.isWpt() && !pointDescription.isFavorite()) {
|
||||||
|
ItineraryItem itineraryItem = new ItineraryItem(itineraryGroup, marker, ItineraryType.MARKERS);
|
||||||
|
itineraryGroup.itineraryItems.add(itineraryItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
itineraryGroups.add(itineraryGroup);
|
itineraryGroups.add(itineraryGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldAddWpt(WptPt wptPt, Set<String> wptCategories) {
|
private boolean shouldAddWpt(WptPt wptPt, Set<String> wptCategories) {
|
||||||
boolean addAll = wptCategories == null || wptCategories.isEmpty();
|
boolean addAll = wptCategories == null || wptCategories.isEmpty();
|
||||||
return addAll || wptCategories.contains(wptPt.category)
|
boolean passed = wptPt.getExtensionsToRead().containsKey(PASSED_TIMESTAMP);
|
||||||
|| wptPt.category == null && wptCategories.contains("");
|
return !passed && (addAll || wptCategories.contains(wptPt.category)
|
||||||
|
|| wptPt.category == null && wptCategories.contains(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadGroups() {
|
private void loadGroups() {
|
||||||
|
@ -480,6 +493,31 @@ public class ItineraryHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ItineraryItem getItineraryItem(@NonNull Object object) {
|
||||||
|
for (ItineraryGroup group : itineraryGroups) {
|
||||||
|
for (ItineraryItem item : group.itineraryItems) {
|
||||||
|
if (Algorithms.objectEquals(item.object, object)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ItineraryGroup getItineraryGroupById(String id, ItineraryType type) {
|
||||||
|
for (ItineraryGroup group : itineraryGroups) {
|
||||||
|
if ((id == null && group.id == null)
|
||||||
|
|| (group.id != null && group.id.equals(id))) {
|
||||||
|
if (type == ItineraryType.POINTS || type == group.type) {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public MapMarkersGroup getMapMarkerGroupById(String id, ItineraryType type) {
|
public MapMarkersGroup getMapMarkerGroupById(String id, ItineraryType type) {
|
||||||
for (MapMarkersGroup group : mapMarkersGroups) {
|
for (MapMarkersGroup group : mapMarkersGroups) {
|
||||||
|
|
|
@ -5,7 +5,8 @@ import androidx.annotation.NonNull;
|
||||||
public enum ItineraryType {
|
public enum ItineraryType {
|
||||||
MARKERS("markers", -1),
|
MARKERS("markers", -1),
|
||||||
FAVOURITES("favourites", 0),
|
FAVOURITES("favourites", 0),
|
||||||
TRACK("track", 1);
|
TRACK("track", 1),
|
||||||
|
POINTS("points", 2);
|
||||||
|
|
||||||
private int typeId;
|
private int typeId;
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
|
@ -79,11 +79,6 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
return fav;
|
return fav;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object getCorrespondingMapObject() {
|
|
||||||
return mapMarker;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportStopRoute> getTransportStopRoutes() {
|
public List<TransportStopRoute> getTransportStopRoutes() {
|
||||||
if (transportStopController != null) {
|
if (transportStopController != null) {
|
||||||
|
|
|
@ -84,11 +84,6 @@ public class WptPtMenuController extends MenuController {
|
||||||
return wpt;
|
return wpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object getCorrespondingMapObject() {
|
|
||||||
return mapMarker;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Override
|
@Override
|
||||||
public boolean handleSingleTapOnMap() {
|
public boolean handleSingleTapOnMap() {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
@ -24,13 +23,12 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask;
|
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.osmand.plus.mapcontextmenu.editors.WptPtEditorFragmentNew.saveGpx;
|
||||||
|
|
||||||
public class WptPtEditorFragment extends PointEditorFragment {
|
public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -372,20 +370,4 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
public int getPointColor() {
|
public int getPointColor() {
|
||||||
return color == 0 ? defaultColor : color;
|
return color == 0 ? defaultColor : color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) {
|
|
||||||
new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() {
|
|
||||||
@Override
|
|
||||||
public void gpxSavingStarted() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void gpxSavingFinished(Exception errorMessage) {
|
|
||||||
if (errorMessage == null && !gpxSelected) {
|
|
||||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) {
|
public static void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) {
|
||||||
new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() {
|
new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() {
|
||||||
@Override
|
@Override
|
||||||
public void gpxSavingStarted() {
|
public void gpxSavingStarted() {
|
||||||
|
|
Loading…
Reference in a new issue