From f31cb5480378624182ce79aab3fddbbfe394fde8 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 22 Aug 2017 15:47:41 -0400 Subject: [PATCH 1/3] Fix favourite import issues When importing as favourites the color was not being passed through. Override equals and hashcode in FavouritePoint to allow deleteFavourite to work correctly. This prevents duplicates if the same gpx file is imported more than once. --- .../src/net/osmand/data/FavouritePoint.java | 24 ++++++++++++++++++- .../osmand/plus/helpers/GpxImportHelper.java | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/data/FavouritePoint.java b/OsmAnd/src/net/osmand/data/FavouritePoint.java index fa9efc4585..431cfce5f0 100644 --- a/OsmAnd/src/net/osmand/data/FavouritePoint.java +++ b/OsmAnd/src/net/osmand/data/FavouritePoint.java @@ -121,4 +121,26 @@ public class FavouritePoint implements Serializable, LocationPoint { return "Favourite " + getName(); //$NON-NLS-1$ } -} \ No newline at end of file + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (!(o instanceof FavouritePoint)) return false; + + FavouritePoint fp = (FavouritePoint)o; + + return (this.latitude == fp.latitude) + && (this.longitude == fp.longitude) + && (this.name.equals(fp.name)); + } + + @Override + public int hashCode() { + int hash = (int)latitude*1000 + (int)longitude*1000; + hash += (name != null) ? name.hashCode() : 0; + return hash; + } + +} + diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index 1cae32b6bc..c42960194b 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -565,6 +565,7 @@ public class GpxImportHelper { if (p.desc != null) { fp.setDescription(p.desc); } + fp.setColor(p.getColor(0)); favourites.add(fp); } } From 657f6f9aafe08316711cbe668c9bf01d3555dc35 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 23 Aug 2017 22:55:24 +0200 Subject: [PATCH 2/3] Change from long to int #4307 --- OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java | 2 +- OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java | 2 +- OsmAnd/src/net/osmand/plus/helpers/DatabaseHelper.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java index 3685e5d2ca..f5f022371f 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java @@ -45,7 +45,7 @@ public interface SQLiteAPI { long getLong(int ind); - long getInt(int ind); + int getInt(int ind); byte[] getBlob(int ind); diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java index 3da132800b..66ad5b8356 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java @@ -87,7 +87,7 @@ public class SQLiteAPIImpl implements SQLiteAPI { } @Override - public long getInt(int ind) { + public int getInt(int ind) { return c.getInt(ind); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/DatabaseHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DatabaseHelper.java index 17b02c70eb..1b5ba08350 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DatabaseHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DatabaseHelper.java @@ -23,10 +23,10 @@ public class DatabaseHelper { private OsmandApplication app; public static class HistoryDownloadEntry { - long count; + int count; String name; - public HistoryDownloadEntry(String name, long count){ + public HistoryDownloadEntry(String name, int count){ this.count = count; this.name = name; @@ -36,7 +36,7 @@ public class DatabaseHelper { return name; } - public long getCount() { + public int getCount() { return count; } } From 9281b684c5454e8b88c4d59d3c930377480266fd Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 23 Aug 2017 23:26:22 +0200 Subject: [PATCH 3/3] Update strings.xml --- OsmAnd/res/values-da/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 84e8c41491..d2f9caef35 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -2834,8 +2834,8 @@ Tidligere destination bliver sidste mellemliggende punkt. Gem rutepunkt Rutepunkt 1 Rutepunkt 1 -Højde: %1$s - Hastighed: %1$ s + Højde: %1$s + Hastighed: %1$s Linje Gem som rutepunkt Gem som linje