diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index e27b3363b6..ae1c22b587 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -480,23 +480,12 @@ public class TravelLocalDataHelper { SQLiteConnection conn = openConnection(false); if (conn != null) { try { - String query; - Object[] parameters; - if (article.lang == null) { - query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + - " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + - " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + - " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; - parameters = new Object[]{article.title, article.routeId, travelBook}; - } else { - query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + - " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + - " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + - " AND " + BOOKMARKS_COL_LANG + " = ?" + - " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; - parameters = new Object[]{article.title, article.routeId, article.lang, travelBook}; - } - conn.execSQL(query, parameters); + String query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + + " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + + " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + + " AND " + BOOKMARKS_COL_LANG + ((article.lang != null) ? " = '" + article.lang + "'" : " IS NULL") + + " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; + conn.execSQL(query, new Object[]{article.title, article.routeId, travelBook}); } finally { conn.close(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 17dd2c71c0..69c1506b9b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -9,7 +9,6 @@ import androidx.annotation.Nullable; import net.osmand.Collator; import net.osmand.CollatorStringMatcher.StringMatcherMode; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.OsmAndCollator; @@ -49,6 +48,8 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import static net.osmand.GPXUtilities.Track; +import static net.osmand.GPXUtilities.TrkSegment; import static net.osmand.GPXUtilities.WptPt; import static net.osmand.GPXUtilities.writeGpxFile; import static net.osmand.plus.helpers.GpxUiHelper.getGpxTitle; @@ -69,6 +70,8 @@ public class TravelObfHelper implements TravelHelper { public static final int ARTICLE_SEARCH_RADIUS = 50000; public static final int GPX_TRACKS_SEARCH_RADIUS = 10000; public static final int MAX_POPULAR_ARTICLES_COUNT = 30; + public static final int REF_KEY = 2; + public static final int NAME_KEY = 1; private final OsmandApplication app; private final Collator collator; @@ -178,7 +181,7 @@ public class TravelObfHelper implements TravelHelper { TravelGpx res = new TravelGpx(); res.file = file; String title = amenity.getName("en"); - res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); + res.title = createTitle(Algorithms.isEmpty(title) ? amenity.getName() : title); res.lat = amenity.getLocation().getLatitude(); res.lon = amenity.getLocation().getLongitude(); res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); @@ -265,8 +268,8 @@ public class TravelObfHelper implements TravelHelper { @Override public boolean publish(BinaryMapDataObject object) { if (object.getPointsLength() > 1) { - if (object.getObjectNames().get(2).equals(ref) - && capitalizeFirstLetter(getGpxTitle(object.getObjectNames().get(1))).equals(article.title)) { + if (object.getObjectNames().get(REF_KEY).equals(ref) + && createTitle(object.getObjectNames().get(NAME_KEY)).equals(article.title)) { segmentList.add(object); } } @@ -288,17 +291,15 @@ public class TravelObfHelper implements TravelHelper { } GPXFile gpxFile = null; if (!segmentList.isEmpty()) { - GPXUtilities.Track track = new GPXUtilities.Track(); + Track track = new Track(); for (BinaryMapDataObject segment : segmentList) { - List pointList = new ArrayList<>(); - GPXUtilities.TrkSegment trkSegment = new GPXUtilities.TrkSegment(); + TrkSegment trkSegment = new TrkSegment(); for (int i = 0; i < segment.getPointsLength(); i++) { WptPt point = new WptPt(); point.lat = MapUtils.get31LatitudeY(segment.getPoint31YTile(i)); point.lon = MapUtils.get31LongitudeX(segment.getPoint31XTile(i)); - pointList.add(point); + trkSegment.points.add(point); } - trkSegment.points = pointList; track.segments.add(trkSegment); } gpxFile = new GPXFile(article.getTitle(), article.getLang(), ""); @@ -309,6 +310,10 @@ public class TravelObfHelper implements TravelHelper { return gpxFile; } + private String createTitle(String name) { + return capitalizeFirstLetter(getGpxTitle(name)); + } + @NonNull private synchronized List getPointList(@NonNull final TravelArticle article) { final List pointList = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index bbc0cb6da7..a01de6e6cb 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -11,7 +11,6 @@ import androidx.annotation.DrawableRes; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; @@ -26,7 +25,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; @@ -35,7 +33,6 @@ import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -61,7 +58,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter