From 17fd983091b58e82107187c8e2e9d7f7e0b0a885 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 11 Dec 2020 09:32:36 +0200 Subject: [PATCH 01/76] Add TravelObfHelper and bookmark --- .../src/net/osmand/plus/AppInitializer.java | 7 +- .../plus/resources/ResourceManager.java | 25 ++ .../data/TravelLocalDataHelper.java | 21 +- .../plus/wikivoyage/data/TravelObfHelper.java | 303 ++++++++++++++++++ 4 files changed, 347 insertions(+), 9 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 3a75558fe5..f8a5446efd 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -67,6 +67,7 @@ import net.osmand.plus.voice.MediaCommandPlayerImpl; import net.osmand.plus.voice.TTSCommandPlayerImpl; import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.data.TravelHelper; +import net.osmand.plus.wikivoyage.data.TravelObfHelper; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.RoutingConfiguration; import net.osmand.util.Algorithms; @@ -458,9 +459,9 @@ public class AppInitializer implements IProgress { app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class); - // TODOTRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper - app.travelHelper = new TravelDbHelper(app); - app.travelHelper.initializeDataOnAppStartup(); + app.travelHelper = app.getResourceManager().hasTravelObfFile() + ? new TravelObfHelper(app) + : new TravelDbHelper(app); app.travelHelper = startupInit(app.travelHelper, TravelHelper.class); app.lockHelper = startupInit(new LockHelper(app), LockHelper.class); diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 8e7857b33a..609ea7910d 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -19,8 +19,10 @@ import net.osmand.IndexConstants; import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; +import net.osmand.binary.BinaryIndexPart; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter; +import net.osmand.binary.BinaryMapPoiReaderAdapter; import net.osmand.binary.CachedOsmandIndexes; import net.osmand.data.Amenity; import net.osmand.data.RotatedTileBox; @@ -634,6 +636,8 @@ public class ResourceManager { collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files); if (Version.isPaidVersion(context)) { collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); + collectFiles(context.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), + IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, files); } if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(context)) { collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); @@ -1157,6 +1161,27 @@ public class ResourceManager { return maps != null && maps.length > 0; } + public BinaryMapIndexReader[] getTravelFiles() { + Collection fileReaders = getFileReaders(); + List readers = new ArrayList<>(fileReaders.size()); + for (BinaryMapReaderResource res : fileReaders) { + if (!res.filename.toString().toLowerCase().contains(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT)) { + continue; + } + BinaryMapIndexReader index = res.getReader(BinaryMapReaderResourceType.POI); + for (BinaryIndexPart p : index.getIndexes()) { + if (p instanceof BinaryMapPoiReaderAdapter.PoiRegion) { + readers.add(index); + } + } + } + return readers.toArray(new BinaryMapIndexReader[0]); + } + + public boolean hasTravelObfFile() { + return isMapsPresentInDirectory(IndexConstants.WIKIVOYAGE_INDEX_DIR); + } + public Map getBackupIndexes(Map map) { File file = context.getAppPath(IndexConstants.BACKUP_INDEX_DIR); if (file != null && file.isDirectory()) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 5743041407..d64bed4ebe 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -118,6 +118,7 @@ public class TravelLocalDataHelper { saved.content = WikiArticleHelper.getPartialContent(article.getContent()); saved.lat = article.lat; saved.lon = article.lon; + saved.routeId = article.routeId; savedArticles.add(saved); dbHelper.addSavedArticle(saved); notifySavedUpdated(); @@ -168,7 +169,7 @@ public class TravelLocalDataHelper { private static class WikivoyageLocalDataDbHelper { - private static final int DB_VERSION = 4; + private static final int DB_VERSION = 5; private static final String DB_NAME = "wikivoyage_local_data"; private static final String HISTORY_TABLE_NAME = "wikivoyage_search_history"; @@ -202,6 +203,7 @@ public class TravelLocalDataHelper { private static final String BOOKMARKS_COL_TRAVEL_BOOK = "travel_book"; private static final String BOOKMARKS_COL_LAT = "lat"; private static final String BOOKMARKS_COL_LON = "lon"; + private static final String BOOKMARKS_COL_ROUTE_ID = "route_id"; private static final String BOOKMARKS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + BOOKMARKS_TABLE_NAME + " (" + @@ -212,7 +214,8 @@ public class TravelLocalDataHelper { BOOKMARKS_COL_PARTIAL_CONTENT + " TEXT, " + BOOKMARKS_COL_TRAVEL_BOOK + " TEXT, " + BOOKMARKS_COL_LAT + " double, " + - BOOKMARKS_COL_LON + " double);"; + BOOKMARKS_COL_LON + " double, " + + BOOKMARKS_COL_ROUTE_ID + " TEXT" + ");"; private static final String BOOKMARKS_TABLE_SELECT = "SELECT " + BOOKMARKS_COL_ARTICLE_TITLE + ", " + @@ -221,7 +224,8 @@ public class TravelLocalDataHelper { BOOKMARKS_COL_IMAGE_TITLE + ", " + BOOKMARKS_COL_PARTIAL_CONTENT + ", " + BOOKMARKS_COL_LAT + ", " + - BOOKMARKS_COL_LON + + BOOKMARKS_COL_LON + ", " + + BOOKMARKS_COL_ROUTE_ID + " FROM " + BOOKMARKS_TABLE_NAME; private final OsmandApplication context; @@ -271,6 +275,9 @@ public class TravelLocalDataHelper { conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_LAT + " double"); conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_LON + " double"); } + if (oldVersion < 5) { + conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_ROUTE_ID + " TEXT"); + } } @NonNull @@ -420,11 +427,12 @@ public class TravelLocalDataHelper { BOOKMARKS_COL_PARTIAL_CONTENT + ", " + BOOKMARKS_COL_TRAVEL_BOOK + ", " + BOOKMARKS_COL_LAT + ", " + - BOOKMARKS_COL_LON + - ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + BOOKMARKS_COL_LON + ", " + + BOOKMARKS_COL_ROUTE_ID + + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; conn.execSQL(query, new Object[]{article.title, article.lang, article.aggregatedPartOf, article.imageTitle, article.content, - travelBook, article.lat, article.lon}); + travelBook, article.lat, article.lon, article.routeId}); } finally { conn.close(); } @@ -475,6 +483,7 @@ public class TravelLocalDataHelper { res.content = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_PARTIAL_CONTENT)); res.lat = cursor.getDouble(cursor.getColumnIndex(BOOKMARKS_COL_LAT)); res.lon = cursor.getDouble(cursor.getColumnIndex(BOOKMARKS_COL_LON)); + res.routeId = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_ROUTE_ID)); return res; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java new file mode 100644 index 0000000000..e47a939781 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -0,0 +1,303 @@ +package net.osmand.plus.wikivoyage.data; + +import androidx.annotation.NonNull; + +import net.osmand.GPXUtilities; +import net.osmand.IndexConstants; +import net.osmand.PlatformUtil; +import net.osmand.ResultMatcher; +import net.osmand.binary.BinaryIndexPart; +import net.osmand.binary.BinaryMapIndexReader; +import net.osmand.binary.BinaryMapPoiReaderAdapter; +import net.osmand.data.Amenity; +import net.osmand.data.LatLon; +import net.osmand.plus.OsmandApplication; +import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; + +import org.apache.commons.logging.Log; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +public class TravelObfHelper implements TravelHelper { + + private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); + public static final String ROUTE_ARTICLE = "route_article"; + + private final OsmandApplication app; + + private File selectedTravelBook = null; + private List existingTravelBooks = new ArrayList<>(); + private List popularArticles = new ArrayList<>(); + private Map cachedArticles; + private TravelLocalDataHelper localDataHelper; + + public TravelObfHelper(OsmandApplication app) { + this.app = app; + localDataHelper = new TravelLocalDataHelper(app); + cachedArticles = new HashMap<>(); + } + + + @Override + public TravelLocalDataHelper getBookmarksHelper() { + return localDataHelper; + } + + @Override + public void initializeDataOnAppStartup() { + + BinaryMapIndexReader[] readers = app.getResourceManager().getTravelFiles(); + String travelBook = app.getSettings().SELECTED_TRAVEL_BOOK.get(); + existingTravelBooks.clear(); + if (readers != null) { + for (BinaryMapIndexReader reader : readers) { + File f = reader.getFile(); + existingTravelBooks.add(f); + if (selectedTravelBook == null) { + selectedTravelBook = f; + } else if (Algorithms.objectEquals(travelBook, f.getName())) { + selectedTravelBook = f; + } + selectedTravelBook = reader.getFile(); + } + } + } + + @Override + public void initializeDataToDisplay() { + localDataHelper.refreshCachedData(); + loadPopularArticles(); + } + + //TODO for now it reads any articles, since we didn't have popular articles in the obf + @NonNull + public List loadPopularArticles() { + String language = app.getLanguage(); + final List articles = new ArrayList<>(); + try { + BinaryMapIndexReader bookIndexReader = getBookBinaryIndex(); + if (bookIndexReader == null) { + popularArticles = new ArrayList<>(); + return popularArticles; + } + LatLon ll = app.getMapViewTrackingUtilities().getMapLocation(); + float coeff = 2; + BinaryMapIndexReader.SearchRequest req = + BinaryMapIndexReader.buildSearchPoiRequest( + MapUtils.get31TileNumberX(ll.getLongitude() - coeff), + MapUtils.get31TileNumberX(ll.getLongitude() + coeff), + MapUtils.get31TileNumberY(ll.getLatitude() + coeff), + MapUtils.get31TileNumberY(ll.getLatitude() - coeff), + -1, + BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, + new ResultMatcher() { + int count = 0; + + @Override + public boolean publish(Amenity object) { + //TODO need more logical way to filter results + if (object.getSubType().equals(ROUTE_ARTICLE)) { + articles.add(object); + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + + bookIndexReader.searchPoi(req); + bookIndexReader.close(); + + if (articles.size() > 0) { + Iterator it = articles.iterator(); + while (it.hasNext()) { + Amenity a = it.next(); + if (!a.getName(language).equals("")) { + TravelArticle article = readArticle(a, language); + popularArticles.add(article); + cachedArticles.put(article.routeId, article); + } + } + } + } catch (Exception e) { + LOG.error(e.getMessage()); + } + return popularArticles; + } + + + private TravelArticle readArticle(Amenity amenity, String lang) { + TravelArticle res = new TravelArticle(); + + res.title = amenity.getName(lang).equals("") ? amenity.getName() : amenity.getName(lang); + res.content = amenity.getDescription(lang); + res.isPartOf = amenity.getTagContent(Amenity.IS_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_PART, lang); + res.lat = amenity.getLocation().getLatitude(); + res.lon = amenity.getLocation().getLongitude(); + res.imageTitle = amenity.getTagContent(Amenity.IMAGE_TITLE, lang) == null ? "" : amenity.getTagContent(Amenity.IMAGE_TITLE, lang); + res.routeId = getRouteId(amenity); + res.originalId = 0; //? + res.lang = lang; + res.contentsJson = amenity.getTagContent(Amenity.CONTENT_JSON, lang) == null ? "" : amenity.getTagContent(Amenity.CONTENT_JSON, lang); + res.aggregatedPartOf = amenity.getTagContent(Amenity.IS_AGGR_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_AGGR_PART, lang); + +// occasional crashes +// try { +// String gpxContent = amenity.getAdditionalInfo("gpx_info"); +// res.gpxFile = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxContent.getBytes("UTF-8"))); +// } catch (IOException e) { +// LOG.error(e.getMessage(), e); +// } + + return res; + } + + private String getRouteId(Amenity amenity) { + return amenity.getTagContent(Amenity.ROUTE_ID, null); + } + + + private BinaryMapIndexReader getBookBinaryIndex() throws IOException { + app.getSettings().SELECTED_TRAVEL_BOOK.set(selectedTravelBook.getName()); + try { + RandomAccessFile r = new RandomAccessFile(selectedTravelBook.getAbsolutePath(), "r"); + BinaryMapIndexReader index = new BinaryMapIndexReader(r, selectedTravelBook); + for (BinaryIndexPart p : index.getIndexes()) { + if (p instanceof BinaryMapPoiReaderAdapter.PoiRegion) { + return index; + } + } + } catch (IOException e) { + System.err.println("File doesn't have valid structure : " + selectedTravelBook.getName() + " " + e.getMessage()); + throw e; + } + return null; + } + + @Override + public boolean isAnyTravelBookPresent() { + return selectedTravelBook != null; + } + + @NonNull + @Override + public List search(String searchQuery) { + return null; + } + + @NonNull + @Override + public List getPopularArticles() { + return popularArticles; + } + + @Override + public Map> getNavigationMap(TravelArticle article) { + return null; + } + + @Override + public TravelArticle getArticleById(String routeId, String lang) { + TravelArticle article = cachedArticles.get(routeId); + if (article != null) { + return article; + } + String name = ""; //??? + return getArticleByTitle(name, lang); + } + + @Override + public TravelArticle getArticleByTitle(final String title, final String lang) { + TravelArticle res = null; + List amenities = Collections.emptyList(); + try { + BinaryMapIndexReader indexReader = getBookBinaryIndex(); + if (indexReader != null) { + int left = 0; + int top = 0; + int right = Integer.MAX_VALUE; + int bottom = Integer.MAX_VALUE; + LatLon ll = app.getMapViewTrackingUtilities().getMapLocation(); + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + MapUtils.get31TileNumberX(ll.getLongitude()), + MapUtils.get31TileNumberY(ll.getLatitude()), title, + left, top, right, bottom, + new ResultMatcher() { + @Override + public boolean publish(Amenity object) { + if (object.getName(lang).equals(title)) { + return true; + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + + amenities = indexReader.searchPoiByName(req); + } + } catch (IOException e) { + //todo + } + if (!amenities.isEmpty()) { + for (Amenity a : amenities) { + LOG.debug("searched article: " + a); + } + } + return res; + } + + @Override + public String getArticleId(String title, String lang) { + return null; + } + + @Override + public ArrayList getArticleLangs(String articleId) { + ArrayList res = new ArrayList<>(); + res.add("en"); + + for (TravelArticle article : popularArticles) { + if (article.getRouteId() == articleId) { + res.add(article.getLang()); + } + } + return res; + } + + @Override + public String getGPXName(TravelArticle article) { + return article.getTitle().replace('/', '_').replace('\'', '_') + .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; + } + + @Override + public File createGpxFile(TravelArticle article) { + final GPXUtilities.GPXFile gpx = article.getGpxFile(); + File file = app.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); + if (!file.exists()) { + GPXUtilities.writeGpxFile(file, gpx); + } + return file; + } + + @Override + public String getSelectedTravelBookName() { + return ""; + } +} From bc501b609a9436dec44f18e90053feebd3eeffce Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 11 Dec 2020 10:08:41 +0200 Subject: [PATCH 02/76] Fix getArticleId --- .../plus/wikivoyage/data/TravelHelper.java | 2 +- .../plus/wikivoyage/data/TravelObfHelper.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 79df7bdfeb..12976ed666 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -36,7 +36,7 @@ public interface TravelHelper { String getArticleId(String title, String lang); - ArrayList getArticleLangs(String articleId); + ArrayList getArticleLangs(String routeId); String getGPXName(TravelArticle article); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index e47a939781..65fe1e88e6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -35,10 +35,10 @@ public class TravelObfHelper implements TravelHelper { private final OsmandApplication app; private File selectedTravelBook = null; - private List existingTravelBooks = new ArrayList<>(); + private final List existingTravelBooks = new ArrayList<>(); private List popularArticles = new ArrayList<>(); - private Map cachedArticles; - private TravelLocalDataHelper localDataHelper; + private final Map cachedArticles; + private final TravelLocalDataHelper localDataHelper; public TravelObfHelper(OsmandApplication app) { this.app = app; @@ -264,16 +264,20 @@ public class TravelObfHelper implements TravelHelper { @Override public String getArticleId(String title, String lang) { + for (TravelArticle article : popularArticles) { + if (article.getTitle().equals(title)) { + return article.getRouteId(); + } + } return null; } @Override - public ArrayList getArticleLangs(String articleId) { + public ArrayList getArticleLangs(String routeId) { ArrayList res = new ArrayList<>(); res.add("en"); - for (TravelArticle article : popularArticles) { - if (article.getRouteId() == articleId) { + if (article.getRouteId().equals(routeId)) { res.add(article.getLang()); } } From 275ef9f6225c638380c5261f7011329e26bbf690 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 11 Dec 2020 13:41:05 +0200 Subject: [PATCH 03/76] Fix update Bookmarked articles tab --- .../article/WikivoyageArticleDialogFragment.java | 6 ++++++ .../wikivoyage/explore/WikivoyageExploreActivity.java | 9 ++++++++- .../explore/travelcards/ArticleTravelCard.java | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 784c1ee8d4..074e9efd27 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.wikivoyage.article; import android.annotation.SuppressLint; +import android.app.Activity; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; @@ -43,6 +44,7 @@ import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; +import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity; import net.osmand.util.Algorithms; import java.io.File; @@ -248,6 +250,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme getMyApplication().getTravelHelper().createGpxFile(article); helper.addArticleToSaved(article); } + Activity activity = getActivity(); + if (activity instanceof WikivoyageExploreActivity) { + ((WikivoyageExploreActivity) activity).updateSavedArticles(); + } updateSaveButton(); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 73da16bf2e..d7ff7e4950 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -225,7 +225,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } @Nullable - private SavedArticlesTabFragment getSavedArticlesTabFragment() { + public SavedArticlesTabFragment getSavedArticlesTabFragment() { for (WeakReference ref : fragments) { Fragment f = ref.get(); if (f instanceof SavedArticlesTabFragment) { @@ -358,6 +358,13 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } } + public void updateSavedArticles() { + SavedArticlesTabFragment fragment = getSavedArticlesTabFragment(); + if(fragment!=null){ + fragment.savedArticlesUpdated(); + } + } + private static class LoadWikivoyageData extends AsyncTask { private WeakReference activityRef; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java index b9c5dbeb11..3812d239df 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java @@ -6,6 +6,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; @@ -22,6 +23,7 @@ import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; +import net.osmand.plus.wikivoyage.explore.SavedArticlesTabFragment; public class ArticleTravelCard extends BaseTravelCard { @@ -106,6 +108,7 @@ public class ArticleTravelCard extends BaseTravelCard { app.getTravelHelper().createGpxFile(article); helper.addArticleToSaved(article); } + updateSavedArticles(); updateSaveButton(holder); } } @@ -113,6 +116,14 @@ public class ArticleTravelCard extends BaseTravelCard { } } + void updateSavedArticles() { + for (Fragment fragment : fragmentManager.getFragments()) { + if (fragment instanceof SavedArticlesTabFragment) { + ((SavedArticlesTabFragment) fragment).savedArticlesUpdated(); + } + } + } + public static class ArticleTravelVH extends RecyclerView.ViewHolder { final TextView title; From bf6d3840067841e7ab72512ef38bd8c8b346674d Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 15 Dec 2020 19:31:01 +0200 Subject: [PATCH 04/76] add speed info to the navigation notification --- .../notifications/NavigationNotification.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java index d0632d812a..243d480b55 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java @@ -17,6 +17,7 @@ import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat.BigTextStyle; import androidx.core.app.NotificationCompat.Builder; +import net.osmand.Location; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -77,7 +78,7 @@ public class NavigationNotification extends OsmandNotification { RoutingHelper routingHelper = app.getRoutingHelper(); routingHelper.setRoutePlanningMode(false); routingHelper.setFollowingMode(true); - routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false); + routingHelper.setCurrentLocation(getLastKnownLocation(), false); } }, new IntentFilter(OSMAND_RESUME_NAVIGATION_SERVICE_ACTION)); @@ -133,13 +134,15 @@ public class NavigationNotification extends OsmandNotification { turnBitmap = null; ongoing = true; RoutingHelper routingHelper = app.getRoutingHelper(); + Location location = getLastKnownLocation(); if (service != null && (service.getUsedBy() & USED_BY_NAVIGATION) != 0) { color = app.getResources().getColor(R.color.osmand_orange); - String distanceStr = OsmAndFormatter.getFormattedDistance(app.getRoutingHelper().getLeftDistance(), app); - String timeStr = OsmAndFormatter.getFormattedDuration(app.getRoutingHelper().getLeftTime(), app); + String distanceStr = OsmAndFormatter.getFormattedDistance(routingHelper.getLeftDistance(), app); + String timeStr = OsmAndFormatter.getFormattedDuration(routingHelper.getLeftTime(), app); String etaStr = SimpleDateFormat.getTimeInstance(DateFormat.SHORT) - .format(new Date(System.currentTimeMillis() + app.getRoutingHelper().getLeftTime() * 1000)); + .format(new Date(System.currentTimeMillis() + routingHelper.getLeftTime() * 1000)); + String speedStr = OsmAndFormatter.getFormattedSpeed(location.getSpeed(), app); TurnType turnType = null; boolean deviatedFromRoute; @@ -200,7 +203,10 @@ public class NavigationNotification extends OsmandNotification { } } - notificationText.append(distanceStr).append(" • ").append(timeStr).append(" • ").append(etaStr); + notificationText.append(distanceStr) + .append(" • ").append(timeStr) + .append(" • ").append(etaStr) + .append(" • ").append(speedStr); } else { notificationTitle = app.getString(R.string.shared_string_navigation); @@ -266,6 +272,10 @@ public class NavigationNotification extends OsmandNotification { } } + private Location getLastKnownLocation() { + return app.getLocationProvider().getLastKnownLocation(); + } + public Bitmap drawableToBitmap(Drawable drawable) { int height = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_height); int width = (int) app.getResources().getDimension(android.R.dimen.notification_large_icon_width); From 6cfc51fedf1da3debb556e98c207849452529bff Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 15 Dec 2020 22:53:27 +0200 Subject: [PATCH 05/76] Fix obf helper --- .../osmand/binary/BinaryMapIndexReader.java | 17 +- .../src/net/osmand/plus/AppInitializer.java | 2 +- .../plus/resources/ResourceManager.java | 8 +- .../plus/wikivoyage/data/TravelHelper.java | 4 +- .../plus/wikivoyage/data/TravelObfHelper.java | 212 +++++++----------- 5 files changed, 98 insertions(+), 145 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java index 5e45a893ba..035b33d470 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java @@ -1538,9 +1538,20 @@ public class BinaryMapIndexReader { return request; } - - public static SearchRequest buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom, - ResultMatcher matcher){ + + public static SearchRequest buildSearchPoiRequest(LatLon latLon, int radius, int zoom, + SearchPoiTypeFilter poiTypeFilter, + ResultMatcher matcher) { + SearchRequest request = new SearchRequest<>(); + request.setBBoxRadius(latLon.getLatitude(), latLon.getLongitude(), radius); + request.zoom = zoom; + request.poiTypeFilter = poiTypeFilter; + request.resultMatcher = matcher; + return request; + } + + public static SearchRequest buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom, + ResultMatcher matcher) { SearchRequest request = new SearchRequest(); request.left = sleft; request.right = sright; diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index f8a5446efd..0a1f1d5c8e 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -459,7 +459,7 @@ public class AppInitializer implements IProgress { app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class); - app.travelHelper = app.getResourceManager().hasTravelObfFile() + app.travelHelper = true ? new TravelObfHelper(app) : new TravelDbHelper(app); app.travelHelper = startupInit(app.travelHelper, TravelHelper.class); diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 609ea7910d..424186421b 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -1161,7 +1161,7 @@ public class ResourceManager { return maps != null && maps.length > 0; } - public BinaryMapIndexReader[] getTravelFiles() { + public List getTravelRepositories() { Collection fileReaders = getFileReaders(); List readers = new ArrayList<>(fileReaders.size()); for (BinaryMapReaderResource res : fileReaders) { @@ -1175,11 +1175,7 @@ public class ResourceManager { } } } - return readers.toArray(new BinaryMapIndexReader[0]); - } - - public boolean hasTravelObfFile() { - return isMapsPresentInDirectory(IndexConstants.WIKIVOYAGE_INDEX_DIR); + return readers; } public Map getBackupIndexes(Map map) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 12976ed666..6ff6cf914b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -3,11 +3,8 @@ package net.osmand.plus.wikivoyage.data; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import net.osmand.plus.OsmandApplication; - import java.io.File; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -30,6 +27,7 @@ public interface TravelHelper { Map> getNavigationMap( final TravelArticle article); + @Nullable TravelArticle getArticleById(String routeId, String lang); TravelArticle getArticleByTitle(String title, String lang); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 65fe1e88e6..2621315eaf 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -4,11 +4,10 @@ import androidx.annotation.NonNull; import net.osmand.GPXUtilities; import net.osmand.IndexConstants; +import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; -import net.osmand.binary.BinaryIndexPart; import net.osmand.binary.BinaryMapIndexReader; -import net.osmand.binary.BinaryMapPoiReaderAdapter; import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; @@ -19,11 +18,9 @@ import org.apache.commons.logging.Log; import java.io.File; import java.io.IOException; -import java.io.RandomAccessFile; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -31,14 +28,14 @@ public class TravelObfHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); public static final String ROUTE_ARTICLE = "route_article"; + public static final int SEARCH_RADIUS = 100000; private final OsmandApplication app; - private File selectedTravelBook = null; - private final List existingTravelBooks = new ArrayList<>(); private List popularArticles = new ArrayList<>(); private final Map cachedArticles; private final TravelLocalDataHelper localDataHelper; + private List travelBookReaders; public TravelObfHelper(OsmandApplication app) { this.app = app; @@ -54,22 +51,7 @@ public class TravelObfHelper implements TravelHelper { @Override public void initializeDataOnAppStartup() { - - BinaryMapIndexReader[] readers = app.getResourceManager().getTravelFiles(); - String travelBook = app.getSettings().SELECTED_TRAVEL_BOOK.get(); - existingTravelBooks.clear(); - if (readers != null) { - for (BinaryMapIndexReader reader : readers) { - File f = reader.getFile(); - existingTravelBooks.add(f); - if (selectedTravelBook == null) { - selectedTravelBook = f; - } else if (Algorithms.objectEquals(travelBook, f.getName())) { - selectedTravelBook = f; - } - selectedTravelBook = reader.getFile(); - } - } + travelBookReaders = app.getResourceManager().getTravelRepositories(); } @Override @@ -83,64 +65,61 @@ public class TravelObfHelper implements TravelHelper { public List loadPopularArticles() { String language = app.getLanguage(); final List articles = new ArrayList<>(); - try { - BinaryMapIndexReader bookIndexReader = getBookBinaryIndex(); - if (bookIndexReader == null) { - popularArticles = new ArrayList<>(); - return popularArticles; - } - LatLon ll = app.getMapViewTrackingUtilities().getMapLocation(); - float coeff = 2; - BinaryMapIndexReader.SearchRequest req = - BinaryMapIndexReader.buildSearchPoiRequest( - MapUtils.get31TileNumberX(ll.getLongitude() - coeff), - MapUtils.get31TileNumberX(ll.getLongitude() + coeff), - MapUtils.get31TileNumberY(ll.getLatitude() + coeff), - MapUtils.get31TileNumberY(ll.getLatitude() - coeff), - -1, - BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, - new ResultMatcher() { - int count = 0; + for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + try { + if (travelBookReader == null) { + popularArticles = new ArrayList<>(); + return popularArticles; + } + Location myLocation = app.getLocationProvider().getLastKnownLocation(); + LatLon ll; + if (myLocation != null) { + ll = new LatLon(myLocation.getLatitude(), myLocation.getLongitude()); + } else { + ll = app.getMapViewTrackingUtilities().getMapLocation(); + } + BinaryMapIndexReader.SearchRequest req = + BinaryMapIndexReader.buildSearchPoiRequest(ll, SEARCH_RADIUS,-1, + BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, + new ResultMatcher() { + int count = 0; - @Override - public boolean publish(Amenity object) { - //TODO need more logical way to filter results - if (object.getSubType().equals(ROUTE_ARTICLE)) { - articles.add(object); + @Override + public boolean publish(Amenity object) { + //TODO need more logical way to filter results + if (object.getSubType().equals(ROUTE_ARTICLE)) { + articles.add(object); + } + return false; } - return false; - } - @Override - public boolean isCancelled() { - return false; - } - }); + @Override + public boolean isCancelled() { + return false; + } + }); + req.setBBoxRadius(ll.getLatitude(),ll.getLongitude(),100000); + travelBookReader.searchPoi(req); + travelBookReader.close(); - bookIndexReader.searchPoi(req); - bookIndexReader.close(); - - if (articles.size() > 0) { - Iterator it = articles.iterator(); - while (it.hasNext()) { - Amenity a = it.next(); - if (!a.getName(language).equals("")) { - TravelArticle article = readArticle(a, language); - popularArticles.add(article); - cachedArticles.put(article.routeId, article); + if (articles.size() > 0) { + for (Amenity a : articles) { + if (!a.getName(language).equals("")) { + TravelArticle article = readArticle(a, language); + popularArticles.add(article); + cachedArticles.put(article.routeId, article); + } } } + } catch (Exception e) { + LOG.error(e.getMessage()); } - } catch (Exception e) { - LOG.error(e.getMessage()); } return popularArticles; } - private TravelArticle readArticle(Amenity amenity, String lang) { TravelArticle res = new TravelArticle(); - res.title = amenity.getName(lang).equals("") ? amenity.getName() : amenity.getName(lang); res.content = amenity.getDescription(lang); res.isPartOf = amenity.getTagContent(Amenity.IS_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_PART, lang); @@ -152,15 +131,6 @@ public class TravelObfHelper implements TravelHelper { res.lang = lang; res.contentsJson = amenity.getTagContent(Amenity.CONTENT_JSON, lang) == null ? "" : amenity.getTagContent(Amenity.CONTENT_JSON, lang); res.aggregatedPartOf = amenity.getTagContent(Amenity.IS_AGGR_PART, lang) == null ? "" : amenity.getTagContent(Amenity.IS_AGGR_PART, lang); - -// occasional crashes -// try { -// String gpxContent = amenity.getAdditionalInfo("gpx_info"); -// res.gpxFile = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxContent.getBytes("UTF-8"))); -// } catch (IOException e) { -// LOG.error(e.getMessage(), e); -// } - return res; } @@ -168,27 +138,9 @@ public class TravelObfHelper implements TravelHelper { return amenity.getTagContent(Amenity.ROUTE_ID, null); } - - private BinaryMapIndexReader getBookBinaryIndex() throws IOException { - app.getSettings().SELECTED_TRAVEL_BOOK.set(selectedTravelBook.getName()); - try { - RandomAccessFile r = new RandomAccessFile(selectedTravelBook.getAbsolutePath(), "r"); - BinaryMapIndexReader index = new BinaryMapIndexReader(r, selectedTravelBook); - for (BinaryIndexPart p : index.getIndexes()) { - if (p instanceof BinaryMapPoiReaderAdapter.PoiRegion) { - return index; - } - } - } catch (IOException e) { - System.err.println("File doesn't have valid structure : " + selectedTravelBook.getName() + " " + e.getMessage()); - throw e; - } - return null; - } - @Override public boolean isAnyTravelBookPresent() { - return selectedTravelBook != null; + return !Algorithms.isEmpty(travelBookReaders); } @NonNull @@ -210,53 +162,49 @@ public class TravelObfHelper implements TravelHelper { @Override public TravelArticle getArticleById(String routeId, String lang) { - TravelArticle article = cachedArticles.get(routeId); - if (article != null) { - return article; - } - String name = ""; //??? - return getArticleByTitle(name, lang); + return cachedArticles.get(routeId); } @Override public TravelArticle getArticleByTitle(final String title, final String lang) { TravelArticle res = null; List amenities = Collections.emptyList(); - try { - BinaryMapIndexReader indexReader = getBookBinaryIndex(); - if (indexReader != null) { - int left = 0; - int top = 0; - int right = Integer.MAX_VALUE; - int bottom = Integer.MAX_VALUE; - LatLon ll = app.getMapViewTrackingUtilities().getMapLocation(); - BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - MapUtils.get31TileNumberX(ll.getLongitude()), - MapUtils.get31TileNumberY(ll.getLatitude()), title, - left, top, right, bottom, - new ResultMatcher() { - @Override - public boolean publish(Amenity object) { - if (object.getName(lang).equals(title)) { - return true; + for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + try { + if (travelBookReader != null) { + int left = 0; + int top = 0; + int right = Integer.MAX_VALUE; + int bottom = Integer.MAX_VALUE; + LatLon ll = app.getMapViewTrackingUtilities().getMapLocation(); + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + MapUtils.get31TileNumberX(ll.getLongitude()), + MapUtils.get31TileNumberY(ll.getLatitude()), title, + left, top, right, bottom, + new ResultMatcher() { + @Override + public boolean publish(Amenity object) { + if (object.getName(lang).equals(title)) { + return true; + } + return false; } - return false; - } - @Override - public boolean isCancelled() { - return false; - } - }); + @Override + public boolean isCancelled() { + return false; + } + }); - amenities = indexReader.searchPoiByName(req); + amenities = travelBookReader.searchPoiByName(req); + } + } catch (IOException e) { + //todo } - } catch (IOException e) { - //todo - } - if (!amenities.isEmpty()) { - for (Amenity a : amenities) { - LOG.debug("searched article: " + a); + if (!amenities.isEmpty()) { + for (Amenity a : amenities) { + LOG.debug("searched article: " + a); + } } } return res; From 667ebc83cd8104b1c68becd970eb9ec672fc7c37 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 15 Dec 2020 23:25:05 +0200 Subject: [PATCH 06/76] Fix #10358 --- .../net/osmand/plus/activities/MapActivity.java | 2 ++ .../measurementtool/MeasurementToolFragment.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 313fa6b917..8541ab5e87 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1195,6 +1195,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0); getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint); } else if (toShow instanceof GpxData) { + hideContextAndRouteInfoMenues(); + GpxData gpxData = (GpxData) toShow; QuadRect qr = gpxData.getRect(); mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index c54dd93a08..3d8d9163b0 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -70,13 +70,14 @@ import net.osmand.plus.measurementtool.command.MovePointCommand; import net.osmand.plus.measurementtool.command.RemovePointCommand; import net.osmand.plus.measurementtool.command.ReorderPointCommand; import net.osmand.plus.measurementtool.command.ReversePointsCommand; -import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet; -import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; import net.osmand.plus.measurementtool.command.SplitPointsCommand; +import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet; +import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.OnAppModeConfiguredCallback; +import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.views.layers.MapControlsLayer; +import net.osmand.plus.views.layers.MapControlsLayer.MapControlsThemeInfoProvider; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView; @@ -108,8 +109,8 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, - SaveAsNewTrackFragmentListener, MapControlsLayer.MapControlsThemeInfoProvider, - RouteOptionsBottomSheet.OnAppModeConfiguredCallback{ + SaveAsNewTrackFragmentListener, MapControlsThemeInfoProvider, + OnAppModeConfiguredCallback { public static final String TAG = MeasurementToolFragment.class.getSimpleName(); public static final String TAPS_DISABLED_KEY = "taps_disabled_key"; @@ -179,7 +180,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route return mainView.getHeight(); } - public boolean shouldShowXAxisPoints () { + public boolean shouldShowXAxisPoints() { return false; } } @@ -546,7 +547,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route if (savedInstanceState == null) { if (fileName != null) { addNewGpxData(getGpxFile(fileName)); - } else if (editingCtx.isApproximationNeeded()) { + } else if (editingCtx.isApproximationNeeded() && isFollowTrackMode()) { enterApproximationMode(mapActivity); } } else { From 3f3665b0075258598cab7a2cf57521767a42773e Mon Sep 17 00:00:00 2001 From: scai Date: Wed, 16 Dec 2020 07:08:56 +0000 Subject: [PATCH 07/76] Translated using Weblate (German) Currently translated at 100.0% (3581 of 3581 strings) --- OsmAnd/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index f8133d7c17..a34096ce9f 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3942,7 +3942,7 @@ Bitte warten Sie. \nDie Grafik wird nach der Neuberechnung der Route verfügbar sein. Einrichtung - ÖPNV + Verkehr Dienstleistung Reisen Sport From 7fb0b9ca9a223e803b3352d8b7401ab078f29c51 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 16 Dec 2020 06:49:14 +0000 Subject: [PATCH 08/76] Translated using Weblate (German) Currently translated at 100.0% (3581 of 3581 strings) --- OsmAnd/res/values-de/strings.xml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index a34096ce9f..680fd0c035 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -1960,7 +1960,7 @@ Relative Peilung Zeit zwischen automatischen Ansagen Magnetische Peilung - Ziel ist nicht festgelegt + Modul für Bedienungshilfen: Ziel ist nicht festgelegt OsmAnd-Live-Navigation Akkustand Karte bewegen, um die Position der Markierung zu verändern @@ -3520,7 +3520,7 @@ Das importierte Profil enthält zusätzliche Daten. Klicken Sie auf \"Importieren\", um nur Profildaten zu importieren, oder wählen Sie zusätzliche Daten aus. Sie können zusätzliche Daten zum Exportieren zusammen mit dem Profil auswählen. Antarktis - Sie können alle Ihre noch nicht hochgeladenen Bearbeitungen oder OSM-Fehlermeldungen in %1$s anzeigen. Hochgeladene Punkte werden in OsmAnd nicht angezeigt. + Betrachten Sie alle Ihre noch nicht hochgeladenen Bearbeitungen oder OSM-Hinweise in %1$s. Bereits hochgeladene Änderungen werden nicht mehr angezeigt. Empfehlung: Versuchen Sie zunächst, die Bewegungserkennung über den Filter zur Mindestabstandsmessung (B) zu verwenden. Das kann zu besseren Ergebnissen führen und Sie werden weniger Daten verlieren. Sollten Ihre Tracks bei niedrigen Geschwindigkeiten ungenau bleiben, versuchen Sie hier Werte ungleich Null. Bitte beachten Sie, dass einige Messungen (einige netzwerkbasierte Methoden) möglicherweise überhaupt keine Geschwindigkeitswerte anzeigen. In diesem Fall wird nichts aufgezeichnet. Es werden nur Punkte aufgezeichnet, die mit der gewählten Mindestgenauigkeit bestimmt wurden (in Metern/Fuß, wie von Android je nach Chipsatz bereitgestellt). Die Genauigkeit beschreibt die Nähe der Messungen zur wahren Position und steht nicht unmittelbar in Bezug zur Präzision, der Streuung wiederholter Messungen. Bemerkung: Wenn das GPS unmittelbar vor einer Aufzeichnung ausgeschaltet war, kann der erste gemessene Punkt eine verminderte Genauigkeit haben, sodass wir in unserem Code vielleicht eine Sekunde oder so warten wollen, bevor ein Punkt (oder der beste von 3 aufeinanderfolgenden Punkten usw.) aufgezeichnet wird. Das ist aber noch nicht implementiert. @@ -3801,9 +3801,9 @@ Bitte geben Sie Ihre Fahrzeuglänge an. Für lange Fahrzeuge könnten einige Streckenabschnitte nicht befahrbar sein. Nächstgelegenen Zielpunkt löschen Bitte geben Sie einen Namen für das Profil an - Der aktuelle Punkt auf der Route wird gelöscht. Wenn es das Ziel ist, wird die Navigation gestoppt. + Löscht das nächste Ziel auf Ihrer Route. Wenn dies das endgültige Ziel ist, wird die Navigation gestoppt. Wikipedia-Karten herunterladen - Info über Sehenswürdigkeiten erhalten Sie bei Wikipedia. Es ist Ihr Offline-Wegweiser für die Hosentasche - aktivieren Sie einfach das Wikipedia-Modul und genießen Sie Artikel über Objekte in Ihrer Umgebung. + Holen Sie sich Informationen über Sehenswürdigkeiten aus Wikipedia, einem Offline-Reiseführer für die Hosentasche mit Artikeln über Orte und Ziele. Enduro Motorroller Rollstuhl @@ -3844,7 +3844,7 @@ Adresse hinzufügen Adresse eingeben Bilder auf Straßenebene - Sind Sie sicher, dass Sie alle Änderungen an der geplanten Route verwerfen wollen, indem Sie sie schließen\? + Sind Sie sicher, dass Sie alle Änderungen an der geplanten Route verwerfen wollen\? Routentyp davor ändern Routentyp danach ändern Davor trimmen @@ -3877,7 +3877,7 @@ Während der Navigation automatisch Track aufzeichnen Track Route Track Datei zum Folgen auswählen, oder vom Gerät importieren. - Die GPX-Aufzeichnung wird angehalten, wenn OsmAnd beendet wird (über „zuletzt verwendete Apps“). (Die Hintergrunddienst-Anzeige verschwindet aus der Android-Benachrichtigungsleiste.) + Die Track-Aufzeichnung wird angehalten, wenn OsmAnd beendet wird (über „zuletzt verwendete Apps“). (Die Hintergrunddienst-Anzeige verschwindet aus der Android-Benachrichtigungsleiste.) Aufzeichnungsintervall für die generelle Track-Aufzeichnung festlegen (wird über die Schaltfläche \'Routenaufzeichung\' auf dem Kartenbildschirm angeschaltet). Als nächstes können Sie Ihren Track mit einem Ihrer Navigationsprofile auf die nächstgelegene erlaubte Straße einrasten lassen, um diese Option zu nutzen. Track-Wegpunkt hinzufügen @@ -3913,12 +3913,12 @@ Name: A – Z Start- und Zielsymbole Vielen Dank für den Kauf von \'Höhenlinien\' - Das Abonnement wird pro ausgewähltem Zeitraum berechnet. Sie können das Abonnement jederzeit über die AppGallery kündigen. - Die Bezahlung wird Ihrem AppGallery-Konto bei der Bestätigung des Kaufs belastet. + Das Abonnement wird für den gewählten Zeitraum berechnet. Sie können es jederzeit in Ihrer AppGallery kündigen. + Ihr AppGallery-Konto wird mit der Kaufbestätigung belastet. \n -\nDas Abonnement verlängert sich automatisch, sofern es nicht vor dem Verlängerungsdatum gekündigt wird. Ihr Konto wird für den Verlängerungszeitraum (Monat / drei Monate / Jahr) nur am Verlängerungsdatum belastet. +\nDas Abonnement verlängert sich automatisch, wenn es nicht vor dem Verlängerungsdatum gekündigt wird. Ihr Konto wird erst am Verlängerungsdatum für den Verlängerungszeitraum (Monat/drei Monate/Jahr) belastet. \n -\nSie können Ihre Abonnements verwalten und kündigen, indem Sie zu Ihren AppGallery-Einstellungen gehen. +\nSie können Ihre Abonnements in Ihren AppGallery-Einstellungen verwalten und kündigen. Vermeidet Fußwege Keine Fußwege Entwicklung @@ -3953,7 +3953,7 @@ Spezial Fügen Sie mindestens zwei Punkte hinzu Abonnement verwalten - Es gibt ein Problem mit Ihrem Abonnement. Tippen Sie auf die Schaltfläche, um zu den Einstellungen des Google Play Abonnements zu gelangen und Ihre Zahlungsmethode zu überprüfen. + Tippen Sie auf die Schaltfläche, um eine Zahlungsmethode auf Google Play einzurichten und Ihr Abonnement zu bestätigen. OsmAnd Live Abonnement ist abgelaufen OsmAnd Live Abonnement wurde ausgesetzt OsmAnd Live Abonnement liegt auf Eis @@ -4020,4 +4020,6 @@ Lücke Segmente verbinden Neues Segment hinzufügen + OsmAnd-Profil + Benutzerprofil \ No newline at end of file From 4cbca78b7973edb00f41c35f9486b19b18e7a216 Mon Sep 17 00:00:00 2001 From: ace shadow Date: Tue, 15 Dec 2020 21:53:24 +0000 Subject: [PATCH 09/76] Translated using Weblate (Slovak) Currently translated at 100.0% (3581 of 3581 strings) --- OsmAnd/res/values-sk/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 3a606aac2e..d798541848 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -4016,4 +4016,6 @@ \n• Podpora vlastných farieb pre obľúbené položky a sledovanie trasových bodov \n \n + Profil OsmAnd + Profil používateľa \ No newline at end of file From c5bdd0552c06e6722222749f0bf6d82826f71b94 Mon Sep 17 00:00:00 2001 From: ovl-1 Date: Tue, 15 Dec 2020 20:55:25 +0000 Subject: [PATCH 10/76] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 58.5% (2097 of 3581 strings) --- OsmAnd/res/values-nb/strings.xml | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 89b718abcd..d308624f86 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -2904,7 +2904,7 @@ Veityper Gå av på Sitt på stoppet - Vis/skjul GPX-spor + Vis/skjul spor Knapp for å vise eller skjule valgte spor på kartet. Skjul spor Vis spor @@ -2945,9 +2945,9 @@ Fast dekke Betong Brostein - Rustikk brostein + Naturlig brostein Steinbelagt - Småstein + Rullestein Stein Metall Tre @@ -3031,7 +3031,7 @@ Tillat OsmAnd å samle inn og behandle anonym programbruksdata. Ingen data om din plassering, eller om plasseringer du ser på kartet blir samlet inn. \n \nDu kan alltid endre ditt valg i \"Innstillinger\" → \"Personvern og sikkerhet\". - Velg hvilken data du ønsker å dele: + Velg typen data du vil dele: Nedlastede kart Besøkte skjermer Definer hvilken data du ønsker å dele med OsmAnd. @@ -3039,7 +3039,7 @@ Hjelp oss å fastslå popularitet for OsmAnd-funksjoner. Trykk \"Tillat\" hvis du samtykker du til vår %1$s Personvern og sikkerhet - Velg data til deling + Velg hvilke data du deler Nei takk Tillat Profilnavn @@ -3048,8 +3048,8 @@ Hest Helikopter Du kan legge til din egen endrede versjon av filen routing.xml til i ..osmand/routing - Skikjøring - Skikjøring + Stå på ski + Ski Vis kompasslinjal Skjul kompasslinjal Velg ikon @@ -3103,10 +3103,10 @@ Terreng Sett opp profil Antall overganger - Pendlebuss - Tunnelbane + Skyttelbuss + T-bane Baser din egendefinerte profil på en av de forvalgte programprofilene, dette definerer grunnleggende oppsett, som forvalg synliget for miniprogrammer, enheter for hastighet og distanse. Dette er de forvalgte programprofilene, sammen med eksempler på egentilpassede profiler de kan utvides til: - Alle typer offentlig transport + Offentlige transporttyper Endre kartforstørrelse ved å rulle hjulet opp og ned. Escape tar deg tilbake til WunderLINQ-programmet. Legg til minst ett element i listen i hurtighandlingsinnstillingene Bakker for alpin skisport og tilgang til skiheiser. @@ -3125,8 +3125,8 @@ Minimumshastighet Maksimumshastighet Standardhastighet - Endre forvalgte hastighetsinnstillinger - Sett min/maks -hastighet + Endre standardhastighetsinnstillinger + Still inn min/maks-hastighet Ny profil Krasj OsmAnd krasjet tidligere. Hjelp til å forbedre OsmAnd ved å dele feilmeldingen. @@ -3157,11 +3157,11 @@ Scooter Vannrett nøyaktighet: %1$s, loddrett: %2$s Vannrett nøyaktighet: %s - Profil beholder sine egne innstillinger - Velg kartinnstillinger for profilen - Velg skjerminnstillinger for profilen + Profilen beholder sine egne innstillinger + Velg kartalternativer for profilen + Velg skjermalternativer for profilen Velg navigeringsinnstillinger for profilen - Angi øvre grense for endringer + Bestem det maksimale antall overganger Eksterne inndataenheter Velg en enhet for ekstern kontroll, som f.eks. tastatur eller WunderLINQ. Tastatur @@ -3309,10 +3309,10 @@ Overgang Spor lagret Tomt filnavn - Vekk for sving + Slå på skjermen ved sving Juster hvor lenge skjermen skal forbli påslått. Bruk nærhetssensor - Vift hånden din over toppen av skjermen for å skru den på under navigasjon. + Å bevege hånden over skjermen vil slå den på. Klasse 1 Klasse 2 Klasse 3 From 6ce2abc5b3efb37f31f87509e4d5a7f0e00ae8af Mon Sep 17 00:00:00 2001 From: Ammuu5 Date: Wed, 16 Dec 2020 11:02:19 +0000 Subject: [PATCH 11/76] Translated using Weblate (Finnish) Currently translated at 60.4% (2164 of 3581 strings) --- OsmAnd/res/values-fi/strings.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index 4cd281d671..5eec1b2d10 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -412,7 +412,7 @@ Aikarajoitettu pysäköinti Aika rajoittamaton pysäköinti Pysäköidyn autosi sijainti. %1$s - Nouda auto kello: + Nouda ajoneuvo kello: PM AM U-Käännös @@ -1728,7 +1728,7 @@ Maailmanlaajuiset tiedot (välillä 70 astetta pohjoista ja 70 astetta eteläist Paina ja pidä nähdäksesi kartalla Alas/Ylös: %1$s - Laske OsmAnd reitin segmentti ilman internettiä + OsmAnd reittisegmentin laskeminen ilman internettiä Laske OsmAnd reitti ensimmäiselle ja viimeiselle reitin segmentille Käytetäänkö näytettävää jälkeä suunnistuksessa\? Lisää myöhemmäksi päämääräksi @@ -2573,4 +2573,18 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Suunnittele reitti Viimeksi muokattu Luo uusi reitti + Valitse väri + Valitse kuvake + Valitse ryhmä + Lisää kuvaus + Vain seuraava segmentti lasketaan uudelleen valitulla profiililla. + Seuraava segmentti + Kaikki seuraavat segmentit + Edellinen segmentti + Kaikki edelliset segmentit + Vain valittu segmentti lasketaan uudelleen käyttämällä valittua profiilia. + Kaikki seuraavat segmentit lasketaan uudelleen käyttämällä valittua profiilia. + Kaikki edelliset segmentit lasketaan uudelleen käyttämällä valittua profiilia. + Yhdistä segmentit + Lisää uusi segmentti \ No newline at end of file From 7e1a04e4dc1f01a72de66c6cbb53b0ebb8c2f49c Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Tue, 15 Dec 2020 18:31:12 +0000 Subject: [PATCH 12/76] Translated using Weblate (Sardinian) Currently translated at 99.7% (3573 of 3581 strings) --- OsmAnd/res/values-sc/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 68e3956fb4..8a5a50a624 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -4013,4 +4013,6 @@ \n • Suportu pro colores personalizados pro sos preferidos e sos puntos de coladòrgiu de sas rastas \n \n + Profilu de OsmAnd + Profilu de s\'impreadore \ No newline at end of file From 5896717781cb843365134174ce5d1bfa68e5ec4e Mon Sep 17 00:00:00 2001 From: scai Date: Wed, 16 Dec 2020 07:13:34 +0000 Subject: [PATCH 13/76] Translated using Weblate (German) Currently translated at 100.0% (3873 of 3873 strings) --- OsmAnd/res/values-de/phrases.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index 5fa56c8b47..b133a39aeb 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -3889,4 +3889,5 @@ Rettungsschwimmerbasis Impfung: COVID19 Impfung + Rammbrunnen \ No newline at end of file From 5a6c0ec6a707a62fc7f8fdd63b35617c66832d24 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 16 Dec 2020 07:11:55 +0000 Subject: [PATCH 14/76] Translated using Weblate (German) Currently translated at 100.0% (3873 of 3873 strings) --- OsmAnd/res/values-de/phrases.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index b133a39aeb..a05ba941da 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -3890,4 +3890,11 @@ Impfung: COVID19 Impfung Rammbrunnen + See + Fluss + Brunnen + Angetriebene Pumpe + Wassertank + Wasserhahn + Wasserwerk \ No newline at end of file From 3e964097c9bb9723ca0e960d98b37d61122afb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20J=C3=B5er=C3=BC=C3=BCt?= Date: Tue, 15 Dec 2020 20:44:45 +0000 Subject: [PATCH 15/76] Translated using Weblate (Estonian) Currently translated at 99.4% (3851 of 3873 strings) --- OsmAnd/res/values-et/phrases.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OsmAnd/res/values-et/phrases.xml b/OsmAnd/res/values-et/phrases.xml index 381bede727..c2229acf50 100644 --- a/OsmAnd/res/values-et/phrases.xml +++ b/OsmAnd/res/values-et/phrases.xml @@ -3843,4 +3843,15 @@ Ei Sireen Vetelpäästejaam + Õde + Vaktsineerimine + Vaktsineerimine: COVID19 + Puurkaev + Veevärgi ettevõte + Veekraan + Veepaak + Mootoriga veepump + Kaev + Jõgi + Järv \ No newline at end of file From 06cb6f3c03f2f5fa03e78833e71f6f7d1a359dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20J=C3=B5er=C3=BC=C3=BCt?= Date: Tue, 15 Dec 2020 20:48:31 +0000 Subject: [PATCH 16/76] Translated using Weblate (Estonian) Currently translated at 98.4% (3527 of 3581 strings) --- OsmAnd/res/values-et/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml index 835fad3539..cd68aefcae 100644 --- a/OsmAnd/res/values-et/strings.xml +++ b/OsmAnd/res/values-et/strings.xml @@ -3850,4 +3850,6 @@ Tükelda pärast Tükelda enne Liida lõigud + Kasutajaprofiil + OsmAnd profiil \ No newline at end of file From bf1e1246b89bda7157a85264ebc8a01a60106e37 Mon Sep 17 00:00:00 2001 From: Ammuu5 Date: Wed, 16 Dec 2020 11:31:42 +0000 Subject: [PATCH 17/76] Translated using Weblate (Finnish) Currently translated at 60.5% (2168 of 3581 strings) --- OsmAnd/res/values-fi/strings.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index 5eec1b2d10..75de0d4182 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -390,7 +390,7 @@ Tapahtui odottamaton virhe suoritettaessa toimintoa {0}. Avoinna Tallenna nimellä - Valitse tien väriteema: + Valitse tien värimaailma: Salli GPS:n käyttö asetuksista Autotuki Muokkaa näyttöä @@ -488,7 +488,7 @@ Esteettömyys moodi Globaalien systeemiasetusten mukaan ZXing viivakoodinlukusovellusta ei ole asennettuna. Etsitäänkö se Google Playstä? - Tien väriteema + Tien värimaailma Näytä kohteen suunta Laske mahdollisesti epäoptimaalinen reitti pitkille matkoille Käytä aina offline editointia @@ -836,7 +836,7 @@ Maailmanlaajuiset tiedot (välillä 70 astetta pohjoista ja 70 astetta eteläist Nauhoitettu Nauhoita Ei dataa - Korkeuskäyräviivojen väripaletti + Korkeuskäyräviivojen värimaailma Miniminopeuden kirjaaminen Aseta miniminopeus kirjattavalle pisteelle. Liikkeen tunnistuksen kirjaus @@ -847,7 +847,7 @@ Maailmanlaajuiset tiedot (välillä 70 astetta pohjoista ja 70 astetta eteläist Näytä Joulupyhän KP:t\? Vaaleanruskea Tummanruskea - Korkeuskäyrien väripaletti + Korkeuskäyrien värimaailma Tienpinnan eheys Kirjoita kaupunki, osoite, KP:n nimi Muokkaa luokkia @@ -2208,7 +2208,7 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Kasvata haun laajuutta Muokkaa hakusanoja tai lisää haun laajuutta. Tämän toimintonappulan tökkääminen näyttää tai piilottaa OSM-huomautukset kartalla. - Väriskeema + Värimaailma Salli yksityisalueet Salli pääsy yksityisalueille. Ota käyttöön animoitu sijaintini kartan vieritys navigaation aikana. @@ -2587,4 +2587,8 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Kaikki edelliset segmentit lasketaan uudelleen käyttämällä valittua profiilia. Yhdistä segmentit Lisää uusi segmentti + Kahdeksankulmio + Neliö + Ympyrä + Valitse muoto \ No newline at end of file From aaa19575127534ce86a1aba63c9a8ace0562f062 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Wed, 16 Dec 2020 17:57:07 +0300 Subject: [PATCH 18/76] Add phrase --- OsmAnd/res/values/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 055ed90025..f8980249cb 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4318,4 +4318,7 @@ Well River Lake + + Ranger station + From f829fa9ad4f159364f8c0a322a851c19b99df831 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 16 Dec 2020 17:26:47 +0200 Subject: [PATCH 19/76] Move them below "Walking". --- .../settings/backend/ApplicationMode.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index 9f112b498e..9a5cdb7d79 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -92,6 +92,14 @@ public class ApplicationMode { .icon(R.drawable.ic_action_pedestrian_dark) .description(R.string.base_profile_descr_pedestrian).reg(); + public static final ApplicationMode TRUCK = create(ApplicationMode.CAR, R.string.app_mode_truck, "truck") + .icon(R.drawable.ic_action_truck_dark) + .description(R.string.app_mode_truck).reg(); + + public static final ApplicationMode MOTORCYCLE = create(ApplicationMode.CAR, R.string.app_mode_motorcycle, "motorcycle") + .icon(R.drawable.ic_action_motorcycle_dark) + .description(R.string.app_mode_motorcycle).reg(); + public static final ApplicationMode PUBLIC_TRANSPORT = createBase(R.string.app_mode_public_transport, "public_transport") .icon(R.drawable.ic_action_bus_dark) .description(R.string.base_profile_descr_public_transport).reg(); @@ -108,14 +116,6 @@ public class ApplicationMode { .icon(R.drawable.ic_action_skiing) .description(R.string.base_profile_descr_ski).reg(); - public static final ApplicationMode TRUCK = create(ApplicationMode.CAR, R.string.app_mode_truck, "truck") - .icon(R.drawable.ic_action_truck_dark) - .description(R.string.app_mode_truck).reg(); - - public static final ApplicationMode MOTORCYCLE = create(ApplicationMode.CAR, R.string.app_mode_motorcycle, "motorcycle") - .icon(R.drawable.ic_action_motorcycle_dark) - .description(R.string.app_mode_motorcycle).reg(); - public static List values(OsmandApplication app) { if (customizationListener == null) { customizationListener = new OsmAndAppCustomization.OsmAndAppCustomizationListener() { @@ -512,6 +512,14 @@ public class ApplicationMode { mode.app = app; mode.updateAppModeIcon(); } + if (app.getSettings().APP_MODE_ORDER.isSetForMode(PEDESTRIAN)) { + if (!app.getSettings().APP_MODE_ORDER.isSetForMode(TRUCK)) { + TRUCK.setOrder(PEDESTRIAN.getOrder() + 1); + } + if (!app.getSettings().APP_MODE_ORDER.isSetForMode(MOTORCYCLE)) { + MOTORCYCLE.setOrder(PEDESTRIAN.getOrder() + 1); + } + } } private static void initCustomModes(OsmandApplication app) { @@ -606,7 +614,7 @@ public class ApplicationMode { return gson.toJson(toModeBean()); } - public ApplicationModeBean toModeBean(){ + public ApplicationModeBean toModeBean() { ApplicationModeBean mb = new ApplicationModeBean(); mb.stringKey = stringKey; mb.userProfileName = getUserProfileName(); From ee58b1ababc24dd1c78bfda397e920aa71efea37 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Wed, 16 Dec 2020 18:35:53 +0300 Subject: [PATCH 20/76] Add phrase --- OsmAnd/res/values/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index f8980249cb..ebddd0ac33 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4320,5 +4320,7 @@ Lake Ranger station + Weightbridge + From e8c1434d776ff89a2f18bb8aa3a31ebb6bf92e53 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 16 Dec 2020 19:13:58 +0100 Subject: [PATCH 21/76] Update bundled_assets.xml Add bg --- OsmAnd/assets/bundled_assets.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/assets/bundled_assets.xml b/OsmAnd/assets/bundled_assets.xml index 9b69d7250c..d5626ac886 100644 --- a/OsmAnd/assets/bundled_assets.xml +++ b/OsmAnd/assets/bundled_assets.xml @@ -8,6 +8,7 @@ + From 704b9ab2993690110e80b7f802cd10757f639c7f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 16 Dec 2020 21:12:36 +0200 Subject: [PATCH 22/76] Fix obf helper --- .../src/net/osmand/plus/AppInitializer.java | 1 - .../osmand/plus/activities/MapActivity.java | 1 + .../plus/resources/ResourceManager.java | 4 +- .../plus/wikivoyage/data/TravelObfHelper.java | 224 ++++++++++++++---- 4 files changed, 178 insertions(+), 52 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 00b5d2dc80..52b8cc89dc 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -461,7 +461,6 @@ public class AppInitializer implements IProgress { // TODOTRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper app.travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app); - app.travelHelper.initializeDataOnAppStartup(); app.travelHelper = startupInit(app.travelHelper, TravelHelper.class); app.lockHelper = startupInit(new LockHelper(app), LockHelper.class); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 313fa6b917..aecd00b12d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -450,6 +450,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (dashboardOnMap != null) { dashboardOnMap.updateLocation(true, true, false); } + app.getTravelHelper().initializeDataOnAppStartup(); findViewById(R.id.init_progress).setVisibility(View.GONE); findViewById(R.id.drawer_layout).invalidate(); } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index f8c25683db..ffd8bb4e83 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -801,7 +801,7 @@ public class ResourceManager { return warnings; } - private List getTravelRepositories() { + public List getTravelRepositories() { List fileNames = new ArrayList<>(travelRepositories.keySet()); Collections.sort(fileNames, Algorithms.getStringVersionComparator()); List res = new ArrayList<>(); @@ -814,7 +814,7 @@ public class ResourceManager { return res; } - private List getTravelRepositories(double topLat, double leftLon, double bottomLat, double rightLon) { + public List getTravelRepositories(double topLat, double leftLon, double bottomLat, double rightLon) { List fileNames = new ArrayList<>(travelRepositories.keySet()); Collections.sort(fileNames, Algorithms.getStringVersionComparator()); int leftX31 = MapUtils.get31TileNumberX(leftLon); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index df54776ab8..4308ede839 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -1,20 +1,17 @@ package net.osmand.plus.wikivoyage.data; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import net.osmand.CollatorStringMatcher; import net.osmand.GPXUtilities; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; -import net.osmand.data.MapObject; +import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.api.SQLiteAPI; import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; @@ -22,54 +19,144 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; import java.util.Map; public class TravelObfHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); + public static final String ROUTE_ARTICLE = "route_article"; + public static final int SEARCH_RADIUS = 100000; + private final OsmandApplication app; - private final OsmandApplication application; + private List popularArticles = new ArrayList<>(); + private final Map cachedArticles; + private final TravelLocalDataHelper localDataHelper; + private List travelBookReaders; - private TravelLocalDataHelper localDataHelper; - - private List popularArticles = new ArrayList(); - - - public TravelObfHelper(OsmandApplication application) { - this.application = application; - localDataHelper = new TravelLocalDataHelper(application); + public TravelObfHelper(OsmandApplication app) { + this.app = app; + localDataHelper = new TravelLocalDataHelper(app); + cachedArticles = new HashMap<>(); } + @Override public TravelLocalDataHelper getBookmarksHelper() { return localDataHelper; } @Override public void initializeDataOnAppStartup() { - + travelBookReaders = app.getResourceManager().getTravelRepositories(); } @Override - public boolean isAnyTravelBookPresent() { - return checkIfObfFileExists(application); - } - - public void initializeDataToDisplay() { localDataHelper.refreshCachedData(); loadPopularArticles(); } - @NonNull - public List search(final String searchQuery) { - List res = new ArrayList<>(); + public List loadPopularArticles() { + String language = app.getLanguage(); + popularArticles.clear(); + final List amenities = new ArrayList<>(); + for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + try { + if (travelBookReader == null) { + popularArticles = new ArrayList<>(); + return popularArticles; + } + final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); + BinaryMapIndexReader.SearchRequest req = + BinaryMapIndexReader.buildSearchPoiRequest(location, SEARCH_RADIUS, -1, + BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, + new ResultMatcher() { + @Override + public boolean publish(Amenity amenity) { + if (amenity.getSubType().equals(ROUTE_ARTICLE)) { + amenities.add(amenity); + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + travelBookReader.searchPoi(req); + + if (amenities.size() > 0) { + for (Amenity a : amenities) { + if (!a.getName(language).equals("")) { + TravelArticle article = readArticle(a, language); + popularArticles.add(article); + cachedArticles.put(article.routeId, article); + if (popularArticles.size() >= 100) { + break; + } + } + } + Collections.sort(popularArticles, new Comparator() { + @Override + public int compare(TravelArticle article1, TravelArticle article2) { + int d1 = (int) (MapUtils.getDistance(article1.getLat(), article1.getLon(), + location.getLatitude(), location.getLongitude())); + int d2 = (int) (MapUtils.getDistance(article2.getLat(), article2.getLon(), + location.getLatitude(), location.getLongitude())); + return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); + } + }); + } + + } catch (Exception e) { + LOG.error(e.getMessage()); + } + } + return popularArticles; + } + + private TravelArticle readArticle(Amenity amenity, String lang) { + TravelArticle res = new TravelArticle(); + res.title = amenity.getName(lang).equals("") ? amenity.getName() : amenity.getName(lang); + res.content = amenity.getDescription(lang); + res.isPartOf = checkNull(amenity.getTagContent(Amenity.IS_PART, lang)); + res.lat = amenity.getLocation().getLatitude(); + res.lon = amenity.getLocation().getLongitude(); + res.imageTitle = checkNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang)); + res.routeId = getRouteId(amenity); + res.originalId = 0; //? + res.lang = lang; + res.contentsJson = checkNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); + res.aggregatedPartOf = checkNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); return res; } + String checkNull(String tagContent) { + return tagContent == null ? "" : tagContent; + } + + private String getRouteId(Amenity amenity) { + return amenity.getTagContent(Amenity.ROUTE_ID, null); + } + + @Override + public boolean isAnyTravelBookPresent() { + return !Algorithms.isEmpty(travelBookReaders); + } + @NonNull + @Override + public List search(String searchQuery) { + return null; + } + + @NonNull + @Override public List getPopularArticles() { return popularArticles; } @@ -81,38 +168,89 @@ public class TravelObfHelper implements TravelHelper { @Override public TravelArticle getArticleById(String routeId, String lang) { - return null; + return cachedArticles.get(routeId); } @Override - public TravelArticle getArticleByTitle(String title, String lang) { - return null; + public TravelArticle getArticleByTitle(final String title, final String lang) { + TravelArticle article = null; + final List amenities = new ArrayList<>(); + for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + try { + if (travelBookReader != null) { + int left = Integer.MIN_VALUE; + int right = Integer.MAX_VALUE; + int top = Integer.MIN_VALUE; + int bottom = Integer.MAX_VALUE; + LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + MapUtils.get31TileNumberX(location.getLongitude()), + MapUtils.get31TileNumberY(location.getLatitude()), title, left, right, top, bottom, + new ResultMatcher() { + @Override + public boolean publish(Amenity amenity) { + if (title.equalsIgnoreCase(amenity.getName(lang)) + && amenity.getSubType().equals(ROUTE_ARTICLE)) { + amenities.add(amenity); + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + + travelBookReader.searchPoiByName(req); + } + } catch (IOException e) { + LOG.error(e.getMessage()); + } + if (!amenities.isEmpty()) { + article = readArticle(amenities.get(0), lang); + cachedArticles.put(article.routeId, article); + } + } + return article; } @Override public String getArticleId(String title, String lang) { + for (TravelArticle article : cachedArticles.values()) { + if (article.getTitle().equals(title)) { + return article.getRouteId(); + } + } + TravelArticle article = getArticleByTitle(title, lang); + if (article != null) { + return article.getRouteId(); + } return null; } @Override - public ArrayList getArticleLangs(String articleId) { - return null; - } - - @NonNull - public List loadPopularArticles() { - popularArticles = new ArrayList<>(); - return popularArticles; + public ArrayList getArticleLangs(String routeId) { + ArrayList res = new ArrayList<>(); + res.add("en"); + for (TravelArticle article : popularArticles) { + if (article.getRouteId().equals(routeId)) { + res.add(article.getLang()); + } + } + return res; } + @Override public String getGPXName(TravelArticle article) { return article.getTitle().replace('/', '_').replace('\'', '_') .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; } + @Override public File createGpxFile(TravelArticle article) { final GPXUtilities.GPXFile gpx = article.getGpxFile(); - File file = application.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); + File file = app.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); if (!file.exists()) { GPXUtilities.writeGpxFile(file, gpx); } @@ -121,18 +259,6 @@ public class TravelObfHelper implements TravelHelper { @Override public String getSelectedTravelBookName() { - return null; + return ""; } - - public static boolean checkIfObfFileExists(OsmandApplication app) { - File[] files = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); - if (files != null) { - for (File f : files) { - if (f.getName().contains(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT)) { - return true; - } - } - } - return false; - } -} +} \ No newline at end of file From d5bc1b3c1c763cf03fa1d963032211c26d7089eb Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 17 Dec 2020 11:50:25 +0300 Subject: [PATCH 23/76] Fix #10206 --- OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index e5fa9065cd..268f837d37 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -983,6 +983,8 @@ public class OsmandSettings { { ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.DEFAULT, RouteService.STRAIGHT); ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT); + ROUTE_SERVICE.setModeValue(ApplicationMode.DEFAULT, RouteService.STRAIGHT); + ROUTE_SERVICE.setModeValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT); } public final CommonPreference NAVIGATION_ICON = new EnumStringPreference<>(this, "navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache(); From b11f8a64fecd7f0b568597c7cad4d98ce2eb0b05 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 17 Dec 2020 12:03:28 +0300 Subject: [PATCH 24/76] Revert "Fix #10206" This reverts commit d5bc1b3c1c763cf03fa1d963032211c26d7089eb. --- OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 268f837d37..e5fa9065cd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -983,8 +983,6 @@ public class OsmandSettings { { ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.DEFAULT, RouteService.STRAIGHT); ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT); - ROUTE_SERVICE.setModeValue(ApplicationMode.DEFAULT, RouteService.STRAIGHT); - ROUTE_SERVICE.setModeValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT); } public final CommonPreference NAVIGATION_ICON = new EnumStringPreference<>(this, "navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache(); From 5b900f8bfca232029aa982b7ae49f35118e3ed6f Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 17 Dec 2020 12:28:28 +0300 Subject: [PATCH 25/76] Fix #10206 --- .../osmand/plus/settings/backend/OsmandSettings.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index e5fa9065cd..554b96fc63 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -978,7 +978,16 @@ public class OsmandSettings { ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.SKI, "ski"); } - public final CommonPreference ROUTE_SERVICE = new EnumStringPreference<>(this, "route_service", RouteService.OSMAND, RouteService.values()).makeProfile().cache(); + public final CommonPreference ROUTE_SERVICE = new EnumStringPreference(this, "route_service", RouteService.OSMAND, RouteService.values()) { + @Override + public RouteService getModeValue(ApplicationMode mode) { + if (mode == ApplicationMode.DEFAULT) { + return RouteService.STRAIGHT; + } else { + return super.getModeValue(mode); + } + } + }.makeProfile().cache(); { ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.DEFAULT, RouteService.STRAIGHT); From f0cbbc2344825d547bf2fa2bc37ee237de14156a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 12:29:59 +0200 Subject: [PATCH 26/76] Add getBlockedRoads to aidl api --- .../osmand/aidlapi/IOsmAndAidlInterface.aidl | 3 + .../navigation/ABlockedRoadParams.aidl | 3 + .../navigation/ABlockedRoadParams.java | 57 +++++++++++++++++++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 16 +++++- .../net/osmand/aidl/OsmandAidlServiceV2.java | 12 ++++ 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index ca19b48c83..0325c2a723 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -92,6 +92,7 @@ import net.osmand.aidlapi.copyfile.CopyFileParams; import net.osmand.aidlapi.navigation.ANavigationUpdateParams; import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams; +import net.osmand.aidlapi.navigation.ABlockedRoadParams; import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams; import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams; @@ -892,4 +893,6 @@ interface IOsmAndAidlInterface { boolean selectProfile(in SelectProfileParams params); boolean getProfiles(out List profiles); + + boolean getBlockedRoads(out List blockedRoads); } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl new file mode 100644 index 0000000000..ff967858c0 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.navigation; + +parcelable ABlockedRoadParams; \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java new file mode 100644 index 0000000000..02c59c0ae5 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java @@ -0,0 +1,57 @@ +package net.osmand.aidlapi.navigation; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class ABlockedRoadParams extends AidlParams { + + public long roadId; + public double latitude; + public double longitude; + public String name; + public String appModeKey; + + public ABlockedRoadParams(long roadId, double latitude, double longitude, String name, String appModeKey) { + this.roadId = roadId; + this.latitude = latitude; + this.longitude = longitude; + this.name = name; + this.appModeKey = appModeKey; + } + + protected ABlockedRoadParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public ABlockedRoadParams createFromParcel(Parcel in) { + return new ABlockedRoadParams(in); + } + + @Override + public ABlockedRoadParams[] newArray(int size) { + return new ABlockedRoadParams[size]; + } + }; + + @Override + protected void readFromBundle(Bundle bundle) { + roadId = bundle.getLong("roadId"); + latitude = bundle.getDouble("latitude"); + longitude = bundle.getDouble("longitude"); + name = bundle.getString("name"); + appModeKey = bundle.getString("appModeKey"); + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putLong("roadId", roadId); + bundle.putDouble("latitude", latitude); + bundle.putDouble("longitude", longitude); + bundle.putString("name", name); + bundle.putString("appModeKey", appModeKey); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 6b9bb29dea..514916e51b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -43,6 +43,7 @@ import net.osmand.aidl.tiles.ASqliteDbFile; import net.osmand.aidlapi.customization.AProfile; import net.osmand.aidlapi.info.AppInfoParams; import net.osmand.aidlapi.map.ALatLon; +import net.osmand.aidlapi.navigation.ABlockedRoadParams; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -62,6 +63,7 @@ import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.dialogs.GpxAppearanceAdapter; +import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.helpers.LockHelper; @@ -208,7 +210,7 @@ public class OsmandAidlApi { private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; - private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{ + private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[] { ApplicationMode.CAR, ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN @@ -287,7 +289,7 @@ public class OsmandAidlApi { } private void initOsmandTelegram() { - String[] packages = new String[]{"net.osmand.telegram", "net.osmand.telegram.debug"}; + String[] packages = new String[] {"net.osmand.telegram", "net.osmand.telegram.debug"}; Intent intent = new Intent("net.osmand.telegram.InitApp"); for (String pack : packages) { intent.setComponent(new ComponentName(pack, "net.osmand.telegram.InitAppBroadcastReceiver")); @@ -2167,7 +2169,7 @@ public class OsmandAidlApi { } boolean getBitmapForGpx(final Uri gpxUri, final float density, final int widthPixels, - final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) { + final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) { if (gpxUri == null || callback == null) { return false; } @@ -2368,6 +2370,14 @@ public class OsmandAidlApi { return true; } + public boolean getBlockedRoads(List blockedRoads) { + Map impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads(); + for (AvoidRoadInfo info : impassableRoads.values()) { + blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.name, info.appModeKey)); + } + return true; + } + private static class FileCopyInfo { long startTime; long lastAccessTime; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 9943257c03..c28ef2842b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -73,6 +73,7 @@ import net.osmand.aidlapi.navdrawer.NavDrawerFooterParams; import net.osmand.aidlapi.navdrawer.NavDrawerHeaderParams; import net.osmand.aidlapi.navdrawer.NavDrawerItem; import net.osmand.aidlapi.navdrawer.SetNavDrawerItemsParams; +import net.osmand.aidlapi.navigation.ABlockedRoadParams; import net.osmand.aidlapi.navigation.ANavigationUpdateParams; import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams; import net.osmand.aidlapi.navigation.MuteNavigationParams; @@ -1396,6 +1397,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } + + @Override + public boolean getBlockedRoads(List blockedRoads) { + try { + OsmandAidlApi api = getApi("getBlockedRoads"); + return api != null && api.getBlockedRoads(blockedRoads); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { From 425b98c6dce1b3a039fc9b8cea2ba24400ea5e87 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 12:43:51 +0200 Subject: [PATCH 27/76] Add angle for roundabout --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 8 +++++++- OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 514916e51b..3937055df4 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -140,8 +140,11 @@ import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_ import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR; import static net.osmand.aidlapi.OsmandAidlConstants.OK_RESPONSE; import static net.osmand.plus.FavouritesDbHelper.FILE_TO_SAVE; +import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_ANGLE; import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_LANES; import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_NAME; +import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_POSSIBLY_LEFT; +import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_POSSIBLY_RIGHT; import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_TURN; import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DISTANCE; import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_IMMINENT; @@ -1793,6 +1796,9 @@ public class OsmandAidlApi { RouteDirectionInfo a = ni.directionInfo; bundle.putString(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), "")); bundle.putString(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString()); + bundle.putFloat(prefix + PARAM_NT_DIRECTION_ANGLE, tt.getTurnAngle()); + bundle.putBoolean(prefix + PARAM_NT_DIRECTION_POSSIBLY_LEFT, tt.isPossibleLeftTurn()); + bundle.putBoolean(prefix + PARAM_NT_DIRECTION_POSSIBLY_RIGHT, tt.isPossibleRightTurn()); if (tt.getLanes() != null) { bundle.putString(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes())); } @@ -1800,7 +1806,7 @@ public class OsmandAidlApi { } boolean search(final String searchQuery, final int searchType, final double latitude, final double longitude, - final int radiusLevel, final int totalLimit, final SearchCompleteCallback callback) { + final int radiusLevel, final int totalLimit, final SearchCompleteCallback callback) { if (Algorithms.isEmpty(searchQuery) || latitude == 0 || longitude == 0 || callback == null) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 57d6039145..8212d0ab26 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -151,6 +151,9 @@ public class ExternalApiHelper { public static final String PARAM_NT_DIRECTION_NAME = "turn_name"; public static final String PARAM_NT_DIRECTION_TURN = "turn_type"; public static final String PARAM_NT_DIRECTION_LANES = "turn_lanes"; + public static final String PARAM_NT_DIRECTION_ANGLE = "turn_angle"; + public static final String PARAM_NT_DIRECTION_POSSIBLY_LEFT = "turn_possibly_left"; + public static final String PARAM_NT_DIRECTION_POSSIBLY_RIGHT = "turn_possibly_right"; public static final String PARAM_CLOSE_AFTER_COMMAND = "close_after_command"; @@ -690,6 +693,9 @@ public class ExternalApiHelper { RouteDirectionInfo a = ni.directionInfo; result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), "")); result.putExtra(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString()); + result.putExtra(prefix + PARAM_NT_DIRECTION_ANGLE, tt.getTurnAngle()); + result.putExtra(prefix + PARAM_NT_DIRECTION_POSSIBLY_LEFT, tt.isPossibleLeftTurn()); + result.putExtra(prefix + PARAM_NT_DIRECTION_POSSIBLY_RIGHT, tt.isPossibleRightTurn()); if (tt.getLanes() != null) { result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes())); } From 4ac5f6e9577bdd962b23885e107926496da4c2b9 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Wed, 16 Dec 2020 19:04:04 +0000 Subject: [PATCH 28/76] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3581 of 3581 strings) --- OsmAnd/res/values-uk/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 9ac26b675a..9be3ea3de0 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4012,4 +4012,6 @@ \n• Підтримка власних кольорів закладок та маршрутних точок треку \n \n + Профіль OsmAnd + Профіль користувача \ No newline at end of file From 84948095e8842639277bb5569619d4a7411f4ab3 Mon Sep 17 00:00:00 2001 From: Ammuu5 Date: Wed, 16 Dec 2020 11:58:39 +0000 Subject: [PATCH 29/76] Translated using Weblate (Finnish) Currently translated at 61.1% (2191 of 3581 strings) --- OsmAnd/res/values-fi/strings.xml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-fi/strings.xml b/OsmAnd/res/values-fi/strings.xml index 75de0d4182..026179f02c 100644 --- a/OsmAnd/res/values-fi/strings.xml +++ b/OsmAnd/res/values-fi/strings.xml @@ -305,7 +305,7 @@ Näytä vain Seuraa Valitse päämäärä ensin - Ohjeet + Reittiohjeet Avoinna Ladataan katuja/rakennuksia… Ladataan postinumeroita… @@ -2571,7 +2571,7 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Viikko Suuntima Suunnittele reitti - Viimeksi muokattu + Viimeksi muokatut Luo uusi reitti Valitse väri Valitse kuvake @@ -2591,4 +2591,27 @@ Jos pidät OsmAndista ja OSMsta ja haluat tukea niitä, on tämä täydellinen t Neliö Ympyrä Valitse muoto + Palauta oletusarvot + Kaikki profiiliasetukset palautettu oletusarvoihin. + Kaikki laajennuksen asetukset palautettu oletusarvoihin. + Sovelluksen oletus (%s) + Palauta oletus kohteiden järjestys + Näytön oletusaikakatkaisu + Järjestelmän oletus + Muokkaa profiililuetteloa + Muokkaa profiileja + Tuo profiili + Valittu profiili + Mukavuus + Matkailu + Erityinen + Urheilu + OsmAnd-latauspalvelu + Palvelu + Hätätapaus + Liikenne + Näytä julkinen liikenne + Piilota julkinen liikenne + Symbolit + Korvaa toinen kohde tällä. \ No newline at end of file From c97cd527d62798f2eb7181445ab6fe79de60a380 Mon Sep 17 00:00:00 2001 From: abdullah abdulrhman Date: Wed, 16 Dec 2020 18:32:25 +0000 Subject: [PATCH 30/76] Translated using Weblate (Arabic) Currently translated at 92.7% (3593 of 3873 strings) --- OsmAnd/res/values-ar/phrases.xml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ar/phrases.xml b/OsmAnd/res/values-ar/phrases.xml index 5b5499949f..a369c15aab 100644 --- a/OsmAnd/res/values-ar/phrases.xml +++ b/OsmAnd/res/values-ar/phrases.xml @@ -3364,8 +3364,8 @@ الرابط أماكن لوقوف السيارات قبر - جنس المجتمع: ذكر - جنس المجتمع: أنثى + نوع المجتمع: ذكر + نوع المجتمع: أنثى لا نعم حمام القدم @@ -3659,4 +3659,17 @@ حطام سفينة حجر الشاهد القائم الروني دبابة تاريخية + بحيرة + نهر + بئر + مضخة + خزان مياه + حنفية + أعمال مياه + شيب مياه + لقاح كورونا COVID19 + يتوفر لدهم لقاح + منصة الانقاذ + صفارت إنذار + نوع المجتمع: مختلط \ No newline at end of file From e2264f42b5a535df84628cfe0b493576dade0a10 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 13:29:23 +0200 Subject: [PATCH 31/76] Fix possible npe --- .../notifications/NavigationNotification.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java index 243d480b55..63c17ceece 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java @@ -134,7 +134,6 @@ public class NavigationNotification extends OsmandNotification { turnBitmap = null; ongoing = true; RoutingHelper routingHelper = app.getRoutingHelper(); - Location location = getLastKnownLocation(); if (service != null && (service.getUsedBy() & USED_BY_NAVIGATION) != 0) { color = app.getResources().getColor(R.color.osmand_orange); @@ -142,7 +141,11 @@ public class NavigationNotification extends OsmandNotification { String timeStr = OsmAndFormatter.getFormattedDuration(routingHelper.getLeftTime(), app); String etaStr = SimpleDateFormat.getTimeInstance(DateFormat.SHORT) .format(new Date(System.currentTimeMillis() + routingHelper.getLeftTime() * 1000)); - String speedStr = OsmAndFormatter.getFormattedSpeed(location.getSpeed(), app); + String speedStr = null; + Location location = getLastKnownLocation(); + if (location != null && location.hasSpeed()) { + speedStr = OsmAndFormatter.getFormattedSpeed(location.getSpeed(), app); + } TurnType turnType = null; boolean deviatedFromRoute; @@ -202,12 +205,12 @@ public class NavigationNotification extends OsmandNotification { notificationText.append("\n"); } } - notificationText.append(distanceStr) .append(" • ").append(timeStr) - .append(" • ").append(etaStr) - .append(" • ").append(speedStr); - + .append(" • ").append(etaStr); + if (speedStr != null) { + notificationText.append(" • ").append(speedStr); + } } else { notificationTitle = app.getString(R.string.shared_string_navigation); String error = routingHelper.getLastRouteCalcErrorShort(); @@ -217,7 +220,6 @@ public class NavigationNotification extends OsmandNotification { notificationText.append(error); } } - } else if (routingHelper.isRoutePlanningMode() && routingHelper.isPauseNavigation()) { ongoing = false; notificationTitle = app.getString(R.string.shared_string_navigation); From ff6701de70562141541025ac4524bcb98e2f606a Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 17 Dec 2020 15:01:14 +0200 Subject: [PATCH 32/76] temp --- OsmAnd/res/values/strings.xml | 1 + .../plus/helpers/WaypointDialogHelper.java | 51 +++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 56d61d25ff..eecb00ee9a 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Reverse all points • Added option to export and import all data including settings, resources, my places\n\n • Plan Route: graphs for track segments with route, and added the ability to create and edit multiple track segments\n\n diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 19cd646ecb..628bc7ed71 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -42,12 +42,13 @@ import java.util.ArrayList; import java.util.List; /** + * */ public class WaypointDialogHelper { private MapActivity mapActivity; private OsmandApplication app; private WaypointHelper waypointHelper; - private List helperCallbacks= new ArrayList<>(); + private List helperCallbacks = new ArrayList<>(); private boolean flat; private List deletedPoints; @@ -242,8 +243,8 @@ public class WaypointDialogHelper { // switch start & finish public static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish, - Activity ctx, TargetPoint start, OsmandApplication app, - WaypointDialogHelper helper) { + Activity ctx, TargetPoint start, OsmandApplication app, + WaypointDialogHelper helper) { if (finish == null) { app.showShortToastMessage(R.string.mark_final_location_first); } else { @@ -263,6 +264,22 @@ public class WaypointDialogHelper { } } + public static void switchAllPoint(final OsmandApplication app, final Activity ctx, + final WaypointDialogHelper helper) { + List all; + TargetPointsHelper targets = app.getTargetPointsHelper(); + all = targets.getIntermediatePointsWithTarget(); + + List cur = targets.getIntermediatePointsWithTarget(); + for (int j = 0; j < cur.size() && j < all.size(); j++) { + if (cur.get(j) != all.get(j)) { + break; + } + } + targets.reorderAllTargetPoints(all, true); + updateControls(ctx, helper); + } + public static void updateControls(Activity ctx, WaypointDialogHelper helper) { if (helper != null && helper.helperCallbacks != null) { for (WaypointDialogHelperCallback callback : helper.helperCallbacks) { @@ -278,7 +295,7 @@ public class WaypointDialogHelper { } public static void replaceStartWithFirstIntermediate(TargetPointsHelper targetPointsHelper, Activity ctx, - WaypointDialogHelper helper) { + WaypointDialogHelper helper) { List intermediatePoints = targetPointsHelper.getIntermediatePointsWithTarget(); TargetPoint firstIntermediate = intermediatePoints.remove(0); targetPointsHelper.setStartPoint(new LatLon(firstIntermediate.getLatitude(), @@ -493,6 +510,32 @@ public class WaypointDialogHelper { items.add(new DividerHalfItem(getContext())); + BaseBottomSheetItem reorderAllItems = new SimpleBottomSheetItem.Builder() + .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)) + .setTitle(getString(R.string.switch_all_points)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + WaypointDialogHelper.switchAllPoint( + mapActivity.getMyApplication(), + mapActivity, + mapActivity.getDashboard().getWaypointDialogHelper() + ); + } + dismiss(); + } + }) + .create(); + if (getMyApplication() != null) { + int intermediateSize = getMyApplication().getTargetPointsHelper().getAllPoints().size(); + if (intermediateSize > 2) { + items.add(reorderAllItems); + } + } + final BaseBottomSheetItem[] addWaypointItem = new BaseBottomSheetItem[1]; addWaypointItem[0] = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_plus)) From c20c0aa6e7a6caaea7127229f686baf6adc4689d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 15:06:41 +0200 Subject: [PATCH 33/76] Add direction to avoid roads --- .../navigation/ABlockedRoadParams.java | 40 +++++++++++-- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 2 +- .../plus/helpers/AvoidSpecificRoads.java | 13 +++- .../backend/ImpassableRoadsStorage.java | 59 ++++++++++++++++--- .../plus/settings/backend/OsmandSettings.java | 1 + .../backup/AvoidRoadsSettingsItem.java | 28 +++++---- 6 files changed, 114 insertions(+), 29 deletions(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java index 02c59c0ae5..a6dd2a18b5 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java @@ -7,16 +7,18 @@ import net.osmand.aidlapi.AidlParams; public class ABlockedRoadParams extends AidlParams { - public long roadId; - public double latitude; - public double longitude; - public String name; - public String appModeKey; + private long roadId; + private double latitude; + private double longitude; + private double direction; + private String name; + private String appModeKey; - public ABlockedRoadParams(long roadId, double latitude, double longitude, String name, String appModeKey) { + public ABlockedRoadParams(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) { this.roadId = roadId; this.latitude = latitude; this.longitude = longitude; + this.direction = direction; this.name = name; this.appModeKey = appModeKey; } @@ -37,11 +39,36 @@ public class ABlockedRoadParams extends AidlParams { } }; + public long getRoadId() { + return roadId; + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + + public double getDirection() { + return direction; + } + + public String getName() { + return name; + } + + public String getAppModeKey() { + return appModeKey; + } + @Override protected void readFromBundle(Bundle bundle) { roadId = bundle.getLong("roadId"); latitude = bundle.getDouble("latitude"); longitude = bundle.getDouble("longitude"); + direction = bundle.getDouble("direction"); name = bundle.getString("name"); appModeKey = bundle.getString("appModeKey"); } @@ -51,6 +78,7 @@ public class ABlockedRoadParams extends AidlParams { bundle.putLong("roadId", roadId); bundle.putDouble("latitude", latitude); bundle.putDouble("longitude", longitude); + bundle.putDouble("direction", direction); bundle.putString("name", name); bundle.putString("appModeKey", appModeKey); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 3937055df4..864a128114 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -2379,7 +2379,7 @@ public class OsmandAidlApi { public boolean getBlockedRoads(List blockedRoads) { Map impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads(); for (AvoidRoadInfo info : impassableRoads.values()) { - blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.name, info.appModeKey)); + blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.direction, info.name, info.appModeKey)); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 22e0607c7f..690c990589 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -26,7 +26,6 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -35,6 +34,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.RouteSegmentSearchResult; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.views.layers.ContextMenuLayer; import net.osmand.router.RouteSegmentResult; import net.osmand.router.RoutingConfiguration; @@ -59,7 +59,7 @@ public class AvoidSpecificRoads { loadImpassableRoads(); } - public void loadImpassableRoads(){ + public void loadImpassableRoads() { for (AvoidRoadInfo avoidRoadInfo : app.getSettings().getImpassableRoadPoints()) { impassableRoads.put(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude), avoidRoadInfo); } @@ -390,7 +390,13 @@ public class AvoidSpecificRoads { if (avoidRoadInfo == null) { avoidRoadInfo = new AvoidRoadInfo(); } - avoidRoadInfo.id = object != null ? object.id : 0; + if (object != null) { + avoidRoadInfo.id = object.id; +// avoidRoadInfo.direction = object.directionRoute(0, true); + } else { + avoidRoadInfo.id = 0; + avoidRoadInfo.direction = Double.NaN; + } avoidRoadInfo.latitude = lat; avoidRoadInfo.longitude = lon; avoidRoadInfo.appModeKey = appModeKey; @@ -400,6 +406,7 @@ public class AvoidSpecificRoads { public static class AvoidRoadInfo { public long id; + public double direction; public double latitude; public double longitude; public String name; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java b/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java index 80242478e5..25586ef35a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java @@ -12,6 +12,7 @@ import java.util.StringTokenizer; class ImpassableRoadsStorage extends SettingsMapPointsStorage { protected String roadsIdsKey; + protected String directionsKey; protected String appModeKey; public ImpassableRoadsStorage(OsmandSettings osmandSettings) { @@ -19,6 +20,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { pointsKey = OsmandSettings.IMPASSABLE_ROAD_POINTS; descriptionsKey = OsmandSettings.IMPASSABLE_ROADS_DESCRIPTIONS; roadsIdsKey = OsmandSettings.IMPASSABLE_ROADS_IDS; + directionsKey = OsmandSettings.IMPASSABLE_ROADS_DIRECTIONS; appModeKey = OsmandSettings.IMPASSABLE_ROADS_APP_MODE_KEYS; } @@ -37,6 +39,21 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { return list; } + public List getDirections(int size) { + List list = new ArrayList<>(); + String directions = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), directionsKey, ""); + if (directions.trim().length() > 0) { + StringTokenizer tok = new StringTokenizer(directions, ","); + while (tok.hasMoreTokens() && list.size() <= size) { + list.add(Double.parseDouble(tok.nextToken())); + } + } + while (list.size() < size) { + list.add(0.0); + } + return list; + } + public List getAppModeKeys(int size) { List list = new ArrayList<>(); String roadIds = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), appModeKey, ""); @@ -55,6 +72,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { public List getImpassableRoadsInfo() { List points = getPoints(); List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); @@ -68,6 +86,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { avoidRoadInfo.id = roadIds.get(i); avoidRoadInfo.latitude = latLon.getLatitude(); avoidRoadInfo.longitude = latLon.getLongitude(); + avoidRoadInfo.direction = directions.get(i); avoidRoadInfo.name = description.getName(); avoidRoadInfo.appModeKey = appModeKeys.get(i); avoidRoadsInfo.add(avoidRoadInfo); @@ -79,15 +98,17 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { public boolean addImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) { List points = getPoints(); List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); roadIds.add(0, avoidRoadInfo.id); + directions.add(0, avoidRoadInfo.direction); points.add(0, new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude)); appModeKeys.add(0, avoidRoadInfo.appModeKey); descriptions.add(0, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name))); - return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys); + return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys, directions); } public boolean updateImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) { @@ -96,13 +117,15 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { int index = points.indexOf(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude)); if (index != -1) { List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); roadIds.set(index, avoidRoadInfo.id); + directions.set(index, avoidRoadInfo.direction); appModeKeys.set(index, avoidRoadInfo.appModeKey); descriptions.set(index, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name))); - return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys); + return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys, directions); } return false; } @@ -111,15 +134,17 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { public boolean deletePoint(int index) { List points = getPoints(); List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); if (index < points.size()) { points.remove(index); roadIds.remove(index); + directions.remove(index); appModeKeys.remove(index); descriptions.remove(index); - return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys); + return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys, directions); } return false; } @@ -128,6 +153,7 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { public boolean deletePoint(LatLon latLon) { List points = getPoints(); List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); @@ -135,9 +161,10 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { if (index != -1) { points.remove(index); roadIds.remove(index); + directions.remove(index); appModeKeys.remove(index); descriptions.remove(index); - return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys); + return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys, directions); } return false; } @@ -146,21 +173,23 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { public boolean movePoint(LatLon latLonEx, LatLon latLonNew) { List points = getPoints(); List roadIds = getRoadIds(points.size()); + List directions = getDirections(points.size()); List appModeKeys = getAppModeKeys(points.size()); List descriptions = getPointDescriptions(points.size()); int i = points.indexOf(latLonEx); if (i != -1) { points.set(i, latLonNew); - return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys); + return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys, directions); } else { return false; } } - public boolean saveAvoidRoadData(List points, List descriptions, - List roadIds, List appModeKeys) { - return savePoints(points, descriptions) && saveRoadIds(roadIds) && saveAppModeKeys(appModeKeys); + public boolean saveAvoidRoadData(List points, List descriptions, List roadIds, + List appModeKeys, List directions) { + return savePoints(points, descriptions) && saveRoadIds(roadIds) + && saveAppModeKeys(appModeKeys) && saveDirections(directions); } public boolean saveRoadIds(List roadIds) { @@ -177,6 +206,20 @@ class ImpassableRoadsStorage extends SettingsMapPointsStorage { .commit(); } + public boolean saveDirections(List directions) { + StringBuilder stringBuilder = new StringBuilder(); + Iterator iterator = directions.iterator(); + while (iterator.hasNext()) { + stringBuilder.append(iterator.next()); + if (iterator.hasNext()) { + stringBuilder.append(","); + } + } + return getSettingsAPI().edit(getOsmandSettings().getGlobalPreferences()) + .putString(directionsKey, stringBuilder.toString()) + .commit(); + } + public boolean saveAppModeKeys(List appModeKeys) { StringBuilder stringBuilder = new StringBuilder(); Iterator iterator = appModeKeys.iterator(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 554b96fc63..fbac3348e8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -2106,6 +2106,7 @@ public class OsmandSettings { public static final String IMPASSABLE_ROAD_POINTS = "impassable_road_points"; public static final String IMPASSABLE_ROADS_DESCRIPTIONS = "impassable_roads_descriptions"; public static final String IMPASSABLE_ROADS_IDS = "impassable_roads_ids"; + public static final String IMPASSABLE_ROADS_DIRECTIONS = "impassable_roads_directions"; public static final String IMPASSABLE_ROADS_APP_MODE_KEYS = "impassable_roads_app_mode_keys"; public void backupPointToStart() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java index 6507ab874e..0f88f0e961 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java @@ -9,6 +9,7 @@ import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.helpers.AvoidSpecificRoads; +import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; @@ -19,16 +20,16 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; -public class AvoidRoadsSettingsItem extends CollectionSettingsItem { +public class AvoidRoadsSettingsItem extends CollectionSettingsItem { private OsmandSettings settings; private AvoidSpecificRoads specificRoads; - public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { super(app, null, items); } - public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @Nullable AvoidRoadsSettingsItem baseItem, @NonNull List items) { + public AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @Nullable AvoidRoadsSettingsItem baseItem, @NonNull List items) { super(app, baseItem, items); } @@ -64,16 +65,16 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem newItems = getNewItems(); + List newItems = getNewItems(); if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { appliedItems = new ArrayList<>(newItems); - for (AvoidSpecificRoads.AvoidRoadInfo duplicate : duplicateItems) { + for (AvoidRoadInfo duplicate : duplicateItems) { LatLon latLon = new LatLon(duplicate.latitude, duplicate.longitude); if (settings.removeImpassableRoad(latLon)) { settings.addImpassableRoad(duplicate); } } - for (AvoidSpecificRoads.AvoidRoadInfo avoidRoad : appliedItems) { + for (AvoidRoadInfo avoidRoad : appliedItems) { settings.addImpassableRoad(avoidRoad); } specificRoads.loadImpassableRoads(); @@ -82,8 +83,8 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem Date: Thu, 17 Dec 2020 14:18:09 +0100 Subject: [PATCH 34/76] Update base class --- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 01203b6f72..3fad53c815 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -94,7 +94,7 @@ public abstract class OsmandPlugin { public abstract String getName(); - public abstract CharSequence getDescription(); + public abstract String getDescription(); @Nullable public Drawable getAssetResourceImage() { From dd69d192e174ac4a796d6175182ca923396e0d17 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 17 Dec 2020 14:21:39 +0100 Subject: [PATCH 35/76] Fix compilation --- OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java index 9f3003e925..13ac0aecc1 100644 --- a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java @@ -100,7 +100,7 @@ public class CustomOsmandPlugin extends OsmandPlugin { } @Override - public CharSequence getDescription() { + public String getDescription() { String description = JsonUtils.getLocalizedResFromMap(app, descriptions, null); return description != null ? Html.fromHtml(description) : null; } From 323cb915d693946fa9abd8eb512b10ef3dacaf8f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 17 Dec 2020 14:26:26 +0100 Subject: [PATCH 36/76] Change String -> CharSequence to make compatible --- OsmAnd/src/net/osmand/access/AccessibilityPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 2 +- .../src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java | 2 +- .../net/osmand/plus/development/OsmandDevelopmentPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java | 2 +- .../src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java | 2 +- .../net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java | 2 +- .../src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java | 2 +- .../src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java | 2 +- OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java b/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java index eb806a5a33..fefc2d9dda 100644 --- a/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java +++ b/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java @@ -56,7 +56,7 @@ public class AccessibilityPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.osmand_accessibility_description); } diff --git a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java index 13ac0aecc1..9f3003e925 100644 --- a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java @@ -100,7 +100,7 @@ public class CustomOsmandPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { String description = JsonUtils.getLocalizedResFromMap(app, descriptions, null); return description != null ? Html.fromHtml(description) : null; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 3fad53c815..01203b6f72 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -94,7 +94,7 @@ public abstract class OsmandPlugin { public abstract String getName(); - public abstract String getDescription(); + public abstract CharSequence getDescription(); @Nullable public Drawable getAssetResourceImage() { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index c42e4de8aa..b7f15624b4 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -581,7 +581,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.audionotes_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index e5d7b3e11d..10997d0f07 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -37,7 +37,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.osmand_development_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index 7883e2c5f0..770f973592 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -83,7 +83,7 @@ public class MapillaryPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.plugin_mapillary_descr); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 7429caadd6..16c60911df 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -117,7 +117,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.record_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java index 7eb775c3a4..2db924aea3 100644 --- a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java @@ -42,7 +42,7 @@ public class NauticalMapsPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(net.osmand.plus.R.string.plugin_nautical_descr); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 90da6cc65d..a9a3262216 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -378,7 +378,7 @@ public class OsmEditingPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.osm_editing_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 464e719a49..26a9a6d0a7 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -168,7 +168,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.osmand_parking_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index e96edba607..d1696c82a1 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -89,7 +89,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.osmand_rastermaps_plugin_description); } diff --git a/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java b/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java index 413b4d9c36..6fab6a62d5 100644 --- a/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java @@ -21,7 +21,7 @@ public class SkiMapsPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(net.osmand.plus.R.string.plugin_ski_descr); } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index a8dc02135b..b6f22610e0 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -119,7 +119,7 @@ public class SRTMPlugin extends OsmandPlugin { } @Override - public String getDescription() { + public CharSequence getDescription() { return app.getString(R.string.srtm_plugin_description); } From 625ff2face1cef73757f58d7d961c59da031aa40 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 15:45:48 +0200 Subject: [PATCH 37/76] Add ability to add and remove avoid roads via aidl --- .../osmand/aidlapi/IOsmAndAidlInterface.aidl | 10 +++- ...ockedRoadParams.aidl => ABlockedRoad.aidl} | 2 +- ...ockedRoadParams.java => ABlockedRoad.java} | 16 +++---- .../navigation/AddBlockedRoadParams.aidl | 3 ++ .../navigation/AddBlockedRoadParams.java | 46 +++++++++++++++++++ .../navigation/RemoveBlockedRoadParams.aidl | 3 ++ .../navigation/RemoveBlockedRoadParams.java | 46 +++++++++++++++++++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 17 +++++-- .../net/osmand/aidl/OsmandAidlServiceV2.java | 38 ++++++++++++++- .../plus/helpers/AvoidSpecificRoads.java | 3 +- 10 files changed, 167 insertions(+), 17 deletions(-) rename OsmAnd-api/src/net/osmand/aidlapi/navigation/{ABlockedRoadParams.aidl => ABlockedRoad.aidl} (57%) rename OsmAnd-api/src/net/osmand/aidlapi/navigation/{ABlockedRoadParams.java => ABlockedRoad.java} (74%) create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.aidl create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.java create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.aidl create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.java diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index 0325c2a723..92115f873b 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -92,7 +92,9 @@ import net.osmand.aidlapi.copyfile.CopyFileParams; import net.osmand.aidlapi.navigation.ANavigationUpdateParams; import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams; -import net.osmand.aidlapi.navigation.ABlockedRoadParams; +import net.osmand.aidlapi.navigation.ABlockedRoad; +import net.osmand.aidlapi.navigation.AddBlockedRoadParams; +import net.osmand.aidlapi.navigation.RemoveBlockedRoadParams; import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams; import net.osmand.aidlapi.contextmenu.UpdateContextMenuButtonsParams; @@ -894,5 +896,9 @@ interface IOsmAndAidlInterface { boolean getProfiles(out List profiles); - boolean getBlockedRoads(out List blockedRoads); + boolean getBlockedRoads(out List blockedRoads); + + boolean addRoadBlock(in AddBlockedRoadParams params); + + boolean removeRoadBlock(in RemoveBlockedRoadParams params); } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.aidl similarity index 57% rename from OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl rename to OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.aidl index ff967858c0..23c31596d5 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.aidl @@ -1,3 +1,3 @@ package net.osmand.aidlapi.navigation; -parcelable ABlockedRoadParams; \ No newline at end of file +parcelable ABlockedRoad; \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.java similarity index 74% rename from OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java rename to OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.java index a6dd2a18b5..e83f64334b 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoadParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/ABlockedRoad.java @@ -5,7 +5,7 @@ import android.os.Parcel; import net.osmand.aidlapi.AidlParams; -public class ABlockedRoadParams extends AidlParams { +public class ABlockedRoad extends AidlParams { private long roadId; private double latitude; @@ -14,7 +14,7 @@ public class ABlockedRoadParams extends AidlParams { private String name; private String appModeKey; - public ABlockedRoadParams(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) { + public ABlockedRoad(long roadId, double latitude, double longitude, double direction, String name, String appModeKey) { this.roadId = roadId; this.latitude = latitude; this.longitude = longitude; @@ -23,19 +23,19 @@ public class ABlockedRoadParams extends AidlParams { this.appModeKey = appModeKey; } - protected ABlockedRoadParams(Parcel in) { + protected ABlockedRoad(Parcel in) { readFromParcel(in); } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator() { @Override - public ABlockedRoadParams createFromParcel(Parcel in) { - return new ABlockedRoadParams(in); + public ABlockedRoad createFromParcel(Parcel in) { + return new ABlockedRoad(in); } @Override - public ABlockedRoadParams[] newArray(int size) { - return new ABlockedRoadParams[size]; + public ABlockedRoad[] newArray(int size) { + return new ABlockedRoad[size]; } }; diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.aidl new file mode 100644 index 0000000000..5eb74b0b53 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.navigation; + +parcelable AddBlockedRoadParams; diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.java new file mode 100644 index 0000000000..b64a9d32ce --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/AddBlockedRoadParams.java @@ -0,0 +1,46 @@ +package net.osmand.aidlapi.navigation; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class AddBlockedRoadParams extends AidlParams { + + private ABlockedRoad blockedRoad; + + public AddBlockedRoadParams(ABlockedRoad blockedRoad) { + this.blockedRoad = blockedRoad; + } + + public AddBlockedRoadParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public AddBlockedRoadParams createFromParcel(Parcel in) { + return new AddBlockedRoadParams(in); + } + + @Override + public AddBlockedRoadParams[] newArray(int size) { + return new AddBlockedRoadParams[size]; + } + }; + + public ABlockedRoad getBlockedRoad() { + return blockedRoad; + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putParcelable("blockedRoad", blockedRoad); + } + + @Override + protected void readFromBundle(Bundle bundle) { + bundle.setClassLoader(ABlockedRoad.class.getClassLoader()); + blockedRoad = bundle.getParcelable("blockedRoad"); + } +} \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.aidl new file mode 100644 index 0000000000..02c9f36f0c --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.navigation; + +parcelable RemoveBlockedRoadParams; diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.java new file mode 100644 index 0000000000..1cb4e2e6a5 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/RemoveBlockedRoadParams.java @@ -0,0 +1,46 @@ +package net.osmand.aidlapi.navigation; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class RemoveBlockedRoadParams extends AidlParams { + + private ABlockedRoad blockedRoad; + + public RemoveBlockedRoadParams(ABlockedRoad blockedRoad) { + this.blockedRoad = blockedRoad; + } + + public RemoveBlockedRoadParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public RemoveBlockedRoadParams createFromParcel(Parcel in) { + return new RemoveBlockedRoadParams(in); + } + + @Override + public RemoveBlockedRoadParams[] newArray(int size) { + return new RemoveBlockedRoadParams[size]; + } + }; + + public ABlockedRoad getBlockedRoad() { + return blockedRoad; + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putParcelable("blockedRoad", blockedRoad); + } + + @Override + protected void readFromBundle(Bundle bundle) { + bundle.setClassLoader(ABlockedRoad.class.getClassLoader()); + blockedRoad = bundle.getParcelable("blockedRoad"); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 864a128114..2f105a7318 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -43,7 +43,7 @@ import net.osmand.aidl.tiles.ASqliteDbFile; import net.osmand.aidlapi.customization.AProfile; import net.osmand.aidlapi.info.AppInfoParams; import net.osmand.aidlapi.map.ALatLon; -import net.osmand.aidlapi.navigation.ABlockedRoadParams; +import net.osmand.aidlapi.navigation.ABlockedRoad; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -2376,14 +2376,25 @@ public class OsmandAidlApi { return true; } - public boolean getBlockedRoads(List blockedRoads) { + public boolean getBlockedRoads(List blockedRoads) { Map impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads(); for (AvoidRoadInfo info : impassableRoads.values()) { - blockedRoads.add(new ABlockedRoadParams(info.id, info.latitude, info.longitude, info.direction, info.name, info.appModeKey)); + blockedRoads.add(new ABlockedRoad(info.id, info.latitude, info.longitude, info.direction, info.name, info.appModeKey)); } return true; } + public boolean addRoadBlock(ABlockedRoad road) { + LatLon latLon = new LatLon(road.getLatitude(), road.getLongitude()); + app.getAvoidSpecificRoads().addImpassableRoad(null, latLon, false, false, null); + return true; + } + + public boolean removeRoadBlock(ABlockedRoad road) { + app.getAvoidSpecificRoads().removeImpassableRoad(new LatLon(road.getLatitude(), road.getLongitude())); + return true; + } + private static class FileCopyInfo { long startTime; long lastAccessTime; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index c28ef2842b..2cd422873d 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -73,14 +73,16 @@ import net.osmand.aidlapi.navdrawer.NavDrawerFooterParams; import net.osmand.aidlapi.navdrawer.NavDrawerHeaderParams; import net.osmand.aidlapi.navdrawer.NavDrawerItem; import net.osmand.aidlapi.navdrawer.SetNavDrawerItemsParams; -import net.osmand.aidlapi.navigation.ABlockedRoadParams; +import net.osmand.aidlapi.navigation.ABlockedRoad; import net.osmand.aidlapi.navigation.ANavigationUpdateParams; import net.osmand.aidlapi.navigation.ANavigationVoiceRouterMessageParams; +import net.osmand.aidlapi.navigation.AddBlockedRoadParams; import net.osmand.aidlapi.navigation.MuteNavigationParams; import net.osmand.aidlapi.navigation.NavigateGpxParams; import net.osmand.aidlapi.navigation.NavigateParams; import net.osmand.aidlapi.navigation.NavigateSearchParams; import net.osmand.aidlapi.navigation.PauseNavigationParams; +import net.osmand.aidlapi.navigation.RemoveBlockedRoadParams; import net.osmand.aidlapi.navigation.ResumeNavigationParams; import net.osmand.aidlapi.navigation.StopNavigationParams; import net.osmand.aidlapi.navigation.UnmuteNavigationParams; @@ -1399,7 +1401,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener } @Override - public boolean getBlockedRoads(List blockedRoads) { + public boolean getBlockedRoads(List blockedRoads) { try { OsmandAidlApi api = getApi("getBlockedRoads"); return api != null && api.getBlockedRoads(blockedRoads); @@ -1408,6 +1410,38 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } + + @Override + public boolean addRoadBlock(AddBlockedRoadParams params) { + try { + OsmandAidlApi api = getApi("addRoadBlock"); + if (params != null && api != null) { + ABlockedRoad road = params.getBlockedRoad(); + if (road != null) { + return api.addRoadBlock(road); + } + } + } catch (Exception e) { + handleException(e); + } + return false; + } + + @Override + public boolean removeRoadBlock(RemoveBlockedRoadParams params) { + try { + OsmandAidlApi api = getApi("removeRoadBlock"); + if (params != null && api != null) { + ABlockedRoad road = params.getBlockedRoad(); + if (road != null) { + return api.removeRoadBlock(road); + } + } + } catch (Exception e) { + handleException(e); + } + return false; + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 690c990589..bfa84b8474 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -393,6 +393,7 @@ public class AvoidSpecificRoads { if (object != null) { avoidRoadInfo.id = object.id; // avoidRoadInfo.direction = object.directionRoute(0, true); + avoidRoadInfo.direction = Double.NaN; } else { avoidRoadInfo.id = 0; avoidRoadInfo.direction = Double.NaN; @@ -406,7 +407,7 @@ public class AvoidSpecificRoads { public static class AvoidRoadInfo { public long id; - public double direction; + public double direction = Double.NaN; public double latitude; public double longitude; public String name; From 4c7f39abb8bd79d17a2f27822d96fbe7dbe9c164 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 17:16:01 +0200 Subject: [PATCH 38/76] Fix #10396 --- .../aidlapi/navigation/NavigateGpxParams.java | 13 +++++- .../aidlapi/navigation/NavigateParams.java | 11 ++++- .../navigation/NavigateSearchParams.java | 12 +++++- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 33 +++++++++------ .../net/osmand/aidl/OsmandAidlService.java | 12 +++--- .../net/osmand/aidl/OsmandAidlServiceV2.java | 7 ++-- .../aidl/navigation/NavigateGpxParams.java | 14 +++++-- .../aidl/navigation/NavigateParams.java | 12 +++++- .../aidl/navigation/NavigateSearchParams.java | 11 ++++- .../plus/helpers/ExternalApiHelper.java | 40 +++++++++++-------- 10 files changed, 117 insertions(+), 48 deletions(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateGpxParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateGpxParams.java index 8b4901b35e..e6fad0c1b1 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateGpxParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateGpxParams.java @@ -11,15 +11,18 @@ public class NavigateGpxParams extends AidlParams { private String data; private Uri uri; private boolean force; + private boolean needLocationPermission; - public NavigateGpxParams(String data, boolean force) { + public NavigateGpxParams(String data, boolean force, boolean needLocationPermission) { this.data = data; this.force = force; + this.needLocationPermission = needLocationPermission; } - public NavigateGpxParams(Uri uri, boolean force) { + public NavigateGpxParams(Uri uri, boolean force, boolean needLocationPermission) { this.uri = uri; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateGpxParams(Parcel in) { @@ -50,11 +53,16 @@ public class NavigateGpxParams extends AidlParams { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToBundle(Bundle bundle) { bundle.putString("data", data); bundle.putParcelable("uri", uri); bundle.putBoolean("force", force); + bundle.putBoolean("needLocationPermission", needLocationPermission); } @Override @@ -62,5 +70,6 @@ public class NavigateGpxParams extends AidlParams { data = bundle.getString("data"); uri = bundle.getParcelable("uri"); force = bundle.getBoolean("force"); + needLocationPermission = bundle.getBoolean("needLocationPermission"); } } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateParams.java index 6dff82b7e4..ad83489f17 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateParams.java @@ -17,8 +17,10 @@ public class NavigateParams extends AidlParams { private double destLon; private boolean force; + private boolean needLocationPermission; - public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, double destLon, String profile, boolean force) { + public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, + double destLon, String profile, boolean force, boolean needLocationPermission) { this.startName = startName; this.startLat = startLat; this.startLon = startLon; @@ -27,6 +29,7 @@ public class NavigateParams extends AidlParams { this.destLon = destLon; this.profile = profile; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateParams(Parcel in) { @@ -77,6 +80,10 @@ public class NavigateParams extends AidlParams { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToBundle(Bundle bundle) { bundle.putString("startName", startName); @@ -87,6 +94,7 @@ public class NavigateParams extends AidlParams { bundle.putDouble("destLon", destLon); bundle.putString("profile", profile); bundle.putBoolean("force", force); + bundle.putBoolean("needLocationPermission", needLocationPermission); } @Override @@ -99,5 +107,6 @@ public class NavigateParams extends AidlParams { destLon = bundle.getDouble("destLon"); profile = bundle.getString("profile"); force = bundle.getBoolean("force"); + needLocationPermission = bundle.getBoolean("needLocationPermission"); } } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateSearchParams.java b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateSearchParams.java index d548dab2f3..a5edc7524c 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateSearchParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/navigation/NavigateSearchParams.java @@ -17,10 +17,11 @@ public class NavigateSearchParams extends AidlParams { private double searchLon; private boolean force; + private boolean needLocationPermission; public NavigateSearchParams(String startName, double startLat, double startLon, - String searchQuery, double searchLat, double searchLon, - String profile, boolean force) { + String searchQuery, double searchLat, double searchLon, + String profile, boolean force, boolean needLocationPermission) { this.startName = startName; this.startLat = startLat; this.startLon = startLon; @@ -29,6 +30,7 @@ public class NavigateSearchParams extends AidlParams { this.searchLon = searchLon; this.profile = profile; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateSearchParams(Parcel in) { @@ -79,6 +81,10 @@ public class NavigateSearchParams extends AidlParams { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToBundle(Bundle bundle) { bundle.putString("startName", startName); @@ -89,6 +95,7 @@ public class NavigateSearchParams extends AidlParams { bundle.putBoolean("force", force); bundle.putDouble("searchLat", searchLat); bundle.putDouble("searchLon", searchLon); + bundle.putBoolean("needLocationPermission", needLocationPermission); } @Override @@ -101,5 +108,6 @@ public class NavigateSearchParams extends AidlParams { force = bundle.getBoolean("force"); searchLat = bundle.getDouble("searchLat"); searchLon = bundle.getDouble("searchLon"); + needLocationPermission = bundle.getBoolean("needLocationPermission"); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 6b9bb29dea..a332a7fd97 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -177,6 +177,7 @@ public class OsmandAidlApi { private static final String AIDL_DATA = "aidl_data"; private static final String AIDL_URI = "aidl_uri"; private static final String AIDL_FORCE = "aidl_force"; + private static final String AIDL_LOCATION_PERMISSION = "aidl_location_permission"; private static final String AIDL_SEARCH_QUERY = "aidl_search_query"; private static final String AIDL_SEARCH_LAT = "aidl_search_lat"; private static final String AIDL_SEARCH_LON = "aidl_search_lon"; @@ -208,7 +209,7 @@ public class OsmandAidlApi { private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; - private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{ + private static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[] { ApplicationMode.CAR, ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN @@ -287,7 +288,7 @@ public class OsmandAidlApi { } private void initOsmandTelegram() { - String[] packages = new String[]{"net.osmand.telegram", "net.osmand.telegram.debug"}; + String[] packages = new String[] {"net.osmand.telegram", "net.osmand.telegram.debug"}; Intent intent = new Intent("net.osmand.telegram.InitApp"); for (String pack : packages) { intent.setComponent(new ComponentName(pack, "net.osmand.telegram.InitAppBroadcastReceiver")); @@ -601,6 +602,7 @@ public class OsmandAidlApi { final RoutingHelper routingHelper = app.getRoutingHelper(); boolean force = intent.getBooleanExtra(AIDL_FORCE, true); + final boolean locationPermission = intent.getBooleanExtra(AIDL_LOCATION_PERMISSION, false); if (routingHelper.isFollowingMode() && !force) { mapActivity.getMapActions().stopNavigationActionConfirm(new DialogInterface.OnDismissListener() { @@ -608,12 +610,12 @@ public class OsmandAidlApi { public void onDismiss(DialogInterface dialog) { MapActivity mapActivity = mapActivityRef.get(); if (mapActivity != null && !routingHelper.isFollowingMode()) { - ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile); + ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission); } } }); } else { - ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile); + ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission); } } } @@ -667,6 +669,7 @@ public class OsmandAidlApi { if (searchLocation != null) { final RoutingHelper routingHelper = app.getRoutingHelper(); boolean force = intent.getBooleanExtra(AIDL_FORCE, true); + final boolean locationPermission = intent.getBooleanExtra(AIDL_LOCATION_PERMISSION, false); if (routingHelper.isFollowingMode() && !force) { mapActivity.getMapActions().stopNavigationActionConfirm(new DialogInterface.OnDismissListener() { @@ -674,12 +677,14 @@ public class OsmandAidlApi { public void onDismiss(DialogInterface dialog) { MapActivity mapActivity = mapActivityRef.get(); if (mapActivity != null && !routingHelper.isFollowingMode()) { - ExternalApiHelper.searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, false); + ExternalApiHelper.searchAndNavigate(mapActivity, searchLocation, start, + startDesc, profile, searchQuery, false, locationPermission); } } }); } else { - ExternalApiHelper.searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, false); + ExternalApiHelper.searchAndNavigate(mapActivity, searchLocation, start, + startDesc, profile, searchQuery, false, locationPermission); } } } @@ -698,7 +703,8 @@ public class OsmandAidlApi { GPXFile gpx = loadGpxFileFromIntent(mapActivity, intent); if (gpx != null) { boolean force = intent.getBooleanExtra(AIDL_FORCE, false); - ExternalApiHelper.saveAndNavigateGpx(mapActivity, gpx, force); + boolean locationPermission = intent.getBooleanExtra(AIDL_LOCATION_PERMISSION, false); + ExternalApiHelper.saveAndNavigateGpx(mapActivity, gpx, force, locationPermission); } } } @@ -1652,8 +1658,8 @@ public class OsmandAidlApi { } boolean navigate(String startName, double startLat, double startLon, - String destName, double destLat, double destLon, - String profile, boolean force) { + String destName, double destLat, double destLon, + String profile, boolean force, boolean requestLocationPermission) { Intent intent = new Intent(); intent.setAction(AIDL_NAVIGATE); intent.putExtra(AIDL_START_NAME, startName); @@ -1664,13 +1670,14 @@ public class OsmandAidlApi { intent.putExtra(AIDL_DEST_LON, destLon); intent.putExtra(AIDL_PROFILE, profile); intent.putExtra(AIDL_FORCE, force); + intent.putExtra(AIDL_LOCATION_PERMISSION, requestLocationPermission); app.sendBroadcast(intent); return true; } boolean navigateSearch(String startName, double startLat, double startLon, - String searchQuery, double searchLat, double searchLon, - String profile, boolean force) { + String searchQuery, double searchLat, double searchLon, + String profile, boolean force, boolean requestLocationPermission) { Intent intent = new Intent(); intent.setAction(AIDL_NAVIGATE_SEARCH); intent.putExtra(AIDL_START_NAME, startName); @@ -1681,6 +1688,7 @@ public class OsmandAidlApi { intent.putExtra(AIDL_SEARCH_LON, searchLon); intent.putExtra(AIDL_PROFILE, profile); intent.putExtra(AIDL_FORCE, force); + intent.putExtra(AIDL_LOCATION_PERMISSION, requestLocationPermission); app.sendBroadcast(intent); return true; } @@ -1720,12 +1728,13 @@ public class OsmandAidlApi { return true; } - boolean navigateGpx(String data, Uri uri, boolean force) { + boolean navigateGpx(String data, Uri uri, boolean force, boolean requestLocationPermission) { Intent intent = new Intent(); intent.setAction(AIDL_NAVIGATE_GPX); intent.putExtra(AIDL_DATA, data); intent.putExtra(AIDL_URI, uri); intent.putExtra(AIDL_FORCE, force); + intent.putExtra(AIDL_LOCATION_PERMISSION, requestLocationPermission); app.sendBroadcast(intent); return true; } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 99e888973f..2760dbe1d0 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -44,6 +44,7 @@ import net.osmand.aidl.gpx.RemoveGpxParams; import net.osmand.aidl.gpx.ShowGpxParams; import net.osmand.aidl.gpx.StartGpxRecordingParams; import net.osmand.aidl.gpx.StopGpxRecordingParams; +import net.osmand.aidl.lock.SetLockStateParams; import net.osmand.aidl.map.ALatLon; import net.osmand.aidl.map.SetMapLocationParams; import net.osmand.aidl.maplayer.AddMapLayerParams; @@ -85,10 +86,9 @@ import net.osmand.aidl.quickaction.QuickActionParams; import net.osmand.aidl.search.SearchParams; import net.osmand.aidl.search.SearchResult; import net.osmand.aidl.tiles.ASqliteDbFile; -import net.osmand.aidl.lock.SetLockStateParams; import net.osmand.data.LatLon; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -736,7 +736,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return params != null && api != null && api.navigate( params.getStartName(), params.getStartLat(), params.getStartLon(), params.getDestName(), params.getDestLat(), params.getDestLon(), - params.getProfile(), params.isForce()); + params.getProfile(), params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; @@ -747,7 +747,8 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { public boolean navigateGpx(NavigateGpxParams params) { try { OsmandAidlApi api = getApi("navigateGpx"); - return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), params.isForce()); + return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), + params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; @@ -857,7 +858,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return params != null && api != null && api.navigateSearch( params.getStartName(), params.getStartLat(), params.getStartLon(), params.getSearchQuery(), params.getSearchLat(), params.getSearchLon(), - params.getProfile(), params.isForce()); + params.getProfile(), params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; @@ -1328,6 +1329,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return false; } } + @Override public boolean setLockState(SetLockStateParams params) { try { diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 9943257c03..1f681f5bb7 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -693,7 +693,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return params != null && api != null && api.navigate( params.getStartName(), params.getStartLat(), params.getStartLon(), params.getDestName(), params.getDestLat(), params.getDestLon(), - params.getProfile(), params.isForce()); + params.getProfile(), params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; @@ -704,7 +704,8 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener public boolean navigateGpx(NavigateGpxParams params) { try { OsmandAidlApi api = getApi("navigateGpx"); - return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), params.isForce()); + return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), + params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; @@ -814,7 +815,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return params != null && api != null && api.navigateSearch( params.getStartName(), params.getStartLat(), params.getStartLon(), params.getSearchQuery(), params.getSearchLat(), params.getSearchLon(), - params.getProfile(), params.isForce()); + params.getProfile(), params.isForce(), params.isNeedLocationPermission()); } catch (Exception e) { handleException(e); return false; diff --git a/OsmAnd/src/net/osmand/aidl/navigation/NavigateGpxParams.java b/OsmAnd/src/net/osmand/aidl/navigation/NavigateGpxParams.java index 6e8fb8efe7..0944c1a5f9 100644 --- a/OsmAnd/src/net/osmand/aidl/navigation/NavigateGpxParams.java +++ b/OsmAnd/src/net/osmand/aidl/navigation/NavigateGpxParams.java @@ -9,15 +9,18 @@ public class NavigateGpxParams implements Parcelable { private String data; private Uri uri; private boolean force; + private boolean needLocationPermission; - public NavigateGpxParams(String data, boolean force) { + public NavigateGpxParams(String data, boolean force, boolean needLocationPermission) { this.data = data; this.force = force; + this.needLocationPermission = needLocationPermission; } - public NavigateGpxParams(Uri uri, boolean force) { + public NavigateGpxParams(Uri uri, boolean force, boolean needLocationPermission) { this.uri = uri; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateGpxParams(Parcel in) { @@ -48,22 +51,27 @@ public class NavigateGpxParams implements Parcelable { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToParcel(Parcel out, int flags) { out.writeString(data); out.writeParcelable(uri, flags); out.writeByte((byte) (force ? 1 : 0)); + out.writeByte((byte) (needLocationPermission ? 1 : 0)); } private void readFromParcel(Parcel in) { data = in.readString(); uri = in.readParcelable(Uri.class.getClassLoader()); force = in.readByte() != 0; + needLocationPermission = in.readByte() != 0; } @Override public int describeContents() { return 0; } - } diff --git a/OsmAnd/src/net/osmand/aidl/navigation/NavigateParams.java b/OsmAnd/src/net/osmand/aidl/navigation/NavigateParams.java index 8b0bdeb1eb..ce3b7ae0e6 100644 --- a/OsmAnd/src/net/osmand/aidl/navigation/NavigateParams.java +++ b/OsmAnd/src/net/osmand/aidl/navigation/NavigateParams.java @@ -13,8 +13,10 @@ public class NavigateParams implements Parcelable { private double destLon; private String profile; private boolean force; + private boolean needLocationPermission; - public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, double destLon, String profile, boolean force) { + public NavigateParams(String startName, double startLat, double startLon, String destName, double destLat, + double destLon, String profile, boolean force, boolean needLocationPermission) { this.startName = startName; this.startLat = startLat; this.startLon = startLon; @@ -23,6 +25,7 @@ public class NavigateParams implements Parcelable { this.destLon = destLon; this.profile = profile; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateParams(Parcel in) { @@ -73,6 +76,10 @@ public class NavigateParams implements Parcelable { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToParcel(Parcel out, int flags) { out.writeString(startName); @@ -83,6 +90,7 @@ public class NavigateParams implements Parcelable { out.writeDouble(destLon); out.writeString(profile); out.writeByte((byte) (force ? 1 : 0)); + out.writeByte((byte) (needLocationPermission ? 1 : 0)); } private void readFromParcel(Parcel in) { @@ -94,11 +102,11 @@ public class NavigateParams implements Parcelable { destLon = in.readDouble(); profile = in.readString(); force = in.readByte() != 0; + needLocationPermission = in.readByte() != 0; } @Override public int describeContents() { return 0; } - } diff --git a/OsmAnd/src/net/osmand/aidl/navigation/NavigateSearchParams.java b/OsmAnd/src/net/osmand/aidl/navigation/NavigateSearchParams.java index b092bcd4eb..8fc9ccea18 100644 --- a/OsmAnd/src/net/osmand/aidl/navigation/NavigateSearchParams.java +++ b/OsmAnd/src/net/osmand/aidl/navigation/NavigateSearchParams.java @@ -13,10 +13,11 @@ public class NavigateSearchParams implements Parcelable { private double searchLon; private String profile; private boolean force; + private boolean needLocationPermission; public NavigateSearchParams(String startName, double startLat, double startLon, String searchQuery, double searchLat, double searchLon, - String profile, boolean force) { + String profile, boolean force, boolean needLocationPermission) { this.startName = startName; this.startLat = startLat; this.startLon = startLon; @@ -25,6 +26,7 @@ public class NavigateSearchParams implements Parcelable { this.searchLon = searchLon; this.profile = profile; this.force = force; + this.needLocationPermission = needLocationPermission; } public NavigateSearchParams(Parcel in) { @@ -75,6 +77,10 @@ public class NavigateSearchParams implements Parcelable { return force; } + public boolean isNeedLocationPermission() { + return needLocationPermission; + } + @Override public void writeToParcel(Parcel out, int flags) { out.writeString(startName); @@ -85,6 +91,7 @@ public class NavigateSearchParams implements Parcelable { out.writeByte((byte) (force ? 1 : 0)); out.writeDouble(searchLat); out.writeDouble(searchLon); + out.writeByte((byte) (needLocationPermission ? 1 : 0)); } private void readFromParcel(Parcel in) { @@ -96,11 +103,11 @@ public class NavigateSearchParams implements Parcelable { force = in.readByte() != 0; searchLat = in.readDouble(); searchLon = in.readDouble(); + needLocationPermission = in.readByte() != 0; } @Override public int describeContents() { return 0; } - } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 57d6039145..5740f8fceb 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -30,6 +30,7 @@ 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.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -129,6 +130,7 @@ public class ExternalApiHelper { public static final String PARAM_URI = "uri"; public static final String PARAM_DATA = "data"; public static final String PARAM_FORCE = "force"; + public static final String PARAM_LOCATION_PERMISSION = "location_permission"; public static final String PARAM_START_NAME = "start_name"; public static final String PARAM_DEST_NAME = "dest_name"; @@ -237,7 +239,8 @@ public class ExternalApiHelper { if (gpx != null) { if (navigate) { boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false); - saveAndNavigateGpx(mapActivity, gpx, force); + boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false); + saveAndNavigateGpx(mapActivity, gpx, force, locationPermission); } else { app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); } @@ -289,6 +292,7 @@ public class ExternalApiHelper { final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName); boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false); + final boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false); final RoutingHelper routingHelper = app.getRoutingHelper(); if (routingHelper.isFollowingMode() && !force) { @@ -297,12 +301,12 @@ public class ExternalApiHelper { @Override public void onDismiss(DialogInterface dialog) { if (!routingHelper.isFollowingMode()) { - startNavigation(mapActivity, start, startDesc, dest, destDesc, profile); + startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission); } } }); } else { - startNavigation(mapActivity, start, startDesc, dest, destDesc, profile); + startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission); } } @@ -348,6 +352,7 @@ public class ExternalApiHelper { resultCode = RESULT_CODE_ERROR_SEARCH_LOCATION_UNDEFINED; } else { boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false); + final boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false); final RoutingHelper routingHelper = app.getRoutingHelper(); if (routingHelper.isFollowingMode() && !force) { @@ -356,12 +361,12 @@ public class ExternalApiHelper { @Override public void onDismiss(DialogInterface dialog) { if (!routingHelper.isFollowingMode()) { - searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults); + searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults, locationPermission); } } }); } else { - searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults); + searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults, locationPermission); } resultCode = Activity.RESULT_OK; } @@ -629,7 +634,8 @@ public class ExternalApiHelper { return null; } - public static void saveAndNavigateGpx(MapActivity mapActivity, final GPXFile gpxFile, final boolean force) { + public static void saveAndNavigateGpx(MapActivity mapActivity, final GPXFile gpxFile, + final boolean force, final boolean checkLocationPermission) { final WeakReference mapActivityRef = new WeakReference<>(mapActivity); if (Algorithms.isEmpty(gpxFile.path)) { @@ -670,12 +676,12 @@ public class ExternalApiHelper { public void onDismiss(DialogInterface dialog) { MapActivity mapActivity = mapActivityRef.get(); if (mapActivity != null && !routingHelper.isFollowingMode()) { - ExternalApiHelper.startNavigation(mapActivity, gpxFile); + ExternalApiHelper.startNavigation(mapActivity, gpxFile, checkLocationPermission); } } }); } else { - startNavigation(mapActivity, gpxFile); + startNavigation(mapActivity, gpxFile, checkLocationPermission); } } } @@ -705,23 +711,22 @@ public class ExternalApiHelper { mapContextMenu.show(new LatLon(lat, lon), pointDescription, object); } - static public void startNavigation(MapActivity mapActivity, - @NonNull GPXFile gpx) { - startNavigation(mapActivity, gpx, null, null, null, null, null); + static public void startNavigation(MapActivity mapActivity, @NonNull GPXFile gpx, boolean checkLocationPermission) { + startNavigation(mapActivity, gpx, null, null, null, null, null, checkLocationPermission); } static public void startNavigation(MapActivity mapActivity, @Nullable LatLon from, @Nullable PointDescription fromDesc, @Nullable LatLon to, @Nullable PointDescription toDesc, - @NonNull ApplicationMode mode) { - startNavigation(mapActivity, null, from, fromDesc, to, toDesc, mode); + @NonNull ApplicationMode mode, boolean checkLocationPermission) { + startNavigation(mapActivity, null, from, fromDesc, to, toDesc, mode, checkLocationPermission); } static private void startNavigation(MapActivity mapActivity, GPXFile gpx, LatLon from, PointDescription fromDesc, LatLon to, PointDescription toDesc, - ApplicationMode mode) { + ApplicationMode mode, boolean checkLocationPermission) { OsmandApplication app = mapActivity.getMyApplication(); RoutingHelper routingHelper = app.getRoutingHelper(); if (gpx == null) { @@ -745,12 +750,15 @@ public class ExternalApiHelper { app.getRoutingHelper().notifyIfRouteIsCalculated(); routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false); } + if (checkLocationPermission) { + OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity); + } } static public void searchAndNavigate(@NonNull MapActivity mapActivity, @NonNull final LatLon searchLocation, @Nullable final LatLon from, @Nullable final PointDescription fromDesc, @NonNull final ApplicationMode mode, @NonNull final String searchQuery, - final boolean showSearchResults) { + final boolean showSearchResults, final boolean checkLocationPermission) { final WeakReference mapActivityRef = new WeakReference<>(mapActivity); OsmandApplication app = mapActivity.getMyApplication(); @@ -791,7 +799,7 @@ public class ExternalApiHelper { LatLon to = new LatLon(res.getLatitude(), res.getLongitude()); PointDescription toDesc = new PointDescription( PointDescription.POINT_TYPE_TARGET, res.getLocalName() + ", " + res.getLocalTypeName()); - startNavigation(mapActivity, from, fromDesc, to, toDesc, mode); + startNavigation(mapActivity, from, fromDesc, to, toDesc, mode, checkLocationPermission); } else { mapActivity.getMyApplication().showToastMessage(mapActivity.getString(R.string.search_nothing_found)); } From 50162f229ab53c555a52b57f41842fecf4ec7e71 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 17 Dec 2020 17:25:15 +0200 Subject: [PATCH 39/76] Sort: Allow to reverse all points --- .../plus/helpers/WaypointDialogHelper.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 628bc7ed71..24d684a408 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -39,6 +39,7 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -266,17 +267,13 @@ public class WaypointDialogHelper { public static void switchAllPoint(final OsmandApplication app, final Activity ctx, final WaypointDialogHelper helper) { - List all; TargetPointsHelper targets = app.getTargetPointsHelper(); - all = targets.getIntermediatePointsWithTarget(); - - List cur = targets.getIntermediatePointsWithTarget(); - for (int j = 0; j < cur.size() && j < all.size(); j++) { - if (cur.get(j) != all.get(j)) { - break; - } - } - targets.reorderAllTargetPoints(all, true); + List points = targets.getAllPoints(); + Collections.reverse(points); + TargetPoint start = points.get(0); + targets.setStartPoint(start.point, false, start.getOriginalPointDescription()); + points.remove(start); + targets.reorderAllTargetPoints(points, true); updateControls(ctx, helper); } @@ -508,8 +505,6 @@ public class WaypointDialogHelper { .create(); items.add(reorderStartAndFinishItem); - items.add(new DividerHalfItem(getContext())); - BaseBottomSheetItem reorderAllItems = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)) .setTitle(getString(R.string.switch_all_points)) @@ -530,12 +525,14 @@ public class WaypointDialogHelper { }) .create(); if (getMyApplication() != null) { - int intermediateSize = getMyApplication().getTargetPointsHelper().getAllPoints().size(); + int intermediateSize = getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(); if (intermediateSize > 2) { items.add(reorderAllItems); } } + items.add(new DividerHalfItem(getContext())); + final BaseBottomSheetItem[] addWaypointItem = new BaseBottomSheetItem[1]; addWaypointItem[0] = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_plus)) From 398724c9ffbca4279b0bebf0c1c30c87eff7801f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 17 Dec 2020 17:44:24 +0200 Subject: [PATCH 40/76] Fix bookmarks --- .../src/net/osmand/plus/AppInitializer.java | 2 +- .../osmand/plus/activities/MapActivity.java | 1 - .../WikivoyageArticleDialogFragment.java | 26 +++++-- .../plus/wikivoyage/data/TravelObfHelper.java | 76 ++++++++++--------- .../explore/WikivoyageExploreActivity.java | 15 +--- .../travelcards/ArticleTravelCard.java | 11 --- 6 files changed, 62 insertions(+), 69 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 52b8cc89dc..c372a4de98 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -660,7 +660,7 @@ public class AppInitializer implements IProgress { initPoiTypes(); notifyEvent(InitEvents.POI_TYPES_INITIALIZED); app.resourceManager.reloadIndexesOnStart(this, warnings); - + app.travelHelper.initializeDataOnAppStartup(); // native depends on renderers initNativeCore(); notifyEvent(InitEvents.NATIVE_INITIALIZED); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index aecd00b12d..313fa6b917 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -450,7 +450,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (dashboardOnMap != null) { dashboardOnMap.updateLocation(true, true, false); } - app.getTravelHelper().initializeDataOnAppStartup(); findViewById(R.id.init_progress).setVisibility(View.GONE); findViewById(R.id.drawer_layout).invalidate(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 074e9efd27..2d834c444f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -55,7 +55,7 @@ import java.util.Map; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; -public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment { +public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment implements TravelLocalDataHelper.Listener { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -212,6 +212,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme @Override public void onPause() { super.onPause(); + getMyApplication().getTravelHelper().getBookmarksHelper().removeListener(this); if (webViewClient != null) { webViewClient.stopRunningAsyncTasks(); } @@ -220,6 +221,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme @Override public void onResume() { super.onResume(); + getMyApplication().getTravelHelper().getBookmarksHelper().addListener(this); OsmandSettings settings = getMyApplication().getSettings(); if (!settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.get()) { FragmentActivity activity = getActivity(); @@ -250,10 +252,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme getMyApplication().getTravelHelper().createGpxFile(article); helper.addArticleToSaved(article); } - Activity activity = getActivity(); - if (activity instanceof WikivoyageExploreActivity) { - ((WikivoyageExploreActivity) activity).updateSavedArticles(); - } updateSaveButton(); } } @@ -413,6 +411,24 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } } + @Override + public void savedArticlesUpdated() { + WikivoyageExploreActivity activity = getExploreActivity(); + if (activity != null) { + activity.updateFragments(); + } + } + + @Nullable + private WikivoyageExploreActivity getExploreActivity() { + Activity activity = getActivity(); + if (activity instanceof WikivoyageExploreActivity) { + return (WikivoyageExploreActivity) activity; + } else { + return null; + } + } + private class WikivoyageArticleWebAppInterface { @JavascriptInterface diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 4308ede839..7fa838cf2a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -35,7 +35,6 @@ public class TravelObfHelper implements TravelHelper { private List popularArticles = new ArrayList<>(); private final Map cachedArticles; private final TravelLocalDataHelper localDataHelper; - private List travelBookReaders; public TravelObfHelper(OsmandApplication app) { this.app = app; @@ -50,7 +49,6 @@ public class TravelObfHelper implements TravelHelper { @Override public void initializeDataOnAppStartup() { - travelBookReaders = app.getResourceManager().getTravelRepositories(); } @Override @@ -64,7 +62,7 @@ public class TravelObfHelper implements TravelHelper { String language = app.getLanguage(); popularArticles.clear(); final List amenities = new ArrayList<>(); - for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { if (travelBookReader == null) { popularArticles = new ArrayList<>(); @@ -92,7 +90,7 @@ public class TravelObfHelper implements TravelHelper { if (amenities.size() > 0) { for (Amenity a : amenities) { - if (!a.getName(language).equals("")) { + if (!Algorithms.isEmpty(a.getName(language))) { TravelArticle article = readArticle(a, language); popularArticles.add(article); cachedArticles.put(article.routeId, article); @@ -122,22 +120,22 @@ public class TravelObfHelper implements TravelHelper { private TravelArticle readArticle(Amenity amenity, String lang) { TravelArticle res = new TravelArticle(); - res.title = amenity.getName(lang).equals("") ? amenity.getName() : amenity.getName(lang); + res.title = Algorithms.isEmpty(amenity.getName(lang)) ? amenity.getName() : amenity.getName(lang); res.content = amenity.getDescription(lang); - res.isPartOf = checkNull(amenity.getTagContent(Amenity.IS_PART, lang)); + res.isPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_PART, lang)); res.lat = amenity.getLocation().getLatitude(); res.lon = amenity.getLocation().getLongitude(); - res.imageTitle = checkNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang)); + res.imageTitle = emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang)); res.routeId = getRouteId(amenity); res.originalId = 0; //? res.lang = lang; - res.contentsJson = checkNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); - res.aggregatedPartOf = checkNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); + res.contentsJson = emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); + res.aggregatedPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); return res; } - String checkNull(String tagContent) { - return tagContent == null ? "" : tagContent; + private String emptyIfNull(String text) { + return text == null ? "" : text; } private String getRouteId(Amenity amenity) { @@ -146,7 +144,7 @@ public class TravelObfHelper implements TravelHelper { @Override public boolean isAnyTravelBookPresent() { - return !Algorithms.isEmpty(travelBookReaders); + return !Algorithms.isEmpty(getTravelBookReaders()); } @NonNull @@ -175,35 +173,31 @@ public class TravelObfHelper implements TravelHelper { public TravelArticle getArticleByTitle(final String title, final String lang) { TravelArticle article = null; final List amenities = new ArrayList<>(); - for (BinaryMapIndexReader travelBookReader : travelBookReaders) { + for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - if (travelBookReader != null) { - int left = Integer.MIN_VALUE; - int right = Integer.MAX_VALUE; - int top = Integer.MIN_VALUE; - int bottom = Integer.MAX_VALUE; - LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); - BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - MapUtils.get31TileNumberX(location.getLongitude()), - MapUtils.get31TileNumberY(location.getLatitude()), title, left, right, top, bottom, - new ResultMatcher() { - @Override - public boolean publish(Amenity amenity) { - if (title.equalsIgnoreCase(amenity.getName(lang)) - && amenity.getSubType().equals(ROUTE_ARTICLE)) { - amenities.add(amenity); - } - return false; + int left = 0; + int right = Integer.MAX_VALUE; + int top = 0; + int bottom = Integer.MAX_VALUE; + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + 0, 0, title, left, right, top, bottom, + new ResultMatcher() { + @Override + public boolean publish(Amenity amenity) { + if (title.equalsIgnoreCase(amenity.getName(lang)) + && amenity.getSubType().equals(ROUTE_ARTICLE)) { + amenities.add(amenity); } + return false; + } - @Override - public boolean isCancelled() { - return false; - } - }); + @Override + public boolean isCancelled() { + return false; + } + }); - travelBookReader.searchPoiByName(req); - } + travelBookReader.searchPoiByName(req); } catch (IOException e) { LOG.error(e.getMessage()); } @@ -215,6 +209,14 @@ public class TravelObfHelper implements TravelHelper { return article; } + private List getTravelBookReaders() { + if (!app.isApplicationInitializing()) { + return app.getResourceManager().getTravelRepositories(); + } else { + return new ArrayList<>(); + } + } + @Override public String getArticleId(String title, String lang) { for (TravelArticle article : cachedArticles.values()) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index d7ff7e4950..7699f1da5d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -59,7 +59,6 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv protected List> fragments = new ArrayList<>(); private LockableViewPager viewPager; - private boolean updateNeeded; @Override public void onCreate(Bundle savedInstanceState) { @@ -319,16 +318,13 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv updateFragments(); } - private void updateFragments() { + public void updateFragments() { ExploreTabFragment exploreTabFragment = getExploreTabFragment(); SavedArticlesTabFragment savedArticlesTabFragment = getSavedArticlesTabFragment(); if (exploreTabFragment != null && savedArticlesTabFragment != null && exploreTabFragment.isAdded() && savedArticlesTabFragment.isAdded()) { exploreTabFragment.populateData(); savedArticlesTabFragment.savedArticlesUpdated(); - updateNeeded = false; - } else { - updateNeeded = true; } } @@ -353,16 +349,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } public void onTabFragmentResume(Fragment fragment) { - if (updateNeeded) { updateFragments(); - } - } - - public void updateSavedArticles() { - SavedArticlesTabFragment fragment = getSavedArticlesTabFragment(); - if(fragment!=null){ - fragment.savedArticlesUpdated(); - } } private static class LoadWikivoyageData extends AsyncTask { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java index 3812d239df..b9c5dbeb11 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java @@ -6,7 +6,6 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; @@ -23,7 +22,6 @@ import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; -import net.osmand.plus.wikivoyage.explore.SavedArticlesTabFragment; public class ArticleTravelCard extends BaseTravelCard { @@ -108,7 +106,6 @@ public class ArticleTravelCard extends BaseTravelCard { app.getTravelHelper().createGpxFile(article); helper.addArticleToSaved(article); } - updateSavedArticles(); updateSaveButton(holder); } } @@ -116,14 +113,6 @@ public class ArticleTravelCard extends BaseTravelCard { } } - void updateSavedArticles() { - for (Fragment fragment : fragmentManager.getFragments()) { - if (fragment instanceof SavedArticlesTabFragment) { - ((SavedArticlesTabFragment) fragment).savedArticlesUpdated(); - } - } - } - public static class ArticleTravelVH extends RecyclerView.ViewHolder { final TextView title; From 8631ddc2c0afa44c055b4f294c76552c96b020b2 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 17 Dec 2020 17:53:39 +0200 Subject: [PATCH 41/76] Fix check for NaN --- .../plus/settings/backend/backup/AvoidRoadsSettingsItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java index 0f88f0e961..a65a60b2d7 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java @@ -154,7 +154,7 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem Date: Thu, 17 Dec 2020 18:14:54 +0200 Subject: [PATCH 42/76] Refactoring --- .../WikivoyageArticleDialogFragment.java | 24 +------------------ .../explore/WikivoyageExploreActivity.java | 13 ++++++++-- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 2d834c444f..784c1ee8d4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.wikivoyage.article; import android.annotation.SuppressLint; -import android.app.Activity; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; @@ -44,7 +43,6 @@ import net.osmand.plus.wikivoyage.WikivoyageWebViewClient; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; -import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity; import net.osmand.util.Algorithms; import java.io.File; @@ -55,7 +53,7 @@ import java.util.Map; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; -public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment implements TravelLocalDataHelper.Listener { +public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -212,7 +210,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme @Override public void onPause() { super.onPause(); - getMyApplication().getTravelHelper().getBookmarksHelper().removeListener(this); if (webViewClient != null) { webViewClient.stopRunningAsyncTasks(); } @@ -221,7 +218,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme @Override public void onResume() { super.onResume(); - getMyApplication().getTravelHelper().getBookmarksHelper().addListener(this); OsmandSettings settings = getMyApplication().getSettings(); if (!settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.get()) { FragmentActivity activity = getActivity(); @@ -411,24 +407,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } } - @Override - public void savedArticlesUpdated() { - WikivoyageExploreActivity activity = getExploreActivity(); - if (activity != null) { - activity.updateFragments(); - } - } - - @Nullable - private WikivoyageExploreActivity getExploreActivity() { - Activity activity = getActivity(); - if (activity instanceof WikivoyageExploreActivity) { - return (WikivoyageExploreActivity) activity; - } else { - return null; - } - } - private class WikivoyageArticleWebAppInterface { @JavascriptInterface diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 7699f1da5d..45047e2e1c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -38,6 +38,7 @@ import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelHelper; +import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment; import net.osmand.util.Algorithms; @@ -45,7 +46,8 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -public class WikivoyageExploreActivity extends TabActivity implements DownloadEvents, OnDialogFragmentResultListener { +public class WikivoyageExploreActivity extends TabActivity implements DownloadEvents, OnDialogFragmentResultListener, + TravelLocalDataHelper.Listener { private static final String TAB_SELECTED = "tab_selected"; private static final String ROUTE_ID_KEY = "route_id_key"; @@ -189,6 +191,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv setIntent(null); } getMyApplication().getDownloadThread().setUiActivity(this); + app.getTravelHelper().getBookmarksHelper().addListener(this); } protected void parseLaunchIntentLink(Uri data) { @@ -210,6 +213,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv protected void onPause() { super.onPause(); getMyApplication().getDownloadThread().resetUiActivity(this); + app.getTravelHelper().getBookmarksHelper().removeListener(this); } @Nullable @@ -349,7 +353,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } public void onTabFragmentResume(Fragment fragment) { - updateFragments(); + updateFragments(); + } + + @Override + public void savedArticlesUpdated() { + updateFragments(); } private static class LoadWikivoyageData extends AsyncTask { From 9ac96bfb86cb7390ec442696bf15ec1fd8ea7b0d Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 17 Dec 2020 18:57:48 +0200 Subject: [PATCH 43/76] Refactor --- OsmAnd/res/values/strings.xml | 2 +- .../plus/helpers/WaypointDialogHelper.java | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index eecb00ee9a..4647ed8506 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,7 +11,7 @@ Thx - Hardy --> - Reverse all points + Reverse all points • Added option to export and import all data including settings, resources, my places\n\n • Plan Route: graphs for track segments with route, and added the ability to create and edit multiple track segments\n\n diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 24d684a408..8fbfcb45fc 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -265,8 +265,8 @@ public class WaypointDialogHelper { } } - public static void switchAllPoint(final OsmandApplication app, final Activity ctx, - final WaypointDialogHelper helper) { + public static void reverseAllPoints(OsmandApplication app, Activity ctx, + WaypointDialogHelper helper) { TargetPointsHelper targets = app.getTargetPointsHelper(); List points = targets.getAllPoints(); Collections.reverse(points); @@ -457,7 +457,8 @@ public class WaypointDialogHelper { @Override public void createMenuItems(Bundle savedInstanceState) { items.add(new TitleItem(getString(R.string.shared_string_options))); - + final OsmandApplication app = requiredMyApplication(); + final TargetPointsHelper targetsHelper = app.getTargetPointsHelper(); BaseBottomSheetItem sortDoorToDoorItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_sort_door_to_door)) .setTitle(getString(R.string.intermediate_items_sort_by_distance)) @@ -507,15 +508,15 @@ public class WaypointDialogHelper { BaseBottomSheetItem reorderAllItems = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)) - .setTitle(getString(R.string.switch_all_points)) + .setTitle(getString(R.string.reverce_all_points)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - WaypointDialogHelper.switchAllPoint( - mapActivity.getMyApplication(), + WaypointDialogHelper.reverseAllPoints( + app, mapActivity, mapActivity.getDashboard().getWaypointDialogHelper() ); @@ -524,11 +525,9 @@ public class WaypointDialogHelper { } }) .create(); - if (getMyApplication() != null) { - int intermediateSize = getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(); - if (intermediateSize > 2) { - items.add(reorderAllItems); - } + int intermediateSize = targetsHelper.getIntermediatePoints().size(); + if (intermediateSize > 2 && !targetsHelper.getAllPoints().isEmpty()) { + items.add(reorderAllItems); } items.add(new DividerHalfItem(getContext())); From 0f69a1c0481d6922165d64bb68a01ee147f87365 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 17 Dec 2020 19:15:27 +0200 Subject: [PATCH 44/76] Typo fix, additional fix --- OsmAnd/res/values/strings.xml | 2 +- .../plus/helpers/WaypointDialogHelper.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 4647ed8506..b1df50c808 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,7 +11,7 @@ Thx - Hardy --> - Reverse all points + Reverse all points • Added option to export and import all data including settings, resources, my places\n\n • Plan Route: graphs for track segments with route, and added the ability to create and edit multiple track segments\n\n diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 8fbfcb45fc..8d0d8210c1 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -268,13 +268,15 @@ public class WaypointDialogHelper { public static void reverseAllPoints(OsmandApplication app, Activity ctx, WaypointDialogHelper helper) { TargetPointsHelper targets = app.getTargetPointsHelper(); - List points = targets.getAllPoints(); - Collections.reverse(points); - TargetPoint start = points.get(0); - targets.setStartPoint(start.point, false, start.getOriginalPointDescription()); - points.remove(start); - targets.reorderAllTargetPoints(points, true); - updateControls(ctx, helper); + if (!targets.getAllPoints().isEmpty()) { + List points = targets.getAllPoints(); + Collections.reverse(points); + TargetPoint start = points.get(0); + targets.setStartPoint(start.point, false, start.getOriginalPointDescription()); + points.remove(start); + targets.reorderAllTargetPoints(points, true); + updateControls(ctx, helper); + } } public static void updateControls(Activity ctx, WaypointDialogHelper helper) { @@ -508,7 +510,7 @@ public class WaypointDialogHelper { BaseBottomSheetItem reorderAllItems = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)) - .setTitle(getString(R.string.reverce_all_points)) + .setTitle(getString(R.string.reverse_all_points)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @Override @@ -526,7 +528,7 @@ public class WaypointDialogHelper { }) .create(); int intermediateSize = targetsHelper.getIntermediatePoints().size(); - if (intermediateSize > 2 && !targetsHelper.getAllPoints().isEmpty()) { + if (intermediateSize > 2) { items.add(reorderAllItems); } From 87312b955d3fccb5207b45078b012843a7c5637a Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 17 Dec 2020 19:29:02 +0200 Subject: [PATCH 45/76] Fix getArticleById --- .../plus/wikivoyage/data/TravelObfHelper.java | 62 +++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 7fa838cf2a..65f45001da 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -2,8 +2,11 @@ package net.osmand.plus.wikivoyage.data; import androidx.annotation.NonNull; +import net.osmand.Collator; +import net.osmand.CollatorStringMatcher; import net.osmand.GPXUtilities; import net.osmand.IndexConstants; +import net.osmand.OsmAndCollator; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; @@ -24,6 +27,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static net.osmand.CollatorStringMatcher.StringMatcherMode.*; +import static net.osmand.binary.BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER; + public class TravelObfHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); @@ -71,7 +77,7 @@ public class TravelObfHelper implements TravelHelper { final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest(location, SEARCH_RADIUS, -1, - BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER, + ACCEPT_ALL_POI_TYPE_FILTER, new ResultMatcher() { @Override public boolean publish(Amenity amenity) { @@ -150,7 +156,8 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override public List search(String searchQuery) { - return null; + List res = new ArrayList<>(); + return res; } @NonNull @@ -166,7 +173,51 @@ public class TravelObfHelper implements TravelHelper { @Override public TravelArticle getArticleById(String routeId, String lang) { - return cachedArticles.get(routeId); + TravelArticle article = cachedArticles.get(routeId); + if (article != null) { + return article; + } else { + return getArticleByIdFromTravelBooks(routeId, lang); + } + } + + public TravelArticle getArticleByIdFromTravelBooks(final String routeId, final String lang) { + TravelArticle article = null; + final List amenities = new ArrayList<>(); + for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { + try { + int left = 0; + int right = Integer.MAX_VALUE; + int top = 0; + int bottom = Integer.MAX_VALUE; + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + left, right, top, bottom, -1, ACCEPT_ALL_POI_TYPE_FILTER, + new ResultMatcher() { + @Override + public boolean publish(Amenity amenity) { + if (amenity.getSubType().equals(ROUTE_ARTICLE) + && getRouteId(amenity).equals(routeId)) { + amenities.add(amenity); + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + + travelBookReader.searchPoiByName(req); + } catch (IOException e) { + LOG.error(e.getMessage()); + } + if (!amenities.isEmpty()) { + article = readArticle(amenities.get(0), lang); + cachedArticles.put(article.routeId, article); + } + } + return article; } @Override @@ -184,8 +235,9 @@ public class TravelObfHelper implements TravelHelper { new ResultMatcher() { @Override public boolean publish(Amenity amenity) { - if (title.equalsIgnoreCase(amenity.getName(lang)) - && amenity.getSubType().equals(ROUTE_ARTICLE)) { + Collator collator = OsmAndCollator.primaryCollator(); + if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), + CHECK_EQUALS_FROM_SPACE) && amenity.getSubType().equals(ROUTE_ARTICLE)) { amenities.add(amenity); } return false; From 4ca2c3183ccf883121e5f45c927ca9006ba04a58 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Fri, 18 Dec 2020 10:34:37 +0300 Subject: [PATCH 46/76] Add phrases --- OsmAnd/res/values/phrases.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index ebddd0ac33..28c17c4a5d 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4322,5 +4322,9 @@ Ranger station Weightbridge + Waste transfer station + + Lavoir + From 3a3f7ea81854dee1506376fff8200c8cf3222ab4 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Thu, 17 Dec 2020 16:27:02 +0000 Subject: [PATCH 47/76] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3875 of 3875 strings) --- OsmAnd/res/values-uk/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-uk/phrases.xml b/OsmAnd/res/values-uk/phrases.xml index 2454d78d33..dde958ae61 100644 --- a/OsmAnd/res/values-uk/phrases.xml +++ b/OsmAnd/res/values-uk/phrases.xml @@ -3882,4 +3882,6 @@ Резервуар для води Озеро Річка + Лісництво + Автомобільні ваги \ No newline at end of file From 40368fa8662274059e6851b865b3326c128e5fbf Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Thu, 17 Dec 2020 16:34:53 +0000 Subject: [PATCH 48/76] Translated using Weblate (Sardinian) Currently translated at 99.6% (3863 of 3875 strings) --- OsmAnd/res/values-sc/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sc/phrases.xml b/OsmAnd/res/values-sc/phrases.xml index 0aeaf1f00b..b04d3277e7 100644 --- a/OsmAnd/res/values-sc/phrases.xml +++ b/OsmAnd/res/values-sc/phrases.xml @@ -3890,4 +3890,6 @@ Isceta Òperas idràulicas Putzu a tubu + Bilàntzia a ponte + Istatzione de sos rangers \ No newline at end of file From 044155769877b6d40db2abf981bae6905ba7d957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20J=C3=B5er=C3=BC=C3=BCt?= Date: Thu, 17 Dec 2020 20:22:33 +0000 Subject: [PATCH 49/76] Translated using Weblate (Estonian) Currently translated at 99.4% (3854 of 3875 strings) --- OsmAnd/res/values-et/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-et/phrases.xml b/OsmAnd/res/values-et/phrases.xml index c2229acf50..8ef9bbe198 100644 --- a/OsmAnd/res/values-et/phrases.xml +++ b/OsmAnd/res/values-et/phrases.xml @@ -3854,4 +3854,7 @@ Kaev Jõgi Järv + Mobiiliraha müügikoht + Pargivahi maja + Autokaal \ No newline at end of file From b1aae45b0dcd43833d3e72f3cae87a3cac4ac149 Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 17 Dec 2020 14:31:02 +0000 Subject: [PATCH 50/76] Translated using Weblate (Spanish (Argentina)) Currently translated at 100.0% (3875 of 3875 strings) --- OsmAnd/res/values-es-rAR/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/phrases.xml b/OsmAnd/res/values-es-rAR/phrases.xml index eeb3cd5c9d..0bcfde319f 100644 --- a/OsmAnd/res/values-es-rAR/phrases.xml +++ b/OsmAnd/res/values-es-rAR/phrases.xml @@ -3901,4 +3901,6 @@ Canilla Planta potabilizadora Pozo entubado + Báscula puente + Estación de guardabosques \ No newline at end of file From a79c185e7ebd0d3fe707cdf23370bdadc1f269cc Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Thu, 17 Dec 2020 13:55:26 +0000 Subject: [PATCH 51/76] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3875 of 3875 strings) --- OsmAnd/res/values-pt-rBR/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/phrases.xml b/OsmAnd/res/values-pt-rBR/phrases.xml index 466eae1657..c74187b593 100644 --- a/OsmAnd/res/values-pt-rBR/phrases.xml +++ b/OsmAnd/res/values-pt-rBR/phrases.xml @@ -3894,4 +3894,6 @@ Toque Estação de tratamento de água Bem embalado + Balança + Posto de guarda florestal \ No newline at end of file From 601aae3ec1eb1bb7d68fabbd2f24ad3e165b91d4 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Thu, 17 Dec 2020 13:51:45 +0000 Subject: [PATCH 52/76] Translated using Weblate (Hebrew) Currently translated at 56.4% (2187 of 3875 strings) --- OsmAnd/res/values-iw/phrases.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd/res/values-iw/phrases.xml b/OsmAnd/res/values-iw/phrases.xml index d23f018e7c..757da8abcc 100644 --- a/OsmAnd/res/values-iw/phrases.xml +++ b/OsmAnd/res/values-iw/phrases.xml @@ -2174,4 +2174,20 @@ לוח זמנים כוורת דבורים חנות אגוזים + תת־קרקעי + רחוב + חנייה + נתיב + ירוק + מדרכה + קיבולת זרימה של ברז כיבוי + שירותים לאזרח + ויזות למהגרים + קונסוליה + שגרירות + לוח זמנים + מילוי מי שתייה + חץ + רטט + לחץ \ No newline at end of file From 73bfac85484fb414ab23dcbe53669bdf2e0cc656 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Thu, 17 Dec 2020 22:49:25 +0000 Subject: [PATCH 53/76] Translated using Weblate (Esperanto) Currently translated at 100.0% (3875 of 3875 strings) --- OsmAnd/res/values-eo/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-eo/phrases.xml b/OsmAnd/res/values-eo/phrases.xml index f3ba290f90..7949fb2046 100644 --- a/OsmAnd/res/values-eo/phrases.xml +++ b/OsmAnd/res/values-eo/phrases.xml @@ -3887,4 +3887,6 @@ krano akvokondukilo puto tuba (abisena) + Pezilo por aŭtomobiloj + Oficejo de naturrezervejo \ No newline at end of file From 3e1b212fac2a1b9658e6c71d2ded54325da435d0 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Fri, 18 Dec 2020 02:13:08 +0000 Subject: [PATCH 54/76] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3875 of 3875 strings) --- OsmAnd/res/values-zh-rTW/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/phrases.xml b/OsmAnd/res/values-zh-rTW/phrases.xml index 3a13797bd1..ca44b815e7 100644 --- a/OsmAnd/res/values-zh-rTW/phrases.xml +++ b/OsmAnd/res/values-zh-rTW/phrases.xml @@ -3893,4 +3893,6 @@ 點擊 自來水廠 管井 + 地磅 + 護林員站 \ No newline at end of file From d7a12127053c04a89803766679499ceeeadf9bb7 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 18 Dec 2020 13:01:49 +0200 Subject: [PATCH 55/76] Add RouteArticleFilter --- .../plus/wikivoyage/data/TravelObfHelper.java | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 65f45001da..c760baa04b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -12,6 +12,7 @@ import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.LatLon; +import net.osmand.osm.PoiCategory; import net.osmand.plus.OsmandApplication; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -28,7 +29,6 @@ import java.util.List; import java.util.Map; import static net.osmand.CollatorStringMatcher.StringMatcherMode.*; -import static net.osmand.binary.BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER; public class TravelObfHelper implements TravelHelper { @@ -67,33 +67,13 @@ public class TravelObfHelper implements TravelHelper { public List loadPopularArticles() { String language = app.getLanguage(); popularArticles.clear(); - final List amenities = new ArrayList<>(); + List amenities; for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - if (travelBookReader == null) { - popularArticles = new ArrayList<>(); - return popularArticles; - } final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); - BinaryMapIndexReader.SearchRequest req = - BinaryMapIndexReader.buildSearchPoiRequest(location, SEARCH_RADIUS, -1, - ACCEPT_ALL_POI_TYPE_FILTER, - new ResultMatcher() { - @Override - public boolean publish(Amenity amenity) { - if (amenity.getSubType().equals(ROUTE_ARTICLE)) { - amenities.add(amenity); - } - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - }); - travelBookReader.searchPoi(req); - + BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( + location, SEARCH_RADIUS, -1, getSearchRouteArticleFilter(), null); + amenities = travelBookReader.searchPoi(req); if (amenities.size() > 0) { for (Amenity a : amenities) { if (!Algorithms.isEmpty(a.getName(language))) { @@ -116,7 +96,6 @@ public class TravelObfHelper implements TravelHelper { } }); } - } catch (Exception e) { LOG.error(e.getMessage()); } @@ -124,6 +103,20 @@ public class TravelObfHelper implements TravelHelper { return popularArticles; } + BinaryMapIndexReader.SearchPoiTypeFilter getSearchRouteArticleFilter() { + return new BinaryMapIndexReader.SearchPoiTypeFilter() { + @Override + public boolean accept(PoiCategory type, String subcategory) { + return subcategory.equals(ROUTE_ARTICLE); + } + + @Override + public boolean isEmpty() { + return false; + } + }; + } + private TravelArticle readArticle(Amenity amenity, String lang) { TravelArticle res = new TravelArticle(); res.title = Algorithms.isEmpty(amenity.getName(lang)) ? amenity.getName() : amenity.getName(lang); @@ -191,12 +184,11 @@ public class TravelObfHelper implements TravelHelper { int top = 0; int bottom = Integer.MAX_VALUE; BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - left, right, top, bottom, -1, ACCEPT_ALL_POI_TYPE_FILTER, + left, right, top, bottom, -1, getSearchRouteArticleFilter(), new ResultMatcher() { @Override public boolean publish(Amenity amenity) { - if (amenity.getSubType().equals(ROUTE_ARTICLE) - && getRouteId(amenity).equals(routeId)) { + if (getRouteId(amenity).equals(routeId)) { amenities.add(amenity); } return false; @@ -208,7 +200,7 @@ public class TravelObfHelper implements TravelHelper { } }); - travelBookReader.searchPoiByName(req); + travelBookReader.searchPoi(req); } catch (IOException e) { LOG.error(e.getMessage()); } From 1cd07abf929ee818ec7df5a47f9657cc9f1d8b9a Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 14:31:44 +0300 Subject: [PATCH 56/76] Remove poi along road from plan route settings --- .../plus/routepreparationmenu/RouteOptionsBottomSheet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index 461f947592..8daf44e8e8 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -101,7 +101,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { DIRECTIONS(), PLAN_ROUTE(MuteSoundRoutingParameter.class, RouteSimulationItem.class, - GpxLocalRoutingParameter.class); + GpxLocalRoutingParameter.class, + ShowAlongTheRouteItem.class); private final Class[] excludeParameters; From bbd7678425c995eb921135ff9082390b9107bfb4 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 14:43:44 +0300 Subject: [PATCH 57/76] Small fixes TravelObfHelper --- .../osmand/binary/BinaryMapIndexReader.java | 5 +++ .../plus/wikivoyage/data/TravelObfHelper.java | 34 ++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java index 035b33d470..f0b26d09e8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java @@ -1568,6 +1568,10 @@ public class BinaryMapIndexReader { } public static SearchRequest buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, ResultMatcher resultMatcher, ResultMatcher rawDataCollector) { + return buildSearchPoiRequest(x, y, nameFilter, sleft, sright, stop, sbottom, null, resultMatcher, null); + } + + public static SearchRequest buildSearchPoiRequest(int x, int y, String nameFilter, int sleft, int sright, int stop, int sbottom, SearchPoiTypeFilter poiTypeFilter, ResultMatcher resultMatcher, ResultMatcher rawDataCollector) { SearchRequest request = new SearchRequest(); request.x = x; request.y = y; @@ -1575,6 +1579,7 @@ public class BinaryMapIndexReader { request.right = sright; request.top = stop; request.bottom = sbottom; + request.poiTypeFilter = poiTypeFilter; request.resultMatcher = resultMatcher; request.rawDataCollector = rawDataCollector; request.nameQuery = nameFilter.trim(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index c760baa04b..bb1a86fcb4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -126,7 +126,7 @@ public class TravelObfHelper implements TravelHelper { res.lon = amenity.getLocation().getLongitude(); res.imageTitle = emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, lang)); res.routeId = getRouteId(amenity); - res.originalId = 0; //? + res.originalId = 0; res.lang = lang; res.contentsJson = emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); res.aggregatedPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); @@ -149,8 +149,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override public List search(String searchQuery) { - List res = new ArrayList<>(); - return res; + return Collections.emptyList(); } @NonNull @@ -179,24 +178,23 @@ public class TravelObfHelper implements TravelHelper { final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - int left = 0; - int right = Integer.MAX_VALUE; - int top = 0; - int bottom = Integer.MAX_VALUE; BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - left, right, top, bottom, -1, getSearchRouteArticleFilter(), + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, -1, getSearchRouteArticleFilter(), new ResultMatcher() { + boolean done = false; + @Override public boolean publish(Amenity amenity) { if (getRouteId(amenity).equals(routeId)) { amenities.add(amenity); + done = true; } return false; } @Override public boolean isCancelled() { - return false; + return done; } }); @@ -218,28 +216,26 @@ public class TravelObfHelper implements TravelHelper { final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { - int left = 0; - int right = Integer.MAX_VALUE; - int top = 0; - int bottom = Integer.MAX_VALUE; BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - 0, 0, title, left, right, top, bottom, + 0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), new ResultMatcher() { + boolean done = false; + final Collator collator = OsmAndCollator.primaryCollator(); + @Override public boolean publish(Amenity amenity) { - Collator collator = OsmAndCollator.primaryCollator(); - if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), - CHECK_EQUALS_FROM_SPACE) && amenity.getSubType().equals(ROUTE_ARTICLE)) { + if (CollatorStringMatcher.cmatches(collator, title, amenity.getName(lang), CHECK_EQUALS_FROM_SPACE)) { amenities.add(amenity); + done = true; } return false; } @Override public boolean isCancelled() { - return false; + return done; } - }); + }, null); travelBookReader.searchPoiByName(req); } catch (IOException e) { From d4c4ed3181ae236f05c5e0f7380cfbe8c2b16b28 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 17:23:39 +0300 Subject: [PATCH 58/76] Fix travel helpers --- .../plus/wikivoyage/data/TravelDbHelper.java | 36 +++++++++---- .../plus/wikivoyage/data/TravelHelper.java | 23 ++++---- .../plus/wikivoyage/data/TravelObfHelper.java | 52 ++++++++++++------- 3 files changed, 73 insertions(+), 38 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 378f0a6a70..9ec54b2e06 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -105,7 +105,7 @@ public class TravelDbHelper implements TravelHelper { private File selectedTravelBook = null; private List existingTravelBooks = new ArrayList<>(); - private List popularArticles = new ArrayList(); + private List popularArticles = new ArrayList<>(); public TravelDbHelper(OsmandApplication application) { @@ -126,6 +126,7 @@ public class TravelDbHelper implements TravelHelper { return false; } + @Override public TravelLocalDataHelper getBookmarksHelper() { return localDataHelper; } @@ -135,6 +136,7 @@ public class TravelDbHelper implements TravelHelper { return selectedTravelBook != null; } + @Override public void initializeDataOnAppStartup() { List files = getPossibleFiles(); String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get(); @@ -168,12 +170,14 @@ public class TravelDbHelper implements TravelHelper { return null; } + @Override public void initializeDataToDisplay() { localDataHelper.refreshCachedData(); loadPopularArticles(); } + @Override public String getSelectedTravelBookName() { if (selectedTravelBook != null) { return selectedTravelBook.getName(); @@ -210,8 +214,9 @@ public class TravelDbHelper implements TravelHelper { } } + @Override @NonNull - public List search(final String searchQuery) { + public List search(@NonNull String searchQuery) { List res = new ArrayList<>(); SQLiteConnection conn = openConnection(); String[] queries = searchQuery.replace('_', ' ').replace('/', ' ').split(" "); @@ -260,6 +265,7 @@ public class TravelDbHelper implements TravelHelper { return list; } + @Override @NonNull public List getPopularArticles() { return popularArticles; @@ -270,7 +276,7 @@ public class TravelDbHelper implements TravelHelper { String language = application.getLanguage(); SQLiteConnection conn = openConnection(); if (conn == null) { - popularArticles = new ArrayList(); + popularArticles = new ArrayList<>(); return popularArticles; } String LANG_WHERE = " WHERE " + ARTICLES_COL_LANG + " = '" + language + "'"; @@ -444,8 +450,9 @@ public class TravelDbHelper implements TravelHelper { } @NonNull + @Override public LinkedHashMap> getNavigationMap( - final TravelArticle article) { + @NonNull final TravelArticle article) { String lang = article.getLang(); String title = article.getTitle(); if (TextUtils.isEmpty(lang) || TextUtils.isEmpty(title)) { @@ -533,8 +540,9 @@ public class TravelDbHelper implements TravelHelper { return res; } + @Override @Nullable - public TravelArticle getArticleById(String routeId, String lang) { + public TravelArticle getArticleById(@NonNull String routeId, @NonNull String lang) { TravelArticle res = null; SQLiteConnection conn = openConnection(); if (conn != null && !Algorithms.isEmpty(routeId)) { @@ -550,8 +558,9 @@ public class TravelDbHelper implements TravelHelper { return res; } + @Override @Nullable - public TravelArticle getArticleByTitle(String title, String lang) { + public TravelArticle getArticleByTitle(@NonNull String title, @NonNull String lang) { TravelArticle res = null; SQLiteConnection conn = openConnection(); if (conn != null) { @@ -567,7 +576,9 @@ public class TravelDbHelper implements TravelHelper { return res; } - public String getArticleId(String title, String lang) { + @NonNull + @Override + public String getArticleId(@NonNull String title, @NonNull String lang) { String res = ""; SQLiteConnection conn = openConnection(); if (conn != null) { @@ -585,7 +596,8 @@ public class TravelDbHelper implements TravelHelper { } @NonNull - public ArrayList getArticleLangs(String routeId) { + @Override + public ArrayList getArticleLangs(@NonNull String routeId) { ArrayList res = new ArrayList<>(); SQLiteConnection conn = openConnection(); if (conn != null) { @@ -652,12 +664,16 @@ public class TravelDbHelper implements TravelHelper { return nm.substring(0, nm.indexOf('.')).replace('_', ' '); } - public String getGPXName(TravelArticle article) { + @NonNull + @Override + public String getGPXName(@NonNull final TravelArticle article) { return article.getTitle().replace('/', '_').replace('\'', '_') .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; } - public File createGpxFile(TravelArticle article) { + @NonNull + @Override + public File createGpxFile(@NonNull final TravelArticle article) { final GPXFile gpx = article.getGpxFile(); File file = application.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); if (!file.exists()) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 6ff6cf914b..b55c398817 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -19,26 +19,31 @@ public interface TravelHelper { boolean isAnyTravelBookPresent(); @NonNull - List search(final String searchQuery); + List search(@NonNull String searchQuery); @NonNull List getPopularArticles(); - Map> getNavigationMap( - final TravelArticle article); + @NonNull + Map> getNavigationMap(@NonNull final TravelArticle article); @Nullable - TravelArticle getArticleById(String routeId, String lang); + TravelArticle getArticleById(@NonNull String routeId, @NonNull String lang); - TravelArticle getArticleByTitle(String title, String lang); + @Nullable + TravelArticle getArticleByTitle(@NonNull String title, @NonNull String lang); - String getArticleId(String title, String lang); + @NonNull + String getArticleId(@NonNull String title, @NonNull String lang); - ArrayList getArticleLangs(String routeId); + @NonNull + ArrayList getArticleLangs(@NonNull String routeId); - String getGPXName(TravelArticle article); + @NonNull + String getGPXName(@NonNull final TravelArticle article); - File createGpxFile(TravelArticle article); + @NonNull + File createGpxFile(@NonNull final TravelArticle article); // TODO: this method should be deleted once TravelDBHelper is deleted // For TravelOBFHelper it could always return "" and should be no problem diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index bb1a86fcb4..013be1e6d4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -1,15 +1,18 @@ package net.osmand.plus.wikivoyage.data; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.osmand.Collator; import net.osmand.CollatorStringMatcher; import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.OsmAndCollator; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; +import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter; import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.osm.PoiCategory; @@ -66,7 +69,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull public List loadPopularArticles() { String language = app.getLanguage(); - popularArticles.clear(); + List popularArticles = new ArrayList<>(); List amenities; for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { @@ -100,11 +103,12 @@ public class TravelObfHelper implements TravelHelper { LOG.error(e.getMessage()); } } + this.popularArticles = popularArticles; return popularArticles; } - BinaryMapIndexReader.SearchPoiTypeFilter getSearchRouteArticleFilter() { - return new BinaryMapIndexReader.SearchPoiTypeFilter() { + SearchPoiTypeFilter getSearchRouteArticleFilter() { + return new SearchPoiTypeFilter() { @Override public boolean accept(PoiCategory type, String subcategory) { return subcategory.equals(ROUTE_ARTICLE); @@ -148,7 +152,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override - public List search(String searchQuery) { + public List search(@NonNull String searchQuery) { return Collections.emptyList(); } @@ -158,13 +162,14 @@ public class TravelObfHelper implements TravelHelper { return popularArticles; } + @NonNull @Override - public Map> getNavigationMap(TravelArticle article) { - return null; + public Map> getNavigationMap(@NonNull final TravelArticle article) { + return Collections.emptyMap(); } @Override - public TravelArticle getArticleById(String routeId, String lang) { + public TravelArticle getArticleById(@NonNull String routeId, @NonNull String lang) { TravelArticle article = cachedArticles.get(routeId); if (article != null) { return article; @@ -173,7 +178,7 @@ public class TravelObfHelper implements TravelHelper { } } - public TravelArticle getArticleByIdFromTravelBooks(final String routeId, final String lang) { + private TravelArticle getArticleByIdFromTravelBooks(final String routeId, final String lang) { TravelArticle article = null; final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { @@ -210,8 +215,9 @@ public class TravelObfHelper implements TravelHelper { return article; } + @Nullable @Override - public TravelArticle getArticleByTitle(final String title, final String lang) { + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang) { TravelArticle article = null; final List amenities = new ArrayList<>(); for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { @@ -257,22 +263,28 @@ public class TravelObfHelper implements TravelHelper { } } + @NonNull @Override - public String getArticleId(String title, String lang) { + public String getArticleId(@NonNull String title, @NonNull String lang) { + TravelArticle a = null; for (TravelArticle article : cachedArticles.values()) { if (article.getTitle().equals(title)) { - return article.getRouteId(); + a = article; + break; } } - TravelArticle article = getArticleByTitle(title, lang); - if (article != null) { - return article.getRouteId(); + if (a == null) { + TravelArticle article = getArticleByTitle(title, lang); + if (article != null) { + a = article; + } } - return null; + return a != null && a.getRouteId() != null ? a.getRouteId() : ""; } + @NonNull @Override - public ArrayList getArticleLangs(String routeId) { + public ArrayList getArticleLangs(@NonNull String routeId) { ArrayList res = new ArrayList<>(); res.add("en"); for (TravelArticle article : popularArticles) { @@ -283,15 +295,17 @@ public class TravelObfHelper implements TravelHelper { return res; } + @NonNull @Override - public String getGPXName(TravelArticle article) { + public String getGPXName(@NonNull final TravelArticle article) { return article.getTitle().replace('/', '_').replace('\'', '_') .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; } + @NonNull @Override - public File createGpxFile(TravelArticle article) { - final GPXUtilities.GPXFile gpx = article.getGpxFile(); + public File createGpxFile(@NonNull final TravelArticle article) { + final GPXFile gpx = article.getGpxFile(); File file = app.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); if (!file.exists()) { GPXUtilities.writeGpxFile(file, gpx); From 8899dda3fbecff40f1743e297aba30aeb8ff3a81 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Fri, 18 Dec 2020 11:49:09 +0000 Subject: [PATCH 59/76] Translated using Weblate (French) Currently translated at 99.8% (3578 of 3582 strings) --- OsmAnd/res/values-fr/strings.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index cc4f1eb7f8..aa448607ce 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3813,7 +3813,7 @@ Seuil de distance Profil de navigation Photos des rues - Voulez-vous vraiment fermer l\'itinéraire planifié sans enregistrer \? (vous perdrez vos modifications) + Souhaitez-vous vraiment ignorer toutes les modifications apportées à l\'itinéraire planifié \? Si inversion du sens Point de la trace vers lequel naviguer Enregistrer le parcours @@ -3995,4 +3995,7 @@ Ajouter un nouveau segment « Identifiable » siginifie que la trace sera affichée publiquement dans « Mes traces GPS » ainsi que dans les listes de traces GPS publiques. Ainsi les autres utilisateurs peuvent télécharger la trace brute et l\'associer avec votre nom d\'utilisateur. Les données de points de passage horodatés fournis par l\'API GPS publique feront référence à la page d\'origine de votre trace. « Public » signifie que la trace est affichée publiquement dans vos traces GPS et dans les listes de traces GPS publiques. Les données diffusées via l\'API ne font pas référence à votre page de traces. Les horodatages des points de trace ne sont pas disponibles via l\'API GPS publique et les points de trace ne sont pas classés par ordre chronologique. + Profil OsmAnd + Profil utilisateur + Inverser tous les points \ No newline at end of file From d114664ffb8fdef41da866e250641d4c45988ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Fri, 18 Dec 2020 12:41:14 +0000 Subject: [PATCH 60/76] Translated using Weblate (Turkish) Currently translated at 100.0% (3582 of 3582 strings) --- OsmAnd/res/values-tr/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index b018a39601..4be2bd1df1 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -3973,4 +3973,5 @@ \n OsmAnd profili Kullanıcı profili + Tüm noktaları tersine çevir \ No newline at end of file From 3aba88a8580b4a1f4bd1b2274a958d2d71106e05 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Fri, 18 Dec 2020 13:16:04 +0000 Subject: [PATCH 61/76] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3582 of 3582 strings) --- OsmAnd/res/values-uk/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 9be3ea3de0..0ea2ee3374 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4014,4 +4014,5 @@ \n Профіль OsmAnd Профіль користувача + Повернути назад всі точки \ No newline at end of file From 29a93c128ec26e13d353ee1e558682f32e39ea2e Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Fri, 18 Dec 2020 12:30:09 +0000 Subject: [PATCH 62/76] Translated using Weblate (Hebrew) Currently translated at 99.7% (3572 of 3582 strings) --- OsmAnd/res/values-iw/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index fdcadfd9f0..66d06edf99 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -4018,4 +4018,7 @@ \n • תמיכה בצבעים מותאמים אישית למועדפים ולנקודות דרך במסלול \n \n + פרופיל + פרופיל + להפוך את כל \ No newline at end of file From 597889ed2744bc633267be0989e191c35fc94fd8 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Fri, 18 Dec 2020 13:15:31 +0000 Subject: [PATCH 63/76] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3877 of 3877 strings) --- OsmAnd/res/values-uk/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-uk/phrases.xml b/OsmAnd/res/values-uk/phrases.xml index dde958ae61..6991f87786 100644 --- a/OsmAnd/res/values-uk/phrases.xml +++ b/OsmAnd/res/values-uk/phrases.xml @@ -3884,4 +3884,6 @@ Річка Лісництво Автомобільні ваги + Громадська пральня + Станція перевезення відходів \ No newline at end of file From 89eee2c653df51f9cf7bfbcb3d3f0a9d30568e9e Mon Sep 17 00:00:00 2001 From: Franco Date: Fri, 18 Dec 2020 11:37:48 +0000 Subject: [PATCH 64/76] Translated using Weblate (Spanish (Argentina)) Currently translated at 100.0% (3582 of 3582 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 4618562b7e..01a7bc425a 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -4023,4 +4023,5 @@ \n Perfil de OsmAnd Perfil de usuario + Invertir todos los puntos \ No newline at end of file From 329e78bd9d82897e0874a66319f657e82fe77441 Mon Sep 17 00:00:00 2001 From: Franco Date: Fri, 18 Dec 2020 11:41:50 +0000 Subject: [PATCH 65/76] Translated using Weblate (Spanish (Argentina)) Currently translated at 100.0% (3877 of 3877 strings) --- OsmAnd/res/values-es-rAR/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/phrases.xml b/OsmAnd/res/values-es-rAR/phrases.xml index 0bcfde319f..7aa4610509 100644 --- a/OsmAnd/res/values-es-rAR/phrases.xml +++ b/OsmAnd/res/values-es-rAR/phrases.xml @@ -3903,4 +3903,6 @@ Pozo entubado Báscula puente Estación de guardabosques + Lavadero público de ropa + Estación de transferencia de residuos \ No newline at end of file From ffd1d2dd738c0336ecc90b2838f7e33191156208 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Fri, 18 Dec 2020 09:43:19 +0000 Subject: [PATCH 66/76] Translated using Weblate (Hebrew) Currently translated at 56.4% (2187 of 3877 strings) --- OsmAnd/res/values-iw/phrases.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/OsmAnd/res/values-iw/phrases.xml b/OsmAnd/res/values-iw/phrases.xml index 757da8abcc..6ad03cdbfe 100644 --- a/OsmAnd/res/values-iw/phrases.xml +++ b/OsmAnd/res/values-iw/phrases.xml @@ -2190,4 +2190,24 @@ חץ רטט לחץ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 75c627fee2c37110dc9fe0efb622a442556ab753 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 18:21:49 +0300 Subject: [PATCH 67/76] Added search to TravelObfHelper --- .../plus/wikivoyage/data/TravelDbHelper.java | 4 +- .../plus/wikivoyage/data/TravelObfHelper.java | 77 +++++++++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 9ec54b2e06..d50d05e42b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -99,7 +99,7 @@ public class TravelDbHelper implements TravelHelper { private final OsmandApplication application; private TravelLocalDataHelper localDataHelper; - private Collator collator; + private final Collator collator; private SQLiteConnection connection = null; @@ -382,7 +382,7 @@ public class TravelDbHelper implements TravelHelper { return res; } - private void sortSearchResults(final String searchQuery, List list) { + private void sortSearchResults(@NonNull final String searchQuery, @NonNull List list) { Collections.sort(list, new Comparator() { @Override public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 013be1e6d4..c5dc28c8e3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -25,13 +25,14 @@ import org.apache.commons.logging.Log; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; -import static net.osmand.CollatorStringMatcher.StringMatcherMode.*; +import static net.osmand.CollatorStringMatcher.StringMatcherMode.CHECK_EQUALS_FROM_SPACE; public class TravelObfHelper implements TravelHelper { @@ -40,6 +41,7 @@ public class TravelObfHelper implements TravelHelper { public static final int SEARCH_RADIUS = 100000; private final OsmandApplication app; + private final Collator collator; private List popularArticles = new ArrayList<>(); private final Map cachedArticles; @@ -47,6 +49,7 @@ public class TravelObfHelper implements TravelHelper { public TravelObfHelper(OsmandApplication app) { this.app = app; + collator = OsmAndCollator.primaryCollator(); localDataHelper = new TravelLocalDataHelper(app); cachedArticles = new HashMap<>(); } @@ -70,13 +73,12 @@ public class TravelObfHelper implements TravelHelper { public List loadPopularArticles() { String language = app.getLanguage(); List popularArticles = new ArrayList<>(); - List amenities; for (BinaryMapIndexReader travelBookReader : getTravelBookReaders()) { try { final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); BinaryMapIndexReader.SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( location, SEARCH_RADIUS, -1, getSearchRouteArticleFilter(), null); - amenities = travelBookReader.searchPoi(req); + List amenities = travelBookReader.searchPoi(req); if (amenities.size() > 0) { for (Amenity a : amenities) { if (!Algorithms.isEmpty(a.getName(language))) { @@ -153,7 +155,73 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override public List search(@NonNull String searchQuery) { - return Collections.emptyList(); + List res = new ArrayList<>(); + List searchObjects = null; + for (BinaryMapIndexReader reader : app.getResourceManager().getTravelRepositories()) { + try { + BinaryMapIndexReader.SearchRequest searchRequest = BinaryMapIndexReader. + buildSearchPoiRequest(0, 0, searchQuery, + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), null, null); + + searchObjects = reader.searchPoiByName(searchRequest); + } catch (IOException e) { + LOG.error(e); + } + } + if (!Algorithms.isEmpty(searchObjects)) { + String baseLng = app.getLanguage(); + for (Amenity obj : searchObjects) { + WikivoyageSearchResult r = new WikivoyageSearchResult(); + TravelArticle article = readArticle(obj, baseLng); + r.articleTitles = new ArrayList<>(Collections.singletonList(article.title)); + r.imageTitle = article.imageTitle; + r.routeId = article.routeId; + r.isPartOf = new ArrayList<>(Collections.singletonList(article.isPartOf)); + r.langs = new ArrayList<>(Collections.singletonList(baseLng)); + res.add(r); + cachedArticles.put(article.routeId, article); + } + res = new ArrayList<>(groupSearchResultsByRouteId(res)); + sortSearchResults(res); + } + return res; + } + + private void sortSearchResults(@NonNull List list) { + Collections.sort(list, new Comparator() { + + @Override + public int compare(WikivoyageSearchResult res1, WikivoyageSearchResult res2) { + return collator.compare(res1.articleTitles.get(0), res2.articleTitles.get(0)); + } + }); + } + + @NonNull + private Collection groupSearchResultsByRouteId(@NonNull List res) { + String baseLng = app.getLanguage(); + Map wikivoyage = new HashMap<>(); + for (WikivoyageSearchResult rs : res) { + WikivoyageSearchResult prev = wikivoyage.get(rs.routeId); + if (prev != null) { + int insInd = prev.langs.size(); + if (rs.langs.get(0).equals(baseLng)) { + insInd = 0; + } else if (rs.langs.get(0).equals("en")) { + if (!prev.langs.get(0).equals(baseLng)) { + insInd = 0; + } else { + insInd = 1; + } + } + prev.articleTitles.add(insInd, rs.articleTitles.get(0)); + prev.langs.add(insInd, rs.langs.get(0)); + prev.isPartOf.add(insInd, rs.isPartOf.get(0)); + } else { + wikivoyage.put(rs.routeId, rs); + } + } + return wikivoyage.values(); } @NonNull @@ -226,7 +294,6 @@ public class TravelObfHelper implements TravelHelper { 0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), new ResultMatcher() { boolean done = false; - final Collator collator = OsmAndCollator.primaryCollator(); @Override public boolean publish(Amenity amenity) { From 4e5184876661eadb6bf98c32039b8332af6ba8f7 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 18 Dec 2020 18:40:01 +0300 Subject: [PATCH 68/76] Fix search in TravelObfHelper --- .../osmand/plus/wikivoyage/data/TravelObfHelper.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index c5dc28c8e3..e1dc65ebfd 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -123,9 +123,17 @@ public class TravelObfHelper implements TravelHelper { }; } - private TravelArticle readArticle(Amenity amenity, String lang) { + private TravelArticle readArticle(@NonNull Amenity amenity, @Nullable String lang) { TravelArticle res = new TravelArticle(); - res.title = Algorithms.isEmpty(amenity.getName(lang)) ? amenity.getName() : amenity.getName(lang); + String title = Algorithms.isEmpty(amenity.getName(lang)) ? amenity.getName() : amenity.getName(lang); + if (Algorithms.isEmpty(title)) { + Map namesMap = amenity.getNamesMap(true); + if (!namesMap.isEmpty()) { + lang = namesMap.keySet().iterator().next(); + title = amenity.getName(lang); + } + } + res.title = title; res.content = amenity.getDescription(lang); res.isPartOf = emptyIfNull(amenity.getTagContent(Amenity.IS_PART, lang)); res.lat = amenity.getLocation().getLatitude(); From 9bd994c9c8dd72a34862cb20e7f7dc25b4d0f7b7 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Fri, 18 Dec 2020 15:36:03 +0000 Subject: [PATCH 69/76] Translated using Weblate (French) Currently translated at 99.9% (3580 of 3582 strings) --- OsmAnd/res/values-fr/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index aa448607ce..fc753fd72b 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3852,7 +3852,7 @@ Reprendre l\'enregistrement du trajet Suspendre l\'enregistrement du trajet Définit la fréquence d’enregistrement des points du parcours (activable depuis le gadget \"Enregistrement\" sur la carte). - Suspend l\'enregistrement du parcours lorsque l\'application est arrêtée via Applications récentes ; les indications OsmAnd ne seront plus affichées dans la barre de notifications. + L\'enregistrement de l\'itinéraire sera suspendu si l\'application est arrêtée via Applications récentes (les indications OsmAnd ne seront plus affichées dans la barre de notifications). Tous les segments suivants seront recalculés avec le profil sélectionné. Tous les segments précédents seront recalculés avec le profil sélectionné. Tous les segments suivants @@ -3885,7 +3885,7 @@ Nom : A – Z Icônes de départ et d\'arrivée Merci pour votre achat de \'Courbes de niveaux\' - Abonnement facturé pour chaque période sélectionnée. Annulation possible à tout moment sur AppGallery. + L\'abonnement est facturé pour la période sélectionnée. Annulation possible à tout moment sur AppGallery. Éviter les trottoirs Éviter les trottoirs Développement From 3df6e3f2078b50418e06d6135da16e571bd2dbea Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 18 Dec 2020 15:34:23 +0000 Subject: [PATCH 70/76] Translated using Weblate (German) Currently translated at 100.0% (3582 of 3582 strings) --- OsmAnd/res/values-de/strings.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 680fd0c035..7ec31aa8a6 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -562,7 +562,7 @@ Sprachansagen Sprachansage Vektorkarten wurden nicht geladen - GPX-Daten konnten nicht gelesen werden + GPX-Daten konnten nicht gelesen werden. Offline-Vektorkarten Suche nach Verbindung an Haltestelle Bearbeite POI @@ -2170,7 +2170,7 @@ Karten-Overlay wurde in „%s“ geändert. Karten-Underlay wurde in „%s“ geändert. Ungültiger OLC - +\n Kurzer OLC \nBitte geben Sie einen vollständigen Code ein Gültiger vollständiger OLC @@ -4022,4 +4022,5 @@ Neues Segment hinzufügen OsmAnd-Profil Benutzerprofil + Alle Punkte umkehren \ No newline at end of file From db08e5e683475b7eaabade43a3e9da380b7ab3b1 Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Fri, 18 Dec 2020 14:52:32 +0000 Subject: [PATCH 71/76] Translated using Weblate (Sardinian) Currently translated at 99.7% (3574 of 3582 strings) --- OsmAnd/res/values-sc/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 8a5a50a624..44d5d37f94 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -4015,4 +4015,5 @@ \n Profilu de OsmAnd Profilu de s\'impreadore + Fùrria totu sos puntos \ No newline at end of file From 8e7078edef157499fed9180daf46b4829581a076 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 18 Dec 2020 15:40:21 +0000 Subject: [PATCH 72/76] Translated using Weblate (German) Currently translated at 100.0% (3877 of 3877 strings) --- OsmAnd/res/values-de/phrases.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index a05ba941da..5406e3a1e1 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -1528,8 +1528,8 @@ Baden: ja Baden: nein Bootslager - Brücke Nr. - Tunnel Nr. + Bauwerksnummer + Bauwerksnummer Nr. Passagiere Fahrzeuge @@ -3897,4 +3897,8 @@ Wassertank Wasserhahn Wasserwerk + Waschplatz für Wäsche + Müllumladestation + Fahrzeugwaage + Rangerstation \ No newline at end of file From 409d7605201a4ccd75c868a79fc6e2f61b2eb73d Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Fri, 18 Dec 2020 14:55:36 +0000 Subject: [PATCH 73/76] Translated using Weblate (Sardinian) Currently translated at 99.6% (3865 of 3877 strings) --- OsmAnd/res/values-sc/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-sc/phrases.xml b/OsmAnd/res/values-sc/phrases.xml index b04d3277e7..939dd49e0c 100644 --- a/OsmAnd/res/values-sc/phrases.xml +++ b/OsmAnd/res/values-sc/phrases.xml @@ -3892,4 +3892,6 @@ Putzu a tubu Bilàntzia a ponte Istatzione de sos rangers + Sabunadòrgiu + Istatzione de tramudòngiu de s\'arga \ No newline at end of file From 814086aa3433ce5ea2d68f2f4e6685758e3364d8 Mon Sep 17 00:00:00 2001 From: WaldiS Date: Fri, 18 Dec 2020 17:55:42 +0000 Subject: [PATCH 74/76] Translated using Weblate (Polish) Currently translated at 99.5% (3567 of 3582 strings) --- OsmAnd/res/values-pl/strings.xml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index 9e18f5c096..f3ca626e16 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -1941,7 +1941,7 @@ Cienki Średni Gruby - Nie ustalono celu + Wtyczka ułatwień dostępu: nie ustawiono miejsca docelowego Utrzymywanie trasy po zboczeniu z niej Brak ponownego przeliczania trasy po zjechaniu z trasy. Orientacja magnetyczna @@ -3791,9 +3791,9 @@ Usuń najbliższy punkt docelowy Steruj poziomem powiększenia mapy za pomocą przycisków głośności na urządzeniu. Podaj nazwę punktu - Bieżący punkt docelowy na trasie zostanie usunięty. Jeśli będzie to miejsce docelowe, nawigacja zostanie zatrzymana. + Usuwa następny cel na trasie. Jeśli jest to miejsce docelowe, nawigacja zostanie zatrzymana. Pobierz mapy Wikipedii - Uzyskaj informacje o interesujących miejscach z Wikipedii. Jest to kieszonkowy przewodnik offline - wystarczy włączyć wtyczkę Wikipedii i cieszyć się artykułami o obiektach wokół ciebie. + Uzyskaj informacje o ciekawych miejscach z Wikipedii, kieszonkowego przewodnika offline zawierającego artykuły o miejscach i celach. Motocykl Enduro Skuter Określ długość pojazdu dozwoloną na trasach. @@ -3839,7 +3839,7 @@ Wybierz sposób łączenia punktów, za pomocą linii prostej, lub oblicz trasę między nimi w sposób określony poniżej. Następnie przyciągnij trasę do najbliższej dozwolonej drogi za pomocą jednego z profili nawigacji, aby skorzystać z tej opcji. Zdjęcia z poziomu ulicy - Czy na pewno chcesz odrzucić wszystkie zmiany w zaplanowanej trasie, zamykając ją\? + Czy na pewno chcesz odrzucić wszystkie zmiany w zaplanowanej trasie\? W przypadku odwrotnego kierunku Przejdź z mojej lokalizacji na trasę Sportowy wózek inwalidzki @@ -3912,7 +3912,7 @@ Co nowego Ikony startu i końca Dziękujemy za zakup \"Linii konturowych\" - Subskrypcja naliczona za wybrany okres. Anuluj ją w AppGallery w dowolnym momencie. + Subskrypcja jest naliczana za wybrany okres. Anuluj go w AppGallery w dowolnym momencie. Płatność zostanie pobrana z konta AppGallery po potwierdzeniu zakupu. \n \nSubskrypcja jest automatycznie odnawiana, chyba że zostanie anulowana przed datą odnowienia. Twoje konto zostanie obciążone opłatą za okres odnowienia (miesiąc/trzy miesiące/rok) tylko w dniu odnowienia. @@ -3937,7 +3937,7 @@ MGRS Użyj 2-fazowego algorytmu routingu A * Wykres - %1$s dane dostępne tylko na drogach, aby je uzyskać, musisz obliczyć trasę za pomocą opcji „Trasa między punktami”. + %1$s dane dostępne tylko na drogach, oblicz trasę, korzystając z opcji „Trasa między punktami”, aby wyświetlić wykresy. Proszę czekać. \nWykres będzie dostępny po ponownym obliczeniu trasy. Mapy lokalne @@ -3956,7 +3956,7 @@ Subskrypcja OsmAnd Live została wstrzymana Do jazdy skuterem śnieżnym z wyznaczonymi drogami i torami. Dodaj co najmniej dwa punkty - Wystąpił problem z Twoją subskrypcją. Naciśnij przycisk, aby przejść do ustawień subskrypcji Google Play i naprawić metodę płatności. + Stuknij przycisk, aby skonfigurować metodę płatności w Google Play i naprawić subskrypcję. Subskrypcja OsmAnd Live jest wstrzymana Login Zaloguj się do OpenStreetMap @@ -4021,4 +4021,7 @@ \n• Obsługa niestandardowych kolorów dla ulubionych i śledzenia punktów trasy \n \n + Profil OsmAnd + Profil użytkownika + Odwróć wszystkie punkty \ No newline at end of file From d5437149e05a94702fbb9eab2355013b24188189 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Fri, 18 Dec 2020 16:27:18 +0000 Subject: [PATCH 75/76] Translated using Weblate (Persian) Currently translated at 97.9% (3507 of 3582 strings) --- OsmAnd/res/values-fa/strings.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index f7493ff42e..e5a0251d4b 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -3987,4 +3987,23 @@ ساخت حساب جدید حساب کاربری دارم تاریخچهٔ جست‌وجو + دستگاه شما تنها %1$s فضای خالی دارد. لطفا مقادری فضا خالی کنید و یا تعداد موارد برون‌ریزی را کاهش دهید. + فضای کافی موجود نیست + گروه‌هایی را که درون‌ریزی خواهند شد را انتخاب کنید. + مواردی را که درون‌ریزی خواهند شد را انتخاب کنید. + افزودن به مپیلاری + افزودن به OpenPlaceReviews + برای امتحان کردن بارگذاری یادداشت / نقاط توجه و GPX از dev.openstreetmap.org به جای openstreetmep.org استفاده کنید. + از dev.openstreetmap.org استفاده کنید + برنامه OsmAnd عکس‌ها را از چند منبع نشان می‌دهد: +\nاز OpenPlaceReview برای عکس‌های نقاط توجه؛ +\nاز مپیلاری برای تصویر سطح خیابان؛ +\nاز وب و ویکی‌پدیا برای عکس‌های نقاط توجه متناسب با داده‌های اوپن‌استریت‌مپ. + هواپیمای سبک + اتصال بخش‌ها + "تقطیع از این جا به قبل" + تقطیع از این جا به بعد + افزودن یک بخش جدید + نمایهٔ OsmAnd + نمایهٔ کاربر \ No newline at end of file From 3134f3c6bccd8fb31cf2f7ec30e84f100b31854e Mon Sep 17 00:00:00 2001 From: ovl-1 Date: Fri, 18 Dec 2020 18:48:39 +0000 Subject: [PATCH 76/76] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 58.6% (2101 of 3582 strings) --- OsmAnd/res/values-nb/strings.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index d308624f86..aa5dcb1a44 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -3035,9 +3035,9 @@ Nedlastede kart Besøkte skjermer Definer hvilken data du ønsker å dele med OsmAnd. - Hjelp oss å forstå hvilke kart over hvilke regioner og land som er mest populære. - Hjelp oss å fastslå popularitet for OsmAnd-funksjoner. - Trykk \"Tillat\" hvis du samtykker du til vår %1$s + Hjelp oss å forstå hvilke land- og regionkart som er mest populære. + Hjelp oss å forstå hvilke OsmAnd-funksjoner som er mest populære. + Trykk \"Tillat\" hvis du er enig med vår %1$s Personvern og sikkerhet Velg hvilke data du deler Nei takk @@ -3939,4 +3939,5 @@ Logg inn på OpenStreetMap.org OsmAnd-profil Brukerprofil + Bedøm \ No newline at end of file