From 3e9ef3914b3b3962d00e2803bdd2ad6411cb6523 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Mon, 4 Jan 2021 10:08:10 +0200 Subject: [PATCH 01/61] add filterPoiByType() --- .../java/net/osmand/search/SearchUICore.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index e63870b1a7..14a4566279 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -204,6 +204,7 @@ public class SearchUICore { for (SearchResult rs : lstUnique) { same = sameSearchResult(rs, r); if (same) { + filterPoiByType(rs, r, lst); break; } } @@ -217,6 +218,24 @@ public class SearchUICore { } } } + + private void filterPoiByType(SearchResult r1, SearchResult r2, List list) { + if (r1.object instanceof Amenity) { + + Amenity a1 = (Amenity) r1.object; + Amenity a2 = (Amenity) r2.object; + + if (!(a2.getSubType().equals("building") || a2.getSubType().contains("internet")) + && (a1.getSubType().equals("building") || a1.getSubType().contains("internet"))) { + + int index = list.indexOf(r1); + + if (list.contains(r1)) { + list.set(index, r2); + } + } + } + } public boolean sameSearchResult(SearchResult r1, SearchResult r2) { if (r1.location != null && r2.location != null && @@ -244,10 +263,16 @@ public class SearchUICore { String type2 = a2.getType().getKeyName(); String subType1 = a1.getSubType(); String subType2 = a2.getSubType(); - if(a1.getId().longValue() == a2.getId().longValue() && (subType1.equals("building") || subType2.equals("building"))) { + + if (a1.getId().longValue() == a2.getId().longValue() + && ((subType1.equals("building") || subType2.equals("building")))) { return true; } if (!type1.equals(type2)) { + if (a1.getId().longValue() == a2.getId().longValue() && subType1.contains("internet") + || subType2.contains("internet")) { + return true; + } return false; } if (type1.equals("natural")) { From 29edac0125e9b92b5e54c0a3e1a11dddb4053735 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 5 Jan 2021 12:36:02 +0200 Subject: [PATCH 02/61] add option to copy address; --- OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/mapcontextmenu/other/ShareMenu.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a78818557b..fb403c340c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + Copy address Allow intermittent water ways Allow intermittent water ways Allow streams and drains diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java index 7323e52b5d..aba6ca8277 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java @@ -36,6 +36,7 @@ public class ShareMenu extends BaseMenuController { public enum ShareItem { MESSAGE(R.drawable.ic_action_message, R.string.shared_string_send), CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy), + ADDRESS(R.drawable.ic_action_copy, R.string.copy_address), NAME(R.drawable.ic_action_copy, R.string.copy_location_name), COORDINATES(R.drawable.ic_action_copy, R.string.copy_coordinates), GEO(R.drawable.ic_world_globe_dark, R.string.share_geo), @@ -66,6 +67,7 @@ public class ShareMenu extends BaseMenuController { List list = new LinkedList<>(); list.add(ShareItem.MESSAGE); list.add(ShareItem.CLIPBOARD); + list.add(ShareItem.ADDRESS); list.add(ShareItem.NAME); list.add(ShareItem.COORDINATES); list.add(ShareItem.GEO); @@ -121,6 +123,15 @@ public class ShareMenu extends BaseMenuController { case CLIPBOARD: ShareDialog.sendToClipboard(mapActivity, sms); break; + case ADDRESS: + if (!Algorithms.isEmpty(address)) { + ShareDialog.sendToClipboard(mapActivity, address); + } else { + Toast.makeText(mapActivity, + R.string.no_address_found, + Toast.LENGTH_LONG).show(); + } + break; case NAME: if (!Algorithms.isEmpty(title)) { ShareDialog.sendToClipboard(mapActivity, title); From b9339cdab55bd43a1a973671c99ee8ad4b26cb99 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Tue, 5 Jan 2021 15:11:14 +0200 Subject: [PATCH 03/61] fix filter by building and internet poi --- .../java/net/osmand/search/SearchUICore.java | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index 14a4566279..573068d207 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -204,7 +204,6 @@ public class SearchUICore { for (SearchResult rs : lstUnique) { same = sameSearchResult(rs, r); if (same) { - filterPoiByType(rs, r, lst); break; } } @@ -218,24 +217,6 @@ public class SearchUICore { } } } - - private void filterPoiByType(SearchResult r1, SearchResult r2, List list) { - if (r1.object instanceof Amenity) { - - Amenity a1 = (Amenity) r1.object; - Amenity a2 = (Amenity) r2.object; - - if (!(a2.getSubType().equals("building") || a2.getSubType().contains("internet")) - && (a1.getSubType().equals("building") || a1.getSubType().contains("internet"))) { - - int index = list.indexOf(r1); - - if (list.contains(r1)) { - list.set(index, r2); - } - } - } - } public boolean sameSearchResult(SearchResult r1, SearchResult r2) { if (r1.location != null && r2.location != null && @@ -263,7 +244,7 @@ public class SearchUICore { String type2 = a2.getType().getKeyName(); String subType1 = a1.getSubType(); String subType2 = a2.getSubType(); - + if (a1.getId().longValue() == a2.getId().longValue() && ((subType1.equals("building") || subType2.equals("building")))) { return true; @@ -275,6 +256,7 @@ public class SearchUICore { } return false; } + if (type1.equals("natural")) { similarityRadius = 50000; } else if (subType1.equals(subType2)) { @@ -1012,16 +994,20 @@ public class SearchUICore { // here 2 points are amenity Amenity a1 = (Amenity) o1.object; Amenity a2 = (Amenity) o2.object; - String type1 = a1.getType().getKeyName(); - String type2 = a2.getType().getKeyName(); - int cmp = c.collator.compare(type1, type2); - if (cmp != 0) { - return cmp; - } - + String subType1 = a1.getSubType() == null ? "" : a1.getSubType(); String subType2 = a2.getSubType() == null ? "" : a2.getSubType(); - cmp = c.collator.compare(subType1, subType2); + + int cmp; + + if(subType1.equals("building") || subType1.contains("internet")) { + cmp = 1; + } else if(subType2.equals("building") || subType2.contains("internet")) { + cmp = -1; + } else { + cmp = c.collator.compare(subType1, subType2); + } + if (cmp != 0) { return cmp; } From 2fb22fbf2f3369a011036785a02d5d71fd0e0cd2 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 5 Jan 2021 16:07:31 +0200 Subject: [PATCH 04/61] Fix #10437 --- .../layout/fragment_wikivoyage_article_dialog.xml | 1 + OsmAnd/src/net/osmand/AndroidUtils.java | 12 ++++++++++++ .../src/net/osmand/plus/activities/ExitActivity.java | 2 ++ .../osmand/plus/activities/PrintDialogActivity.java | 3 ++- .../plus/dialogs/HelpArticleDialogFragment.java | 1 + .../osmand/plus/mapillary/MapillaryImageDialog.java | 1 + .../plus/wikipedia/WikipediaDialogFragment.java | 3 +-- .../article/WikivoyageArticleDialogFragment.java | 1 + 8 files changed, 21 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 232e041b75..c001ab748e 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -63,6 +63,7 @@ android:layout_width="match_parent" android:layout_weight="1" android:layout_height="0dp"> + = Build.VERSION_CODES.N) { + OsmandApplication app = (OsmandApplication) activity.getApplicationContext(); + app.checkPreferredLocale(); + activity.getResources().updateConfiguration( + new Configuration(app.getResources().getConfiguration()), + activity.getResources().getDisplayMetrics()); + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java index 67beabb1ad..5097a4f0cc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java @@ -1,5 +1,6 @@ package net.osmand.plus.activities; +import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.app.Activity; @@ -14,6 +15,7 @@ public class ExitActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_activity); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); dis = getIntent().getBooleanExtra(DISABLE_SERVICE, true); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java index 6c7e4d6579..b2211a639d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java @@ -3,7 +3,7 @@ */ package net.osmand.plus.activities; -import android.view.Window; +import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.annotation.SuppressLint; @@ -43,6 +43,7 @@ public class PrintDialogActivity extends ActionBarProgressActivity { getSupportActionBar().setTitle(R.string.print_route); setContentView(R.layout.print_dialog); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); webView = (WebView) findViewById(R.id.printDialogWebview); Intent intent = getIntent(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java index 42a036599c..3c47372356 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java @@ -54,6 +54,7 @@ public class HelpArticleDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_help_article, container, false); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setNavigationIcon(AndroidUtils.getNavigationIconResId(getContext())); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java index 7b9cd23b69..d20f03f4fe 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java @@ -220,6 +220,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog { @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) private View getWebView() { View view = getMapActivity().getLayoutInflater().inflate(R.layout.mapillary_web_view, null); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getMapActivity()); final WebView webView = view.findViewById(R.id.webView); webView.setBackgroundColor(Color.argb(1, 0, 0, 0)); final View noInternetView = view.findViewById(R.id.mapillaryNoInternetLayout); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 72ea3560cb..1ea89040cd 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -17,7 +17,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; -import android.webkit.WebView; import android.widget.ImageView; import android.widget.TextView; @@ -28,7 +27,6 @@ import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.Toolbar; import androidx.browser.customtabs.CustomTabsIntent; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -74,6 +72,7 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9303fb7b84..bc322b31fe 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -91,6 +91,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); From f27c397835cfdbad581f963723479d86b1e7dfbc Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 5 Jan 2021 21:19:24 +0100 Subject: [PATCH 05/61] Fix so we don't store old versions of indexes --- .../osmand/binary/CachedOsmandIndexes.java | 112 +++++++++--------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java index 63c81d13fa..d13bb63cd1 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java @@ -30,41 +30,43 @@ import net.osmand.binary.OsmandIndex.TransportPart; import org.apache.commons.logging.Log; public class CachedOsmandIndexes { - + private OsmAndStoredIndex storedIndex; private OsmAndStoredIndex.Builder storedIndexBuilder; private Log log = PlatformUtil.getLog(CachedOsmandIndexes.class); private boolean hasChanged = true; - + public static final int VERSION = 2; public void addToCache(BinaryMapIndexReader reader, File f) { hasChanged = true; - if(storedIndexBuilder == null) { + if (storedIndexBuilder == null) { storedIndexBuilder = OsmandIndex.OsmAndStoredIndex.newBuilder(); storedIndexBuilder.setVersion(VERSION); storedIndexBuilder.setDateCreated(System.currentTimeMillis()); - if(storedIndex != null) { - for(FileIndex ex : storedIndex.getFileIndexList()) { - storedIndexBuilder.addFileIndex(ex); + if (storedIndex != null) { + for (FileIndex ex : storedIndex.getFileIndexList()) { + if (!ex.getFileName().equals(f.getName())) { + storedIndexBuilder.addFileIndex(ex); + } } } } - + FileIndex.Builder fileIndex = OsmandIndex.FileIndex.newBuilder(); long d = reader.getDateCreated(); - fileIndex.setDateModified(d== 0?f.lastModified() : d); + fileIndex.setDateModified(d == 0 ? f.lastModified() : d); fileIndex.setSize(f.length()); fileIndex.setVersion(reader.getVersion()); fileIndex.setFileName(f.getName()); - for(MapIndex index : reader.getMapIndexes()) { + for (MapIndex index : reader.getMapIndexes()) { MapPart.Builder map = OsmandIndex.MapPart.newBuilder(); map.setSize(index.getLength()); map.setOffset(index.getFilePointer()); - if(index.getName() != null) { + if (index.getName() != null) { map.setName(index.getName()); } - for(MapRoot mr : index.getRoots() ) { + for (MapRoot mr : index.getRoots()) { MapLevel.Builder lev = OsmandIndex.MapLevel.newBuilder(); lev.setSize(mr.length); lev.setOffset(mr.filePointer); @@ -78,36 +80,36 @@ public class CachedOsmandIndexes { } fileIndex.addMapIndex(map); } - - for(AddressRegion index : reader.getAddressIndexes()) { + + for (AddressRegion index : reader.getAddressIndexes()) { AddressPart.Builder addr = OsmandIndex.AddressPart.newBuilder(); addr.setSize(index.getLength()); addr.setOffset(index.getFilePointer()); - if(index.getName() != null) { + if (index.getName() != null) { addr.setName(index.getName()); } - if(index.getEnName() != null) { + if (index.getEnName() != null) { addr.setNameEn(index.getEnName()); } addr.setIndexNameOffset(index.getIndexNameOffset()); - for(CitiesBlock mr : index.getCities() ) { + for (CitiesBlock mr : index.getCities()) { CityBlock.Builder cblock = OsmandIndex.CityBlock.newBuilder(); cblock.setSize(mr.length); cblock.setOffset(mr.filePointer); cblock.setType(mr.type); addr.addCities(cblock); } - for(String s : index.getAttributeTagsTable()) { + for (String s : index.getAttributeTagsTable()) { addr.addAdditionalTags(s); } fileIndex.addAddressIndex(addr); } - - for(PoiRegion index : reader.getPoiIndexes()) { + + for (PoiRegion index : reader.getPoiIndexes()) { PoiPart.Builder poi = OsmandIndex.PoiPart.newBuilder(); poi.setSize(index.getLength()); poi.setOffset(index.getFilePointer()); - if(index.getName() != null) { + if (index.getName() != null) { poi.setName(index.getName()); } poi.setLeft(index.left31); @@ -116,12 +118,12 @@ public class CachedOsmandIndexes { poi.setBottom(index.bottom31); fileIndex.addPoiIndex(poi.build()); } - - for(TransportIndex index : reader.getTransportIndexes()) { + + for (TransportIndex index : reader.getTransportIndexes()) { TransportPart.Builder transport = OsmandIndex.TransportPart.newBuilder(); transport.setSize(index.getLength()); transport.setOffset(index.getFilePointer()); - if(index.getName() != null) { + if (index.getName() != null) { transport.setName(index.getName()); } transport.setLeft(index.getLeft()); @@ -130,33 +132,33 @@ public class CachedOsmandIndexes { transport.setBottom(index.getBottom()); transport.setStopsTableLength(index.stopsFileLength); transport.setStopsTableOffset(index.stopsFileOffset); -// if(index.incompleteRoutesLength > 0) { + // if(index.incompleteRoutesLength > 0) { transport.setIncompleteRoutesLength(index.incompleteRoutesLength); transport.setIncompleteRoutesOffset(index.incompleteRoutesOffset); -// } + // } transport.setStringTableLength(index.stringTable.length); transport.setStringTableOffset(index.stringTable.fileOffset); fileIndex.addTransportIndex(transport); } - - for(RouteRegion index : reader.getRoutingIndexes()) { + + for (RouteRegion index : reader.getRoutingIndexes()) { RoutingPart.Builder routing = OsmandIndex.RoutingPart.newBuilder(); routing.setSize(index.getLength()); routing.setOffset(index.getFilePointer()); - if(index.getName() != null) { + if (index.getName() != null) { routing.setName(index.getName()); } - for(RouteSubregion sub : index.getSubregions()) { + for (RouteSubregion sub : index.getSubregions()) { addRouteSubregion(routing, sub, false); } - for(RouteSubregion sub : index.getBaseSubregions()) { + for (RouteSubregion sub : index.getBaseSubregions()) { addRouteSubregion(routing, sub, true); } fileIndex.addRoutingIndex(routing); } - + storedIndexBuilder.addFileIndex(fileIndex); - + } private void addRouteSubregion(RoutingPart.Builder routing, RouteSubregion sub, boolean base) { @@ -171,7 +173,7 @@ public class CachedOsmandIndexes { rpart.setShifToData(sub.shiftToData); routing.addSubregions(rpart); } - + public BinaryMapIndexReader getReader(File f) throws IOException { RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r"); FileIndex found = null; @@ -191,26 +193,26 @@ public class CachedOsmandIndexes { reader = new BinaryMapIndexReader(mf, f); addToCache(reader, f); if (log.isDebugEnabled()) { - log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val ) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } else { reader = initFileIndex(found, mf, f); } return reader; } - + private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf, File f) throws IOException { BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f, false); reader.version = found.getVersion(); reader.dateCreated = found.getDateModified(); - - for(MapPart index : found.getMapIndexList()) { + + for (MapPart index : found.getMapIndexList()) { MapIndex mi = new MapIndex(); mi.length = (int) index.getSize(); mi.filePointer = (int) index.getOffset(); mi.name = index.getName(); - - for(MapLevel mr : index.getLevelsList()) { + + for (MapLevel mr : index.getLevelsList()) { MapRoot root = new MapRoot(); root.length = (int) mr.getSize(); root.filePointer = (int) mr.getOffset(); @@ -226,15 +228,15 @@ public class CachedOsmandIndexes { reader.indexes.add(mi); reader.basemap = reader.basemap || mi.isBaseMap(); } - - for(AddressPart index : found.getAddressIndexList()) { + + for (AddressPart index : found.getAddressIndexList()) { AddressRegion mi = new AddressRegion(); mi.length = (int) index.getSize(); mi.filePointer = (int) index.getOffset(); mi.name = index.getName(); mi.enName = index.getNameEn(); mi.indexNameOffset = index.getIndexNameOffset(); - for(CityBlock mr : index.getCitiesList() ) { + for (CityBlock mr : index.getCitiesList()) { CitiesBlock cblock = new CitiesBlock(); cblock.length = (int) mr.getSize(); cblock.filePointer = (int) mr.getOffset(); @@ -245,8 +247,8 @@ public class CachedOsmandIndexes { reader.addressIndexes.add(mi); reader.indexes.add(mi); } - - for(PoiPart index : found.getPoiIndexList()) { + + for (PoiPart index : found.getPoiIndexList()) { PoiRegion mi = new PoiRegion(); mi.length = (int) index.getSize(); mi.filePointer = (int) index.getOffset(); @@ -258,14 +260,14 @@ public class CachedOsmandIndexes { reader.poiIndexes.add(mi); reader.indexes.add(mi); } - - for(TransportPart index : found.getTransportIndexList()) { + + for (TransportPart index : found.getTransportIndexList()) { TransportIndex mi = new TransportIndex(); mi.length = (int) index.getSize(); mi.filePointer = (int) index.getOffset(); mi.name = index.getName(); mi.left = index.getLeft(); - mi.right =index.getRight(); + mi.right = index.getRight(); mi.top = index.getTop(); mi.bottom = index.getBottom(); mi.stopsFileLength = index.getStopsTableLength(); @@ -278,14 +280,14 @@ public class CachedOsmandIndexes { reader.transportIndexes.add(mi); reader.indexes.add(mi); } - - for(RoutingPart index : found.getRoutingIndexList()) { + + for (RoutingPart index : found.getRoutingIndexList()) { RouteRegion mi = new RouteRegion(); mi.length = (int) index.getSize(); mi.filePointer = (int) index.getOffset(); mi.name = index.getName(); - - for(RoutingSubregion mr : index.getSubregionsList()) { + + for (RoutingSubregion mr : index.getSubregionsList()) { RouteSubregion sub = new RouteSubregion(mi); sub.length = (int) mr.getSize(); sub.filePointer = (int) mr.getOffset(); @@ -294,7 +296,7 @@ public class CachedOsmandIndexes { sub.top = mr.getTop(); sub.bottom = mr.getBottom(); sub.shiftToData = mr.getShifToData(); - if(mr.getBasemap()) { + if (mr.getBasemap()) { mi.basesubregions.add(sub); } else { mi.subregions.add(sub); @@ -303,7 +305,7 @@ public class CachedOsmandIndexes { reader.routingIndexes.add(mi); reader.indexes.add(mi); } - + return reader; } @@ -313,7 +315,7 @@ public class CachedOsmandIndexes { try { storedIndex = OsmandIndex.OsmAndStoredIndex.newBuilder().mergeFrom(is).build(); hasChanged = false; - if(storedIndex.getVersion() != version){ + if (storedIndex.getVersion() != version) { storedIndex = null; } } finally { @@ -321,7 +323,7 @@ public class CachedOsmandIndexes { } log.info("Initialize cache " + (System.currentTimeMillis() - time)); } - + public void writeToFile(File f) throws IOException { if (hasChanged) { FileOutputStream outputStream = new FileOutputStream(f); From d74e57db84858661acb66007c3a2a73182aa8b1c Mon Sep 17 00:00:00 2001 From: Kseniia Date: Tue, 5 Jan 2021 22:49:39 +0200 Subject: [PATCH 06/61] refactoring --- .../java/net/osmand/search/SearchUICore.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index 573068d207..f8b738a509 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -41,10 +41,13 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class SearchUICore { @@ -67,6 +70,8 @@ public class SearchUICore { private MapPoiTypes poiTypes; private static boolean debugMode = false; + + private static final Set FILTER_DUPLICATE_POI_SUBTYPE = Stream.of("building").collect((Collectors.toCollection(TreeSet::new))); public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) { this.poiTypes = poiTypes; @@ -245,18 +250,20 @@ public class SearchUICore { String subType1 = a1.getSubType(); String subType2 = a2.getSubType(); - if (a1.getId().longValue() == a2.getId().longValue() - && ((subType1.equals("building") || subType2.equals("building")))) { + boolean isEqualId = a1.getId().longValue() == a2.getId().longValue(); + + if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) + || FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) { return true; + } if (!type1.equals(type2)) { - if (a1.getId().longValue() == a2.getId().longValue() && subType1.contains("internet") - || subType2.contains("internet")) { + if (isEqualId && (subType1.contains("internet") || subType2.contains("internet"))) { return true; } return false; } - + if (type1.equals("natural")) { similarityRadius = 50000; } else if (subType1.equals(subType2)) { @@ -1000,9 +1007,9 @@ public class SearchUICore { int cmp; - if(subType1.equals("building") || subType1.contains("internet")) { + if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) || subType1.contains("internet")) { cmp = 1; - } else if(subType2.equals("building") || subType2.contains("internet")) { + } else if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2) || subType2.contains("internet")) { cmp = -1; } else { cmp = c.collator.compare(subType1, subType2); From be80a4c5748bdcbb9b4e3fa02869c0938044fe31 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Tue, 5 Jan 2021 23:29:26 +0200 Subject: [PATCH 07/61] refactoring --- .../java/net/osmand/search/SearchUICore.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index f8b738a509..589dfb3b3f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -34,6 +34,7 @@ import org.json.JSONObject; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; @@ -71,7 +72,7 @@ public class SearchUICore { private static boolean debugMode = false; - private static final Set FILTER_DUPLICATE_POI_SUBTYPE = Stream.of("building").collect((Collectors.toCollection(TreeSet::new))); + private static final Set FILTER_DUPLICATE_POI_SUBTYPE = new TreeSet(Arrays.asList("building", "internet_access_yes")); public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) { this.poiTypes = poiTypes; @@ -249,16 +250,17 @@ public class SearchUICore { String type2 = a2.getType().getKeyName(); String subType1 = a1.getSubType(); String subType2 = a2.getSubType(); - - boolean isEqualId = a1.getId().longValue() == a2.getId().longValue(); + boolean isEqualId = a1.getId().longValue() == a2.getId().longValue(); + if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) || FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) { return true; } if (!type1.equals(type2)) { - if (isEqualId && (subType1.contains("internet") || subType2.contains("internet"))) { + if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) + || FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) { return true; } return false; @@ -1001,20 +1003,20 @@ public class SearchUICore { // here 2 points are amenity Amenity a1 = (Amenity) o1.object; Amenity a2 = (Amenity) o2.object; - + String subType1 = a1.getSubType() == null ? "" : a1.getSubType(); String subType2 = a2.getSubType() == null ? "" : a2.getSubType(); - + int cmp; - - if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) || subType1.contains("internet")) { + + if (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1)) { cmp = 1; - } else if(FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2) || subType2.contains("internet")) { + } else if (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2)) { cmp = -1; } else { cmp = c.collator.compare(subType1, subType2); } - + if (cmp != 0) { return cmp; } From 3096f6f8fde3facfd016f95487ae514a0e796a8b Mon Sep 17 00:00:00 2001 From: Kseniia Date: Wed, 6 Jan 2021 00:05:21 +0200 Subject: [PATCH 08/61] refactoring --- .../java/net/osmand/search/SearchUICore.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index 589dfb3b3f..df8c2bd5be 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -47,8 +47,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class SearchUICore { @@ -72,7 +70,8 @@ public class SearchUICore { private static boolean debugMode = false; - private static final Set FILTER_DUPLICATE_POI_SUBTYPE = new TreeSet(Arrays.asList("building", "internet_access_yes")); + private static final Set FILTER_DUPLICATE_POI_SUBTYPE = new TreeSet( + Arrays.asList("building", "internet_access_yes")); public SearchUICore(MapPoiTypes poiTypes, String locale, boolean transliterate) { this.poiTypes = poiTypes; @@ -252,17 +251,12 @@ public class SearchUICore { String subType2 = a2.getSubType(); boolean isEqualId = a1.getId().longValue() == a2.getId().longValue(); - + if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) || FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) { return true; - } - if (!type1.equals(type2)) { - if (isEqualId && (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1) - || FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2))) { - return true; - } + } else if (!type1.equals(type2)) { return false; } @@ -1004,19 +998,29 @@ public class SearchUICore { Amenity a1 = (Amenity) o1.object; Amenity a2 = (Amenity) o2.object; + String type1 = a1.getType().getKeyName(); + String type2 = a2.getType().getKeyName(); String subType1 = a1.getSubType() == null ? "" : a1.getSubType(); String subType2 = a2.getSubType() == null ? "" : a2.getSubType(); - int cmp; + int cmp = 0; if (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType1)) { cmp = 1; } else if (FILTER_DUPLICATE_POI_SUBTYPE.contains(subType2)) { cmp = -1; - } else { - cmp = c.collator.compare(subType1, subType2); + } + + if (cmp != 0) { + return cmp; } + cmp = c.collator.compare(type1, type2); + if (cmp != 0) { + return cmp; + } + + cmp = c.collator.compare(subType1, subType2); if (cmp != 0) { return cmp; } From 37bfc759b181009c3cd322601b3339919f92eff5 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 Jan 2021 00:30:00 +0200 Subject: [PATCH 09/61] Update CachedOsmandIndexes after map download --- .../net/osmand/binary/CachedOsmandIndexes.java | 16 ++++++++-------- .../plus/download/DownloadIndexesThread.java | 2 +- .../osmand/plus/resources/ResourceManager.java | 8 ++++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java index d13bb63cd1..56b5731577 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java @@ -1,11 +1,5 @@ package net.osmand.binary; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.RandomAccessFile; - import net.osmand.PlatformUtil; import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion; import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock; @@ -29,6 +23,12 @@ import net.osmand.binary.OsmandIndex.TransportPart; import org.apache.commons.logging.Log; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; + public class CachedOsmandIndexes { private OsmAndStoredIndex storedIndex; @@ -174,10 +174,10 @@ public class CachedOsmandIndexes { routing.addSubregions(rpart); } - public BinaryMapIndexReader getReader(File f) throws IOException { + public BinaryMapIndexReader getReader(File f, boolean useStoredIndex) throws IOException { RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r"); FileIndex found = null; - if (storedIndex != null) { + if (storedIndex != null && useStoredIndex) { for (int i = 0; i < storedIndex.getFileIndexCount(); i++) { FileIndex fi = storedIndex.getFileIndex(i); if (f.length() == fi.getSize() && f.getName().equals(fi.getFileName())) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 3355d67a32..9d47f57762 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -576,7 +576,7 @@ public class DownloadIndexesThread { manager.indexVoiceFiles(this); manager.indexFontFiles(this); if (vectorMapsToReindex) { - warnings = manager.indexingMaps(this); + warnings = manager.indexingMaps(this, filesToReindex); } List wns = manager.indexAdditionalMaps(this); if (wns != null) { diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index ffd8bb4e83..db1c3c96d6 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -621,7 +621,11 @@ public class ResourceManager { } } - public List indexingMaps(final IProgress progress) { + public List indexingMaps(IProgress progress) { + return indexingMaps(progress, Collections.emptyList()); + } + + public List indexingMaps(final IProgress progress, List filesToReindex) { long val = System.currentTimeMillis(); ArrayList files = new ArrayList(); File appPath = context.getAppPath(null); @@ -688,7 +692,7 @@ public class ResourceManager { try { BinaryMapIndexReader mapReader = null; try { - mapReader = cachedOsmandIndexes.getReader(f); + mapReader = cachedOsmandIndexes.getReader(f, !filesToReindex.contains(f)); if (mapReader.getVersion() != IndexConstants.BINARY_MAP_VERSION) { mapReader = null; } From de2704a62709e006746079a3f786ae48b8feb046 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 6 Jan 2021 04:36:21 +0200 Subject: [PATCH 10/61] add to context menu option to show nearby poi with the same type; --- OsmAnd/res/values/strings.xml | 1 + .../plus/mapcontextmenu/MenuBuilder.java | 108 ++++++++++++++---- .../builders/AmenityMenuBuilder.java | 16 ++- .../builders/FavouritePointMenuBuilder.java | 4 +- .../controllers/AmenityMenuController.java | 2 +- 5 files changed, 102 insertions(+), 29 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index fb403c340c..1e8391a3d8 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + Nearby POI Copy address Allow intermittent water ways Allow intermittent water ways diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 1d419a6b09..d4f60024f6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -41,6 +41,8 @@ import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; +import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.*; import net.osmand.plus.activities.ActivityResultListener; @@ -51,6 +53,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; +import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.openplacereviews.AddPhotosBottomSheetDialogFragment; import net.osmand.plus.openplacereviews.OPRConstants; @@ -92,12 +95,15 @@ public class MenuBuilder { protected boolean matchWidthDivider; protected boolean light; private long objectId; + private String objectType; private LatLon latLon; private boolean hidden; private boolean showTitleIfTruncated = true; private boolean showNearestWiki = false; + private boolean showNearestPoi = false; private boolean showOnlinePhotos = true; protected List nearestWiki = new ArrayList<>(); + protected List nearestPoi = new ArrayList<>(); private List menuPlugins = new ArrayList<>(); @Nullable private CardsRowBuilder onlinePhotoCardsRow; @@ -208,10 +214,18 @@ public class MenuBuilder { return showNearestWiki; } + public boolean isShowNearestPoi() { + return showNearestPoi; + } + public void setShowNearestWiki(boolean showNearestWiki) { this.showNearestWiki = showNearestWiki; } + public void setShowNearestPoi(boolean showNearestPoi) { + this.showNearestPoi = showNearestPoi; + } + public void setShowTitleIfTruncated(boolean showTitleIfTruncated) { this.showTitleIfTruncated = showTitleIfTruncated; } @@ -229,6 +243,11 @@ public class MenuBuilder { this.showNearestWiki = showNearestWiki; } + public void setShowNearestPoi(boolean showNearestPoi, String objectType) { + this.objectType = objectType; + this.showNearestPoi = showNearestPoi; + } + public void addMenuPlugin(OsmandPlugin plugin) { menuPlugins.add(plugin); } @@ -246,6 +265,7 @@ public class MenuBuilder { buildTitleRow(view); } buildNearestWikiRow(view); + buildNearestPoiRow(view); if (needBuildPlainMenuItems()) { buildPlainMenuItems(view); } @@ -325,10 +345,20 @@ public class MenuBuilder { } protected void buildNearestWikiRow(View view) { - if (processNearestWiki() && nearestWiki.size() > 0) { - buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", 0, - true, getCollapsableWikiView(view.getContext(), true), - false, 0, false, null, false); + buildNearestRow(view, nearestWiki, processNearestWiki(), + R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around)); + } + + protected void buildNearestPoiRow(View view) { + buildNearestRow(view, nearestPoi, processNearestPoi(), + nearestPoi.isEmpty() ? 0 : AmenityMenuController.getRightIconId(nearestPoi.get(0)), + app.getString(R.string.poi_around)); + } + + protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { + if (process && nearestAmenities.size() > 0) { + buildRow(view, iconId, null, text + " (" + nearestAmenities.size() + ")", 0, true, + getCollapsableView(view.getContext(), true, nearestAmenities), false, 0, false, null, false); } } @@ -1118,20 +1148,25 @@ public class MenuBuilder { return new CollapsableView(textView, this, collapsed); } - protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) { + protected CollapsableView getCollapsableView(Context context, boolean collapsed, List nearestAmenities) { LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true); - for (final Amenity wiki : nearestWiki) { + for (final Amenity poi : nearestAmenities) { TextViewEx button = buildButtonInCollapsableView(context, false, false); - String name = wiki.getName(preferredMapAppLang, transliterateNames); + String name = poi.getName(preferredMapAppLang, transliterateNames); + if (Algorithms.isBlank(name)) { + PoiCategory pc = poi.getType(); + PoiType pt = pc.getPoiTypeByKeyName(poi.getSubType()); + name = pt.getTranslation(); + } button.setText(name); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - LatLon latLon = new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()); - PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki); - mapActivity.getContextMenu().show(latLon, pointDescription, wiki); + LatLon latLon = new LatLon(poi.getLocation().getLatitude(), poi.getLocation().getLongitude()); + PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(poi); + mapActivity.getContextMenu().show(latLon, pointDescription, poi); } }); view.addView(button); @@ -1192,21 +1227,7 @@ public class MenuBuilder { protected boolean processNearestWiki() { if (showNearestWiki && latLon != null) { - QuadRect rect = MapUtils.calculateLatLonBbox( - latLon.getLatitude(), latLon.getLongitude(), 250); - PoiUIFilter wikiPoiFilter = app.getPoiFilters().getTopWikiPoiFilter(); - - nearestWiki = getAmenities(rect, wikiPoiFilter); - - Collections.sort(nearestWiki, new Comparator() { - - @Override - public int compare(Amenity o1, Amenity o2) { - double d1 = MapUtils.getDistance(latLon, o1.getLocation()); - double d2 = MapUtils.getDistance(latLon, o2.getLocation()); - return Double.compare(d1, d2); - } - }); + nearestWiki = getSortedAmenities(app.getPoiFilters().getTopWikiPoiFilter()); Long id = objectId; List wikiList = new ArrayList<>(); for (Amenity wiki : nearestWiki) { @@ -1220,6 +1241,43 @@ public class MenuBuilder { return false; } + protected boolean processNearestPoi() { + if (showNearestPoi && latLon != null) { + nearestPoi = getSortedAmenities(app.getPoiFilters().getShowAllPOIFilter()); + Long id = objectId; + String type = objectType; + List poiList = new ArrayList<>(); + for (Amenity poi : nearestPoi) { + if (poi.getId().equals(id) || !Algorithms.stringsEqual(poi.getSubType(), type)) { + poiList.add(poi); + } + } + nearestPoi.removeAll(poiList); + return true; + } + return false; + } + + private List getSortedAmenities(PoiUIFilter filter) { + final LatLon latLon = getLatLon(); + QuadRect rect = MapUtils.calculateLatLonBbox( + latLon.getLatitude(), latLon.getLongitude(), 250); + + List nearestAmenities = getAmenities(rect, filter); + + Collections.sort(nearestAmenities, new Comparator() { + + @Override + public int compare(Amenity o1, Amenity o2) { + double d1 = MapUtils.getDistance(latLon, o1.getLocation()); + double d2 = MapUtils.getDistance(latLon, o2.getLocation()); + return Double.compare(d1, d2); + } + }); + + return nearestAmenities; + } + private List getAmenities(QuadRect rect, PoiUIFilter wikiPoiFilter) { return wikiPoiFilter.searchAmenities(rect.top, rect.left, rect.bottom, rect.right, -1, null); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 12b1b0d497..b72c1a60f5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -35,6 +35,7 @@ import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.mapcontextmenu.CollapsableView; import net.osmand.plus.mapcontextmenu.MenuBuilder; +import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.views.layers.POIMapLayer; @@ -79,6 +80,7 @@ public class AmenityMenuBuilder extends MenuBuilder { super(mapActivity); this.amenity = amenity; setShowNearestWiki(true, amenity.getId()); + setShowNearestPoi(true, amenity.getSubType()); metricSystem = mapActivity.getMyApplication().getSettings().METRIC_SYSTEM.get(); } @@ -86,6 +88,10 @@ public class AmenityMenuBuilder extends MenuBuilder { protected void buildNearestWikiRow(View view) { } + @Override + protected void buildNearestPoiRow(View view) { + } + private void buildRow(View view, int iconId, String text, String textPrefix, boolean collapsable, final CollapsableView collapsableView, int textColor, boolean isWiki, boolean isText, boolean needLinks, @@ -664,11 +670,19 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestWiki() && nearestWiki.size() > 0) { AmenityInfoRow wikiInfo = new AmenityInfoRow( "nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true, - getCollapsableWikiView(view.getContext(), true), + getCollapsableView(view.getContext(), true, nearestWiki), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, wikiInfo); } + if (processNearestPoi() && nearestPoi.size() > 0) { + AmenityInfoRow poiInfo = new AmenityInfoRow( + "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.poi_around) + " (" + nearestPoi.size() + ")", true, + getCollapsableView(view.getContext(), true, nearestPoi), + 0, false, false, false, 1000, null, false, false, false, 0); + buildAmenityRow(view, poiInfo); + } + if (osmEditingEnabled && amenity.getId() != null && amenity.getId() > 0 && (amenity.getId() % 2 == 0 || (amenity.getId() >> 1) < Integer.MAX_VALUE)) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java index 1e6df280a3..03110c8b32 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java @@ -59,9 +59,9 @@ public class FavouritePointMenuBuilder extends MenuBuilder { } @Override - protected void buildNearestWikiRow(View view) { + protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { if (originObject == null || !(originObject instanceof Amenity)) { - super.buildNearestWikiRow(view); + super.buildNearestRow(view, nearestAmenities, process, iconId, text); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 11564a1b73..e67b8dc11b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -116,7 +116,7 @@ public class AmenityMenuController extends MenuController { return getRightIconId(amenity); } - private static int getRightIconId(Amenity amenity) { + public static int getRightIconId(Amenity amenity) { String id = null; PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); if (st != null) { From 6d7c647a644dfe5b8c63b1a1fc581e2b788f71bc Mon Sep 17 00:00:00 2001 From: letypequividelespoubelles Date: Tue, 5 Jan 2021 21:59:54 +0000 Subject: [PATCH 11/61] Translated using Weblate (French) Currently translated at 99.9% (3603 of 3606 strings) --- OsmAnd/res/values-fr/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 65ac4718b2..faca31403e 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4007,4 +4007,5 @@ Autoriser les cours d’eau et les drains Autoriser les cours d’eau et les drains Nombre d\'annonces vocales + Laisser vide sinon \ No newline at end of file From 3cfdec720780876a35613558b0b2beedf62b9a9d Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Tue, 5 Jan 2021 18:02:00 +0000 Subject: [PATCH 12/61] Translated using Weblate (French) Currently translated at 99.9% (3603 of 3606 strings) --- OsmAnd/res/values-fr/strings.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index faca31403e..f3d030e821 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4008,4 +4008,15 @@ Autoriser les cours d’eau et les drains Nombre d\'annonces vocales Laisser vide sinon + Sous-type + Véhicule + Clé d\'API + URL du serveur + Saisissez le paramètre + Calculer un itinéraire d’essai + En voiture + A pieds + Vélo + Automobile + Erreur, vérifiez les paramètres \ No newline at end of file From 02afd3e67f9cca5c3cc74e057c9fdda6ac67893d Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Wed, 6 Jan 2021 06:35:15 +0000 Subject: [PATCH 13/61] Translated using Weblate (French) Currently translated at 99.9% (3603 of 3606 strings) --- OsmAnd/res/values-fr/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index f3d030e821..633470a815 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4007,7 +4007,7 @@ Autoriser les cours d’eau et les drains Autoriser les cours d’eau et les drains Nombre d\'annonces vocales - Laisser vide sinon + Si non, laissez vide Sous-type Véhicule Clé d\'API From 43d243c07e9a446585ba5887e5d37f9a576ccfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Tue, 5 Jan 2021 17:29:01 +0000 Subject: [PATCH 14/61] Translated using Weblate (Turkish) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-tr/strings.xml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 6b794136f0..fccc6158e3 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -1701,7 +1701,7 @@ Etiketi Kaldır Gecelik derlemeleri indir. kurar - Sokak Aydınlatma + Sokak aydınlatma Vekil sunucu Bir proxy sunucusu belirtin. Gizlilik @@ -3982,5 +3982,20 @@ Dere ve kanalizasyonlara izin ver Aralıklı su yollarına izin verin Aralıklı su yollarına izin ver - Sesli uyarı zamanı + Sesli uyarı zamanları + Çevrim içi yönlendirme motoru ekle + Çevrim içi yönlendirme motorunu düzenle + Alt tür + Araç + API anahtarı + Sunucu URL\'si + Parametre gir + Değilse boş tut + Tüm parametreleri ile URL şu şekilde görünecektir: + Güzergah hesaplamayı test et + Araba sürme + Yürüme + Bisiklet + Araba + Hata, parametreleri tekrar gözden geçirin \ No newline at end of file From 1a1bb9ca90dd5c93fb444ad1ad035dcf231b0bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Tue, 5 Jan 2021 19:56:48 +0000 Subject: [PATCH 15/61] Translated using Weblate (Hungarian) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-hu/strings.xml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 2142695973..a9e91052bd 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -585,7 +585,7 @@ Keresztező utca kijelölése Legközelebbi hasznos létesítmények Térképböngészés - Vezetés + Autóvezetés Kerékpározás Gyaloglás Középen @@ -1292,7 +1292,7 @@ Közeli érdekes helyek (POI) Letöltöd a hiányzó térképeket %1$s (%2$d MB)? Térképböngészés - Autó + Személyautó Kerékpár Gyalogos Ez a bővítmény aktiválja a nyomvonalak rögzítésének és mentésének lehetőségét, ha megnyomja a GPX naplózó gombot a térképképernyőn, valamint képes minden navigációs útvonalat automatikusan egy GPX-fájlba naplózni. @@ -4019,4 +4019,20 @@ Patakok és vízelvezető árkok engedélyezése Időszakos vízfolyások engedélyezése Időszakos vízfolyások engedélyezése + Autóvezetés + Gyaloglás + Kerékpár + Személyautó + Hangutasítások ideje + Online útvonaltervező hozzáadása + Online útvonaltervező szerkesztése + Altípus + Jármű + API-kulcs + Kiszolgáló URL-je + Paraméter megadása + Hagyja üresen, ha nem + Az összes paraméterrel rendelkező URL így néz ki: + Útvonaltervezés kipróbálása + Hiba, ellenőrizze újra a paramétereket \ No newline at end of file From 1db6d38bf356f5338d49d9ac6c4af88164ecef70 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 5 Jan 2021 19:40:49 +0000 Subject: [PATCH 16/61] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-uk/strings.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 0bd95661ef..4e70eb1284 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4024,4 +4024,19 @@ Дозволити потоки та стічні канали Дозволити потоки та стічні канали Голосові підказки + Додати мережний рушій маршрутизації + Змінити мережний рушій маршрутизації + Підтип + Транспортний засіб + Ключ API + URL-адреса сервера + Введіть параметр + Залиште порожнім, якщо ні + URL-адреса з усіма параметрами виглядатиме так: + Тестове обчислення маршруту + Водіння + Пішки + Велосипед + Автомобіль + Помилка, повторно перевірте параметри \ No newline at end of file From 3c1e653e002567d6d60758783ece0b8c92fac3b0 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Tue, 5 Jan 2021 17:43:01 +0000 Subject: [PATCH 17/61] Translated using Weblate (Hebrew) Currently translated at 99.9% (3605 of 3606 strings) --- OsmAnd/res/values-iw/strings.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index 9b60953f9d..f2f971e562 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -4032,4 +4032,19 @@ „ציבורי” משמעו שהעקבות מופיעים באופן ציבורי בעקבות ה־GPS שלך וברישומי עקבות GPS ציבוריים וברישומי מעקב ציבוריים עם חותמות זמן בתצורה גולמית. הנתונים שמוגשים דרך ה־API אינם מפנים אל עמוד העקבות שלך. חותמות הזמן של נקודות המעקב אינן זמינות דרך ה־API של ה־GPS ונקודות המעקב אינן מסודרות בהתאם לזמן שתועדו. „פרטי” משמעות שהעקבות לא תופענה ברישומים ציבוריים אך נקודות מעקב ממתוכן תהיינה זמינות בסדר אקראי דרך ה־API הציבורי של ה־GPS ללא חותמות זמן. זמני הכרזות + הוספת מנוע ניווט מקוון + עריכת מנוע הניווט המקוון + תת־סוג + כלי רכב + מפתח API + כתובת השרת + נא למלא משתנים + להשאיר ריק אם לא + כתובת עם כל המשתנים נראית כך: + בדיקת חישוב מסלול + נהיגה + ברגל + אופנוע + מכונית + שגיאה, נא לבדוק את המשתנים מחדש \ No newline at end of file From 5b49cedd1e6a274f3b61a3bc23528ad18903abed Mon Sep 17 00:00:00 2001 From: letypequividelespoubelles Date: Tue, 5 Jan 2021 22:04:46 +0000 Subject: [PATCH 18/61] Translated using Weblate (French) Currently translated at 99.8% (3876 of 3881 strings) --- OsmAnd/res/values-fr/phrases.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-fr/phrases.xml b/OsmAnd/res/values-fr/phrases.xml index 92e6a64d53..1d225381f7 100644 --- a/OsmAnd/res/values-fr/phrases.xml +++ b/OsmAnd/res/values-fr/phrases.xml @@ -3895,4 +3895,9 @@ Robinet Vaccination : covid19 Vaccination + Tunnel à chauve-souris + Pont à chauve- + Passage à faune + Zone de + Lavoir \ No newline at end of file From 87c3e3b53defa52aad5f40a0970562e846ec53ba Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Tue, 5 Jan 2021 23:58:49 +0000 Subject: [PATCH 19/61] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 2064a07de1..8516bae334 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -4023,4 +4023,19 @@ Permitir vias de água intermitentes Permitir vias de água intermitentes Horários de avisos de voz + Adicionar mecanismo de roteamento online + Editar mecanismo de roteamento online + Subtipo + Veículo + Chave de API + URL do servidor + Digite o parâmetro + Mantenha-o vazio se não + O URL com todos os parâmetros terá a seguinte aparência: + Cálculo da rota de teste + Dirigindo + + Bicicleta + Carro + Erro, verifique novamente os parâmetros \ No newline at end of file From a7612e369d5f1e5283e19ca7a6ab73b713e5a688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Tue, 5 Jan 2021 17:28:37 +0000 Subject: [PATCH 20/61] Translated using Weblate (Turkish) Currently translated at 80.7% (3132 of 3881 strings) --- OsmAnd/res/values-tr/phrases.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-tr/phrases.xml b/OsmAnd/res/values-tr/phrases.xml index 6fef6292b4..cf6117a083 100644 --- a/OsmAnd/res/values-tr/phrases.xml +++ b/OsmAnd/res/values-tr/phrases.xml @@ -944,7 +944,7 @@ Yerel yürüyüş güzergahı Yürüyüş yolu başvurusu Çalışma saatleri - Koleksiyon kez + Toplama zamanları Açıklama Telefon İnternet sitesi @@ -3137,4 +3137,12 @@ Göçmen olmayan vizeleri Askeri denetim noktası Yürüyüş denetim noktası + Dolap türü: sokak aydınlatması + Dolap türü: su yönetimi + Dolap türü: atık + Dolap türü: posta hizmeti + Dolap türü: gaz + Dolap türü: kablo tv + Dolap türü: telefon + Dolap türü: elektrik \ No newline at end of file From 599544e7ba31faf7db06a717e4eb060668b6ca41 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 6 Jan 2021 12:00:17 +0200 Subject: [PATCH 21/61] recovering deleted string value after merge --- OsmAnd/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 492d9d1428..df56f768f2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -4027,6 +4027,6 @@ Prefer routes of this difficulty, although routing over harder or easier pistes is still possible if shorter. Off-piste \'Freeride\' and \'Off-piste\' are unofficial routes and passages. Typically ungroomed, unmaintained and not checked in the evening. Enter at your own risk. - + Voice prompts times From 2ebbcb8a9078d19107c92de76aa8b50194f0b62e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 Jan 2021 13:41:15 +0200 Subject: [PATCH 22/61] fix typo --- OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index b8835ff2c6..b2cef88e80 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -2544,7 +2544,7 @@ public class GPXUtilities { if (maxlat == null) { maxlat = parser.getAttributeValue("", "maxLat"); } - if (maxlat == null) { + if (maxlon == null) { maxlon = parser.getAttributeValue("", "maxLon"); } From 190d33681d87d8f4041df970d455d0bfb0f95e57 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 6 Jan 2021 18:12:18 +0200 Subject: [PATCH 23/61] add amenity field to MenuBuilder; remove excess R.string.poi_around; code reduction; --- OsmAnd/res/values/strings.xml | 1 - .../plus/mapcontextmenu/MenuBuilder.java | 41 ++++--------------- .../builders/AmenityMenuBuilder.java | 7 ++-- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index df56f768f2..4991659469 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,7 +12,6 @@ --> - Nearby POI Copy address Error, recheck parameters Car diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index d4f60024f6..227411a5dc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -94,8 +94,7 @@ public class MenuBuilder { private boolean firstRow; protected boolean matchWidthDivider; protected boolean light; - private long objectId; - private String objectType; + private Amenity amenity; private LatLon latLon; private boolean hidden; private boolean showTitleIfTruncated = true; @@ -238,14 +237,8 @@ public class MenuBuilder { this.showOnlinePhotos = showOnlinePhotos; } - public void setShowNearestWiki(boolean showNearestWiki, long objectId) { - this.objectId = objectId; - this.showNearestWiki = showNearestWiki; - } - - public void setShowNearestPoi(boolean showNearestPoi, String objectType) { - this.objectType = objectType; - this.showNearestPoi = showNearestPoi; + public void setAmenity(Amenity amenity) { + this.amenity = amenity; } public void addMenuPlugin(OsmandPlugin plugin) { @@ -352,7 +345,7 @@ public class MenuBuilder { protected void buildNearestPoiRow(View view) { buildNearestRow(view, nearestPoi, processNearestPoi(), nearestPoi.isEmpty() ? 0 : AmenityMenuController.getRightIconId(nearestPoi.get(0)), - app.getString(R.string.poi_around)); + app.getString(R.string.speak_poi)); } protected void buildNearestRow(View view, List nearestAmenities, boolean process, int iconId, String text) { @@ -1155,9 +1148,7 @@ public class MenuBuilder { TextViewEx button = buildButtonInCollapsableView(context, false, false); String name = poi.getName(preferredMapAppLang, transliterateNames); if (Algorithms.isBlank(name)) { - PoiCategory pc = poi.getType(); - PoiType pt = pc.getPoiTypeByKeyName(poi.getSubType()); - name = pt.getTranslation(); + name = AmenityMenuController.getTypeStr(poi); } button.setText(name); @@ -1228,14 +1219,6 @@ public class MenuBuilder { protected boolean processNearestWiki() { if (showNearestWiki && latLon != null) { nearestWiki = getSortedAmenities(app.getPoiFilters().getTopWikiPoiFilter()); - Long id = objectId; - List wikiList = new ArrayList<>(); - for (Amenity wiki : nearestWiki) { - if (wiki.getId().equals(id)) { - wikiList.add(wiki); - } - } - nearestWiki.removeAll(wikiList); return true; } return false; @@ -1243,16 +1226,9 @@ public class MenuBuilder { protected boolean processNearestPoi() { if (showNearestPoi && latLon != null) { - nearestPoi = getSortedAmenities(app.getPoiFilters().getShowAllPOIFilter()); - Long id = objectId; - String type = objectType; - List poiList = new ArrayList<>(); - for (Amenity poi : nearestPoi) { - if (poi.getId().equals(id) || !Algorithms.stringsEqual(poi.getSubType(), type)) { - poiList.add(poi); - } - } - nearestPoi.removeAll(poiList); + PoiCategory pc = amenity.getType(); + PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType()); + nearestPoi = getSortedAmenities(app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName())); return true; } return false; @@ -1264,6 +1240,7 @@ public class MenuBuilder { latLon.getLatitude(), latLon.getLongitude(), 250); List nearestAmenities = getAmenities(rect, filter); + nearestAmenities.remove(amenity); Collections.sort(nearestAmenities, new Comparator() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index b72c1a60f5..4a31a750e6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -79,8 +79,9 @@ public class AmenityMenuBuilder extends MenuBuilder { public AmenityMenuBuilder(@NonNull MapActivity mapActivity, final @NonNull Amenity amenity) { super(mapActivity); this.amenity = amenity; - setShowNearestWiki(true, amenity.getId()); - setShowNearestPoi(true, amenity.getSubType()); + setAmenity(amenity); + setShowNearestWiki(true); + setShowNearestPoi(true); metricSystem = mapActivity.getMyApplication().getSettings().METRIC_SYSTEM.get(); } @@ -677,7 +678,7 @@ public class AmenityMenuBuilder extends MenuBuilder { if (processNearestPoi() && nearestPoi.size() > 0) { AmenityInfoRow poiInfo = new AmenityInfoRow( - "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.poi_around) + " (" + nearestPoi.size() + ")", true, + "nearest_poi", AmenityMenuController.getRightIconId(amenity), null, app.getString(R.string.speak_poi) + " (" + nearestPoi.size() + ")", true, getCollapsableView(view.getContext(), true, nearestPoi), 0, false, false, false, 1000, null, false, false, false, 0); buildAmenityRow(view, poiInfo); From 8d930b508a7c84004aced50dc6009f9d38696eee Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 6 Jan 2021 18:23:59 +0200 Subject: [PATCH 24/61] fix crash auth without internet connection; fix other crash; --- .../plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java | 6 +++++- .../src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java index d1c9f36e9a..abc5d1f407 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java @@ -138,7 +138,11 @@ public class OsmOAuthAuthorizationAdapter { @Override protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) { - loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken)); + if (requestToken != null) { + loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken)); + } else { + app.showShortToastMessage(app.getString(R.string.internet_not_available)); + } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java index 8db1079b8b..0eed60b924 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java @@ -45,7 +45,11 @@ public class OsmOAuthHelper { } public void authorize(@NonNull String oauthVerifier) { - authorizationAdapter.authorize(oauthVerifier, this); + if (oauthVerifier != null) { + authorizationAdapter.authorize(oauthVerifier, this); + } else { + updateAdapter(); + } } public void resetAuthorization() { From 38249b1122c100b9131a19411fb76fc60199fae3 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Wed, 6 Jan 2021 18:58:50 +0200 Subject: [PATCH 25/61] Fix #10437 (2) --- OsmAnd/res/layout/fragment_help_article.xml | 2 +- .../fragment_wikivoyage_article_dialog.xml | 2 +- OsmAnd/res/layout/help_activity.xml | 3 +- OsmAnd/res/layout/mapillary_web_view.xml | 4 +- OsmAnd/res/layout/print_dialog.xml | 2 +- .../res/layout/wikipedia_dialog_fragment.xml | 2 +- .../ObservableWebView.java | 5 +- OsmAnd/src/net/osmand/AndroidUtils.java | 12 ----- .../osmand/plus/activities/ExitActivity.java | 2 - .../plus/activities/PrintDialogActivity.java | 2 - .../dialogs/HelpArticleDialogFragment.java | 1 - .../builders/cards/AbstractCard.java | 6 ++- .../plus/mapillary/MapillaryImageDialog.java | 1 - .../GpxDescriptionDialogFragment.java | 3 +- .../net/osmand/plus/widgets/WebViewEx.java | 49 +++++++++++++++++++ .../wikipedia/WikipediaDialogFragment.java | 1 - .../WikivoyageArticleDialogFragment.java | 1 - 17 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/widgets/WebViewEx.java diff --git a/OsmAnd/res/layout/fragment_help_article.xml b/OsmAnd/res/layout/fragment_help_article.xml index cd4456a080..bb6e44b2a2 100644 --- a/OsmAnd/res/layout/fragment_help_article.xml +++ b/OsmAnd/res/layout/fragment_help_article.xml @@ -14,7 +14,7 @@ app:theme="?attr/toolbar_theme" android:background="?attr/pstsTabBackground"/> - diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index c001ab748e..76fe893831 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -64,7 +64,7 @@ android:layout_weight="1" android:layout_height="0dp"> - diff --git a/OsmAnd/res/layout/help_activity.xml b/OsmAnd/res/layout/help_activity.xml index 8ae5922aa6..d7f2d97070 100644 --- a/OsmAnd/res/layout/help_activity.xml +++ b/OsmAnd/res/layout/help_activity.xml @@ -4,7 +4,8 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/OsmAnd/res/layout/mapillary_web_view.xml b/OsmAnd/res/layout/mapillary_web_view.xml index 3afc91e2af..3e2459b375 100644 --- a/OsmAnd/res/layout/mapillary_web_view.xml +++ b/OsmAnd/res/layout/mapillary_web_view.xml @@ -4,12 +4,12 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + - diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 91714016cd..ae21c22585 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -74,7 +74,7 @@ android:layout_height="0dp" android:layout_weight="1"> - diff --git a/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/ObservableWebView.java b/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/ObservableWebView.java index 3e023f74a5..30ee12b52b 100644 --- a/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/ObservableWebView.java +++ b/OsmAnd/src/com/github/ksoichiro/android/observablescrollview/ObservableWebView.java @@ -23,12 +23,13 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.webkit.WebView; + +import net.osmand.plus.widgets.WebViewEx; /** * WebView that its scroll position can be observed. */ -public class ObservableWebView extends WebView implements Scrollable { +public class ObservableWebView extends WebViewEx implements Scrollable { // Fields that should be saved onSaveInstanceState private int mPrevScrollY; diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index f1ad8fd72d..545e7b7391 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -968,16 +968,4 @@ public class AndroidUtils { } return null; } - - public static void fixWebViewResetsLocaleToUserDefault(Activity activity) { - // issue details: https://issuetracker.google.com/issues/37113860 - // also see: https://gist.github.com/amake/0ac7724681ac1c178c6f95a5b09f03ce - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - OsmandApplication app = (OsmandApplication) activity.getApplicationContext(); - app.checkPreferredLocale(); - activity.getResources().updateConfiguration( - new Configuration(app.getResources().getConfiguration()), - activity.getResources().getDisplayMetrics()); - } - } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java index 5097a4f0cc..67beabb1ad 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java @@ -1,6 +1,5 @@ package net.osmand.plus.activities; -import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.app.Activity; @@ -15,7 +14,6 @@ public class ExitActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_activity); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); dis = getIntent().getBooleanExtra(DISABLE_SERVICE, true); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java index b2211a639d..0963b4d782 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java @@ -3,7 +3,6 @@ */ package net.osmand.plus.activities; -import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.annotation.SuppressLint; @@ -43,7 +42,6 @@ public class PrintDialogActivity extends ActionBarProgressActivity { getSupportActionBar().setTitle(R.string.print_route); setContentView(R.layout.print_dialog); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); webView = (WebView) findViewById(R.id.printDialogWebview); Intent intent = getIntent(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java index 3c47372356..42a036599c 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java @@ -54,7 +54,6 @@ public class HelpArticleDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_help_article, container, false); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setNavigationIcon(AndroidUtils.getNavigationIconResId(getContext())); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java index 82d935b091..73964b03d1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java @@ -1,6 +1,7 @@ package net.osmand.plus.mapcontextmenu.builders.cards; import android.annotation.SuppressLint; +import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.Intent; @@ -23,6 +24,7 @@ import androidx.core.content.ContextCompat; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.widgets.WebViewEx; public abstract class AbstractCard { @@ -55,7 +57,7 @@ public abstract class AbstractCard { @SuppressLint("SetJavaScriptEnabled") @SuppressWarnings("deprecation") - protected static void openUrl(@NonNull Context ctx, + protected static void openUrl(@NonNull Activity ctx, @NonNull OsmandApplication app, @Nullable String title, @NonNull String url, @@ -90,7 +92,7 @@ public abstract class AbstractCard { } }); - final WebView wv = new WebView(ctx); + final WebView wv = new WebViewEx(ctx); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java index d20f03f4fe..7b9cd23b69 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java @@ -220,7 +220,6 @@ public class MapillaryImageDialog extends ContextMenuCardDialog { @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) private View getWebView() { View view = getMapActivity().getLayoutInflater().inflate(R.layout.mapillary_web_view, null); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(getMapActivity()); final WebView webView = view.findViewById(R.id.webView); webView.setBackgroundColor(Color.argb(1, 0, 0, 0)); final View noInternetView = view.findViewById(R.id.mapillaryNoInternetLayout); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GpxDescriptionDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/GpxDescriptionDialogFragment.java index 7cab05bc3a..aa17926449 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/GpxDescriptionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/GpxDescriptionDialogFragment.java @@ -19,6 +19,7 @@ import com.google.android.material.appbar.AppBarLayout; import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndDialogFragment; +import net.osmand.plus.widgets.WebViewEx; public class GpxDescriptionDialogFragment extends BaseOsmAndDialogFragment { @@ -48,7 +49,7 @@ public class GpxDescriptionDialogFragment extends BaseOsmAndDialogFragment { AppBarLayout appBar = new AppBarLayout(ctx); appBar.addView(topBar); - WebView webView = new WebView(ctx); + WebView webView = new WebViewEx(ctx); webView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); webView.getSettings().setTextZoom((int) (getResources().getConfiguration().fontScale * 100f)); Bundle args = getArguments(); diff --git a/OsmAnd/src/net/osmand/plus/widgets/WebViewEx.java b/OsmAnd/src/net/osmand/plus/widgets/WebViewEx.java new file mode 100644 index 0000000000..c83e1110cb --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/widgets/WebViewEx.java @@ -0,0 +1,49 @@ +package net.osmand.plus.widgets; + +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.util.AttributeSet; +import android.webkit.WebView; + +import net.osmand.plus.OsmandApplication; + +public class WebViewEx extends WebView { + + public WebViewEx(Context context) { + super(context); + fixWebViewResetsLocaleToUserDefault(context); + } + + public WebViewEx(Context context, AttributeSet attrs) { + super(context, attrs); + fixWebViewResetsLocaleToUserDefault(context); + } + + public WebViewEx(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + fixWebViewResetsLocaleToUserDefault(context); + } + + public WebViewEx(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + fixWebViewResetsLocaleToUserDefault(context); + } + + public WebViewEx(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) { + super(context, attrs, defStyleAttr, privateBrowsing); + fixWebViewResetsLocaleToUserDefault(context); + } + + public void fixWebViewResetsLocaleToUserDefault(Context ctx) { + // issue details: https://issuetracker.google.com/issues/37113860 + // also see: https://gist.github.com/amake/0ac7724681ac1c178c6f95a5b09f03ce + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + OsmandApplication app = (OsmandApplication) ctx.getApplicationContext(); + app.checkPreferredLocale(); + ctx.getResources().updateConfiguration( + new Configuration(app.getResources().getConfiguration()), + ctx.getResources().getDisplayMetrics()); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 1ea89040cd..17a8500361 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -72,7 +72,6 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index bc322b31fe..9303fb7b84 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -91,7 +91,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); - AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); From 7a59047a5df0d23241e4777db0ac5538a6a60c16 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 Jan 2021 19:42:13 +0200 Subject: [PATCH 26/61] Fix nearest wiki --- .../plus/mapcontextmenu/MenuBuilder.java | 46 +++++++++++++------ .../builders/AmenityMenuBuilder.java | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 227411a5dc..d11d27d34c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -29,12 +29,14 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; + import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.data.Amenity; @@ -44,7 +46,12 @@ import net.osmand.data.QuadRect; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; import net.osmand.osm.io.NetworkUtils; -import net.osmand.plus.*; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.Version; import net.osmand.plus.activities.ActivityResultListener; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; @@ -68,6 +75,7 @@ import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.tools.ClickableSpanTouchListener; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; + import org.apache.commons.logging.Log; import org.openplacereviews.opendb.util.exception.FailedVerificationException; @@ -75,7 +83,13 @@ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; @@ -214,8 +228,8 @@ public class MenuBuilder { } public boolean isShowNearestPoi() { - return showNearestPoi; - } + return showNearestPoi; + } public void setShowNearestWiki(boolean showNearestWiki) { this.showNearestWiki = showNearestWiki; @@ -1217,27 +1231,31 @@ public class MenuBuilder { } protected boolean processNearestWiki() { - if (showNearestWiki && latLon != null) { - nearestWiki = getSortedAmenities(app.getPoiFilters().getTopWikiPoiFilter()); - return true; + if (showNearestWiki && latLon != null && amenity != null) { + PoiUIFilter filter = app.getPoiFilters().getTopWikiPoiFilter(); + if (filter != null) { + nearestWiki = getSortedAmenities(filter, latLon); + return true; + } } return false; } protected boolean processNearestPoi() { - if (showNearestPoi && latLon != null) { + if (showNearestPoi && latLon != null && amenity != null) { PoiCategory pc = amenity.getType(); PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType()); - nearestPoi = getSortedAmenities(app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName())); - return true; + PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName()); + if (filter != null) { + nearestPoi = getSortedAmenities(filter, latLon); + return true; + } } return false; } - private List getSortedAmenities(PoiUIFilter filter) { - final LatLon latLon = getLatLon(); - QuadRect rect = MapUtils.calculateLatLonBbox( - latLon.getLatitude(), latLon.getLongitude(), 250); + private List getSortedAmenities(PoiUIFilter filter, final LatLon latLon) { + QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250); List nearestAmenities = getAmenities(rect, filter); nearestAmenities.remove(amenity); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 4a31a750e6..c0db653e3e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -81,7 +81,7 @@ public class AmenityMenuBuilder extends MenuBuilder { this.amenity = amenity; setAmenity(amenity); setShowNearestWiki(true); - setShowNearestPoi(true); + setShowNearestPoi(!amenity.getType().isWiki()); metricSystem = mapActivity.getMyApplication().getSettings().METRIC_SYSTEM.get(); } From f25a6bc001e46d1c3522374bfe7d1929720b78a7 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Wed, 6 Jan 2021 08:33:54 +0000 Subject: [PATCH 27/61] Translated using Weblate (French) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-fr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 633470a815..dd175df3ba 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4019,4 +4019,7 @@ Vélo Automobile Erreur, vérifiez les paramètres + Ajouter un moteur de routage en ligne + Modifier le moteur de routage en ligne + L\'URL avec tous les paramètres sera de la forme : \ No newline at end of file From c39d62d441ccf063c51821c437db00dbb33aa4cc Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 6 Jan 2021 20:00:22 +0000 Subject: [PATCH 28/61] Translated using Weblate (German) Currently translated at 99.9% (3603 of 3606 strings) --- OsmAnd/res/values-de/strings.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 870673e61e..19175d85be 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -4032,4 +4032,16 @@ Gewässer erlauben, die nicht ständig Wasser führen Gewässer erlauben, die nicht ständig Wasser führen Zeiten der Sprachansagen + Online Routenplaner hinzufügen + Online Routenplaner bearbeiten + Fahrzeug + API Schlüssel + Server URL + Parameter eingeben + Die URL mit allen Parametern wird so aussehen: + Routenberechnung testen + Zu Fuß + Fahrrad + Auto + Fehler, Parameter erneut prüfen \ No newline at end of file From 05767e3b7a09d34e90645d5f6a464a65bf3e993e Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Thu, 7 Jan 2021 00:34:52 +0000 Subject: [PATCH 29/61] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-uk/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 4e70eb1284..dfe36591a5 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4031,7 +4031,7 @@ Ключ API URL-адреса сервера Введіть параметр - Залиште порожнім, якщо ні + Залиште порожнім, якщо не маєте ключа API URL-адреса з усіма параметрами виглядатиме так: Тестове обчислення маршруту Водіння From b318a7cdaf8a10baf79e6ca72286243ec90bceaa Mon Sep 17 00:00:00 2001 From: Temuri Doghonadze Date: Wed, 6 Jan 2021 07:15:23 +0000 Subject: [PATCH 30/61] Translated using Weblate (Georgian) Currently translated at 64.8% (2340 of 3606 strings) --- OsmAnd/res/values-ka/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ka/strings.xml b/OsmAnd/res/values-ka/strings.xml index a39fb02b7b..723edda859 100644 --- a/OsmAnd/res/values-ka/strings.xml +++ b/OsmAnd/res/values-ka/strings.xml @@ -2350,4 +2350,6 @@ ბაზური პროფილი ტიპი: %s რეჟიმი: %s + საცალფეხო გზების არიდება + საცალფეხო ფზების არიდება \ No newline at end of file From 01165f370afb78f25a9a2708b143cbd58e524c02 Mon Sep 17 00:00:00 2001 From: ace shadow Date: Wed, 6 Jan 2021 23:18:04 +0000 Subject: [PATCH 31/61] Translated using Weblate (Slovak) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-sk/strings.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 27d1976a65..3af8231c15 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -4028,4 +4028,19 @@ Povoliť dočasné vodné toky Povoliť dočasné vodné toky Časy hlasových pokynov + Pridať online navigačnú službu + Upraviť online navigačnú službu + Podtyp + Vozidlo + Kľúč API + Adresa URL serveru + Zadajte parameter + Ak nie, ponechajte prázdne + Adresa URL so všetkými parametrami bude vyzerať nasledovne: + Vyskúšať výpočet trasy + Vedenie vozidla + Chôdza + Bicykel + Auto + Chyba, skontrolujte parametre \ No newline at end of file From 7f4340a85a8a97419822503d457166ccb18e32b1 Mon Sep 17 00:00:00 2001 From: iman Date: Wed, 6 Jan 2021 17:44:51 +0000 Subject: [PATCH 32/61] Translated using Weblate (Persian) Currently translated at 99.3% (3581 of 3606 strings) --- OsmAnd/res/values-fa/strings.xml | 81 ++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index fe55b9e35f..7b7362011a 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -163,7 +163,7 @@ پشتیبان‌گیری در قالب تغییر OSM حذف نقطه استفاده از پالایهٔ Kalman - حذف مسیر + کنارگذاشتن مسیر؟ هیچ‌کدام افزونهٔ دراپ‌باکس برای فیلم‌برداری از ضبط‌کنندهٔ سیستم استفاده شود. @@ -644,7 +644,7 @@ توقف اعلام خودکار برای نمایش ردها و مسیرها از رنگ‌های شب‌نما استفاده شود. ویرایش آفلاین - ویرایش‌ها را همیشه آفلاین انجام می‌دهم. + اگر ویرایش آفلاین فعال باشد، تغییرات ابتدا روی دستگاه ذخیره می‌شود و با درخواست شما آپلود می‌گردد. در غیر این صورت دردَم آپلود خواهد شد. در حال آپلود… تعداد {0} یادداشت/POI آپلود شد تغییراتی که به‌وسیلهٔ برنامه روی POIها انجام می‌دهید روی نقشه‌های دانلود‌شده تأثیری ندارد. تغییرات روی فایل دیگری در دستگاه ذخیره می‌شود. @@ -1687,7 +1687,7 @@ بیان‌کردن جهت مقصد با لرزش. مسیریابی با استفاده از به‌روزرسانی‌های OsmAnd Live فعال شود. مسیریابی با OsmAnd Live - مقصد تنظیم نشده + افزونهٔ قابلیت دسترسی: مقصدی تنظیم نشده سویهٔ مغناطیسی سویهٔ نسبی اگر از مسیر خارج شدم، مسیر تازه‌ای پیدا نکن @@ -2151,7 +2151,7 @@ تعداد مشارکت‌کنندگان تعداد ویرایش‌ها گزارش برای - در نام فایل از نویسهٔ غیرمجاز استفاده شده است + نویسهٔ غیرمجاز در نام فایل کنش فوری کنش %d صفحهٔ %d @@ -2301,7 +2301,7 @@ دکمه‌ای برای آشکار/پنهان کردن یادداشت‌های OSM بر روی نقشه. مرتب‌شده بر اساس مسافت جست‌وجو در علاقه‌مندی‌ها - «لایهٔ سایه‌روشن» را دانلود کنید تا سایه‌های عمودی را ببینید. + لایهٔ «سایه‌روشن» را دانلود کنید تا سایه‌زنی‌های عمودی را ببینید. افزونهٔ «منحنی‌های میزان» را نصب کنید تا طبقه‌بندی عمودی محدوده‌ها را ببینید. از این زوم پنهان شود نقشهٔ «منحنی میزان» را برای استفاده در این منطقه دانلود کنید. @@ -2664,7 +2664,7 @@ کپی موقعیت/نام POI مکان بی‌نام دیدن یادداشت‌های بسته - پنهان/آشکارکردن یادداشت‌های OSM. + پنهان یا آشکارکردن یادداشت‌های OSM. ‏GPX - مناسب برای استفاده در JOSM یا سایر ویرایشگرهای OSM. ‏OSC - مناسب برای استفاده در OSM. فایل GPX @@ -3188,9 +3188,9 @@ محدوده‌های کاهش آلودگی هوای شهر را روی نقشه نشان بده. روی مسیریابی اثر نمی‌گذارد. محدوده‌های کاهش در نظر گرفتن محدودیت‌های موقت در مسیریابی - اسکی آلپاین/دان‌هیل + اسکی آلپاین و دانهیل سراشیبی‌های اسکی آلپاین یا دان‌هیل و دسترسی به بالابرهای اسکی. - اسکی کراس/نوردیک + اسکی کراس‌کانتری و نوردیک مسیرهای اسکی کراس یا نوردیک. شکست باز کن @@ -3456,7 +3456,7 @@ امتیاز بدهید ناوبری، صحت ردنگاری اندازهٔ عکس، کیفیت صدا و ویدئو - ثبت ورود، گذرواژه، ویرایش آفلاین + نام کاربری، گذرواژه، ویرایش آفلاین انتخاب نماد، رنگ و نام ردیابی آنلاین صحت ردنگاری @@ -3464,7 +3464,7 @@ یادداشت‌های عکسی محاسبهٔ مجدد مسیر نام کاربری و گذرواژه - این تنظیمات افزونه، سراسری است و روی همهٔ پروفایل‌ها به کار گرفته می‌شود. + این تنظیمات افزونه، سراسری است و روی همهٔ پروفایل‌ها به کار گرفته می‌شود ویرایش OSM OSM نمادی که هنگام حرکت یا ناوبری نمایش داده می‌شود. @@ -3594,7 +3594,7 @@ ناهمواری‌ها نقشهٔ سایه‌روشن که شیب‌ها، بلندی‌ها و پستی‌ها را با استفاده از سایه‌های تیره نمایان می‌کند. کمینه و بیشینهٔ زوم برای نمایش لایه را مشخص کنید. - برای مشاهدهٔ سایه‌روشن‌ها روی نقشه باید نقشهٔ دیگری را نیز دانلود کنید. + "باید نقشهٔ دیگری را نیز دانلود کنید تا سایه‌روشن‌ها را روی نقشه ببینید." برای مشاهدهٔ شیب‌ها روی نقشه باید نقشهٔ دیگری را نیز دانلود کنید. دربارهٔ شیب‌ها می‌توانید در %1$s بیشتر بخوانید. شفافیت @@ -3604,7 +3604,7 @@ سایه‌روشن %1$s از %2$s شیب‌ها - آشکار/پنهان کردن ناهمواری‌ها + آشکار یا پنهان کردن ناهمواری‌ها پنهان‌کردن ناهمواری‌ها نمایش ناهمواری‌ها دکمه‌ای برای آشکار یا پنهان کردن لایهٔ ناهمواری‌ها روی نقشه. @@ -3717,12 +3717,12 @@ \n \n بازگشت به ویرایش - ایجاد / ویرایش POI - افزودن / ویرایش علاقه‌مندی + ایجاد یا ویرایش POI + افزودن یا ویرایش علاقه‌مندی برای دسترسی به این کنش‌ها می‌توانید روی دکمهٔ «%1$s» بزنید. مخفی‌کردن حمل‌ونقل عمومی نمایش حمل‌ونقل عمومی - آشکار/پنهان کردن حمل‌ونقل عمومی + آشکار یا پنهان کردن حمل‌ونقل عمومی دکمه‌ای برای آشکار یا پنهان کردن حمل‌ونقل عمومی روی نقشه. با لمس دکمهٔ عملیاتی بین پروفایل‌های انتخاب‌شده جابه‌جا شوید. افزودن پروفایل @@ -3823,7 +3823,7 @@ حذف نزدیک‌ترین مقصد لطفاً نام نقطه را بنویسید دانلود نقشه‌های ویکی‌پدیا - از ویکی‌پدیا دربارهٔ نقاط توجه اطلاعات کسب کنید؛ مانند یک راهنمای آفلاین جیبی. کافی است افزونهٔ ویکی‌پدیا را فعال کنید و از مقاله‌های مربوط به چیزهای دوروبرتان لذت ببرید. + دربارهٔ نقاط توجه، از ویکی‌پدیا اطلاعات کسب کنید. یک راهنمای آفلاینِ جیبی که مقاله‌هایی دربارهٔ مکان‌ها و مقصدها دارد. صندلی چرخ‌دار یادداشت اُاِس‌اِمی بسته نقطهٔ اضافه‌شده روی نقشه دیده نمی‌شود، زیرا گروه انتخاب‌شده پنهان است. آن را در «%s» پیدا می‌کنید. @@ -3864,11 +3864,11 @@ \n حذفِ قبل حذفِ بعد - تغییر نوع مسیرِ بعد آن - تغییر نوع مسیرِ قبل آن + تغییر نوع مسیرِ بعد + تغییر نوع مسیرِ قبل تک‌رنگ طول وسیلهٔ نقلیهٔ خود را مشخص کنید. ممکن است محدودیت‌های مسیر برای وسایل نقلیهٔ طویل اِعمال شود. - مقصد کنونی مسیر حذف خواهد شد. اگر این قرار است مقصد باشد، ناوبری متوقف می‌شود. + مقصد بعدیِ مسیر شما را حذف خواهد کرد. البته اگر مقصد نهایی باشد، ناوبری را متوقف می‌کند. افزودن به یک رد ذخیره به‌عنوان رد جدید برعکس‌کردن مسیر @@ -3886,7 +3886,7 @@ پروفایل ناوبری یک فایل رد انتخاب کنید تا پارهٔ جدید را به آن بیفزایید. تصاویر نمای خیابان - آیا می‌خواهید خارج شوید و همهٔ تغییرات مسیر طراحی‌شده را از بین ببرید؟ + آیا می‌خواهید همهٔ تغییرات در مسیر طراحی‌شده از بین برود؟ اگر برعکس حرکت کردم ابتدای رد انتخاب فایل رد برای دنبال‌کردن @@ -3963,15 +3963,15 @@ \nنمودار پس از بازمحاسبهٔ مسیر فراهم می‌شود. %1$s — %2$s دست‌کم دو نقطه اضافه کنید - ثبت ورود در اوپن‌استریت‌مپ - ثبت ورود در OpenStreetMap.org + ورود به اوپن‌استریت‌مپ + ورود به OpenStreetMap.org ثبت ورود از طریق اوپن‌استریت‌مپ - برای آپلود تغییرات جدید باید ثبت ورود (login) کنید. + برای آپلود تغییرات جدید باید وارد شوید (login). \n -\nبرای ثبت ورود می‌توانید از روش امن OAuth یا روش نام کاربری و گذرواژه استفاده کنید. +\nبرای ورود می‌توانید از روش امن OAuth یا روش نام کاربری و گذرواژه استفاده کنید. استفاده از نام کاربری و گذرواژه حساب - ثبت ورود + ورود مدیریت اشتراک روی دکمه بزنید و یک شیوهٔ پرداخت در گوگل‌پلی تنظیم کنید تا اشتراک خود را اصلاح نمایید. تاریخچهٔ نشانه‌ها @@ -4006,4 +4006,35 @@ افزودن یک بخش جدید نمایهٔ OsmAnd نمایهٔ کاربر + زمان‌های پیام‌های گفتاری + MGRS + MGRS + ‏OsmAnd از MGRS استفاده می‌کند که شبیه قالب UTM NATO است. + سپاسگزاریم که Contour lines را خریدید + برچسب‌ها را بنویسید و با کاما جدا کنید. + بستن یادداشت OSM + نظردادن به یادداشت OSM + می‌توانید با روش ایمن OAuth وارد شوید یا از نام‌کاربری و گذرواژه‌تان استفاده کنید. + قایق‌موتوری + آپلود عکس ناموفق بود، لطفاً بعداً دوباره امتحان کنید + انتخاب تصویر + منابع + اندازهٔ تخمینی فایل + دادهٔ موردنظر برای برون‌برد در فایل را انتخاب کنید. + برای درون‌برد لازم است + برعکس‌کردن همهٔ نقطه‌ها + پروفایلِ هنگام شروع برنامه را انتخاب کنید. + آخرین استفاده + افزودن موتور مسیریابی آنلاین + ویرایش موتور مسیریابی آنلاین + وسیله نقلیه + کلید API + پارامتر را وارد کنید + ‏URL با همهٔ پارامترها شبیه این است: + آزمایش محاسبهٔ مسیر + رانندگی + پا + دوچرخه + خودرو + خطا، پارامترها را بازبینی کنید \ No newline at end of file From f65d0a2deeeb627afcdce32bd80ee6503c71054b Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Wed, 6 Jan 2021 08:38:37 +0000 Subject: [PATCH 33/61] Translated using Weblate (French) Currently translated at 99.9% (3880 of 3881 strings) --- OsmAnd/res/values-fr/phrases.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-fr/phrases.xml b/OsmAnd/res/values-fr/phrases.xml index 1d225381f7..83c34749e1 100644 --- a/OsmAnd/res/values-fr/phrases.xml +++ b/OsmAnd/res/values-fr/phrases.xml @@ -3896,8 +3896,11 @@ Vaccination : covid19 Vaccination Tunnel à chauve-souris - Pont à chauve- - Passage à faune - Zone de + Pont à chauve-souris + Passage de faune + Zone de baignade Lavoir + Station de traitement des déchets + Pont de levage + Poste de garde forestier \ No newline at end of file From 41eefeda5dfb4654d1d4c6cb07c41e16b32b74a9 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Wed, 6 Jan 2021 14:25:29 +0000 Subject: [PATCH 34/61] Translated using Weblate (Esperanto) Currently translated at 100.0% (3606 of 3606 strings) --- OsmAnd/res/values-eo/strings.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index bf083e4542..2c1f95858b 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4028,4 +4028,19 @@ Permesi navigi per periode sekiĝantaj akvovojoj Permesi sezonajn akvovojojn Tempoj de voĉaj anoncoj + Aldoni enretan navigilon + Redakti enretan navigilon + Subspeco + Veturilo + API-ŝlosilo + Ligilo al servilo + Enigu parametron + Se malnecesa, enigu nenion + Ligilo kun ĉiuj parametroj aspektos kiel tiu ĉi: + Stirado + Testi kalkuli kurson + Piediranto + Biciklo + Aŭtomobilo + Eraro, rekontrolu parametrojn \ No newline at end of file From 301efb0252840cee6d50b683ba89231e21adb0c6 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Thu, 7 Jan 2021 06:24:05 +0000 Subject: [PATCH 35/61] Translated using Weblate (French) Currently translated at 100.0% (3607 of 3607 strings) --- OsmAnd/res/values-fr/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index dd175df3ba..008a82ffa3 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4022,4 +4022,5 @@ Ajouter un moteur de routage en ligne Modifier le moteur de routage en ligne L\'URL avec tous les paramètres sera de la forme : + Copier l\'adresse \ No newline at end of file From 5afed63b53ab7a9aee0ba49b44d80d5565babaf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Thu, 7 Jan 2021 04:41:49 +0000 Subject: [PATCH 36/61] Translated using Weblate (Turkish) Currently translated at 100.0% (3607 of 3607 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 fccc6158e3..2e1ed5e651 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -3998,4 +3998,5 @@ Bisiklet Araba Hata, parametreleri tekrar gözden geçirin + Adresi kopyala \ No newline at end of file From cbcee006be2c1785ed0f1d28105c60e390c14270 Mon Sep 17 00:00:00 2001 From: Temuri Doghonadze Date: Thu, 7 Jan 2021 04:37:31 +0000 Subject: [PATCH 37/61] Translated using Weblate (Georgian) Currently translated at 64.9% (2344 of 3607 strings) --- OsmAnd/res/values-ka/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-ka/strings.xml b/OsmAnd/res/values-ka/strings.xml index 723edda859..720fa5a374 100644 --- a/OsmAnd/res/values-ka/strings.xml +++ b/OsmAnd/res/values-ka/strings.xml @@ -2352,4 +2352,8 @@ რეჟიმი: %s საცალფეხო გზების არიდება საცალფეხო ფზების არიდება + შენახულია + ბოლო ცვლილება + სახელი: ჰ-ა + სახელი: ა-ჰ \ No newline at end of file From 2487e51a58d5362cd6b69ddbae4591051c2751a3 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Thu, 7 Jan 2021 03:07:00 +0000 Subject: [PATCH 38/61] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3607 of 3607 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 115f04c6d7..9e432f64ed 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -4023,4 +4023,20 @@ 允許間歇水路 允許間歇水路 語音提示時間 + 新增線上路線引擎 + 編輯線上路線引擎 + 子類型 + 車輛 + API 金鑰 + 伺服器 URL + 輸入參數 + 否則請保持空白 + 帶有所有參數的 URL 如下所示: + 測試路線計算 + 駕駛 + 步行 + 自行車 + 汽車 + 錯誤,重新檢查參數 + 複製地址 \ No newline at end of file From 0361b6b773f3009344941d1cd4484882a80ad04b Mon Sep 17 00:00:00 2001 From: Kseniia Date: Thu, 7 Jan 2021 12:11:49 +0200 Subject: [PATCH 39/61] add conditions for restrictions via ways --- .../net/osmand/router/BinaryRoutePlanner.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 6b8926b413..e641af4145 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -29,7 +29,7 @@ public class BinaryRoutePlanner { protected static final Log log = PlatformUtil.getLog(BinaryRoutePlanner.class); private static final int ROUTE_POINTS = 11; - private static final boolean TRACE_ROUTING = false; + private static final boolean TRACE_ROUTING = true; public static double squareRootDist(int x1, int y1, int x2, int y2) { @@ -647,26 +647,39 @@ public class BinaryRoutePlanner { int type = -1; if (!reverseWay) { for (int i = 0; i < road.getRestrictionLength(); i++) { + int rt = road.getRestrictionType(i); + long rv = road.getRestrictionVia(i); if (road.getRestrictionId(i) == next.road.id) { - if(!via || road.getRestrictionVia(i) == viaId) { - type = road.getRestrictionType(i); + if (!via || rv == viaId) { + type = rt; break; } } + if (rv == viaId && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON; + break; + } } } else { for (int i = 0; i < next.road.getRestrictionLength(); i++) { int rt = next.road.getRestrictionType(i); + long rv = next.road.getRestrictionVia(i); long restrictedTo = next.road.getRestrictionId(i); if (restrictedTo == road.id) { - if(!via || next.road.getRestrictionVia(i) == viaId) { + if (!via || rv == viaId) { type = rt; break; } } + if (rv == viaId && rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON; + break; + } + // Check if there is restriction only to the other than current road - if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN + if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN + || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { // check if that restriction applies to considered junk RouteSegment foundNext = inputNext; @@ -674,6 +687,8 @@ public class BinaryRoutePlanner { if (foundNext.getRoad().id == restrictedTo) { break; } + + foundNext = foundNext.next; } if (foundNext != null) { @@ -682,7 +697,7 @@ public class BinaryRoutePlanner { } } } - if (type == REVERSE_WAY_RESTRICTION_ONLY) { + if (type == REVERSE_WAY_RESTRICTION_ONLY) { // next = next.next; continue; } else if (type == -1 && exclusiveRestriction) { // next = next.next; continue; From 2c802717a91aaed431a88fbaa84c667587915320 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Thu, 7 Jan 2021 12:15:51 +0200 Subject: [PATCH 40/61] add conditions for restrictions via ways --- .../main/java/net/osmand/router/BinaryRoutePlanner.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index e641af4145..ebfe18940c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -29,7 +29,7 @@ public class BinaryRoutePlanner { protected static final Log log = PlatformUtil.getLog(BinaryRoutePlanner.class); private static final int ROUTE_POINTS = 11; - private static final boolean TRACE_ROUTING = true; + private static final boolean TRACE_ROUTING = false; public static double squareRootDist(int x1, int y1, int x2, int y2) { @@ -678,8 +678,7 @@ public class BinaryRoutePlanner { } // Check if there is restriction only to the other than current road - if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN - || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN + if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN || rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { // check if that restriction applies to considered junk RouteSegment foundNext = inputNext; @@ -687,8 +686,6 @@ public class BinaryRoutePlanner { if (foundNext.getRoad().id == restrictedTo) { break; } - - foundNext = foundNext.next; } if (foundNext != null) { @@ -697,7 +694,7 @@ public class BinaryRoutePlanner { } } } - if (type == REVERSE_WAY_RESTRICTION_ONLY) { + if (type == REVERSE_WAY_RESTRICTION_ONLY) { // next = next.next; continue; } else if (type == -1 && exclusiveRestriction) { // next = next.next; continue; From 31ffca2547238809ec0818bbbae416178afc2352 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 7 Jan 2021 11:23:24 +0100 Subject: [PATCH 41/61] Formatting --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 9 ++++----- .../osmand/plus/routing/data/AnnounceTimeDistances.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 2d35556d84..a19ebd3023 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -673,15 +673,15 @@ public class OsmAndLocationProvider implements SensorEventListener { private void stopLocationRequests() { LocationManager service = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE); - if(gpsStatusListener != null) { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + if (gpsStatusListener != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { service.unregisterGnssStatusCallback((GnssStatus.Callback) gpsStatusListener); } else { service.removeGpsStatusListener((Listener) gpsStatusListener); } } service.removeUpdates(gpsListener); - while(!networkListeners.isEmpty()) { + while (!networkListeners.isEmpty()) { service.removeUpdates(networkListeners.poll()); } } @@ -812,8 +812,7 @@ public class OsmAndLocationProvider implements SensorEventListener { setLocation(location); } - private void setLocation(net.osmand.Location location) { - if (location == null) { + private void setLocation(net.osmand.Location location) { if (location == null) { updateGPSInfo(null); } diff --git a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java index bc00ae7833..497f237158 100644 --- a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java +++ b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java @@ -73,7 +73,7 @@ public class AnnounceTimeDistances { // Do not play prepare: for pedestrian and slow transport // same check as speed < 150/(90-22) m/s = 2.2 m/s = 8 km/h - // if (DEFAULT_SPEED < 2.3) { + // if (DEFAULT_SPEED < 2.3) { if (PREPARE_DISTANCE_END - TURN_IN_DISTANCE < 150) { PREPARE_DISTANCE_END = PREPARE_DISTANCE * 2; } From 6e584b4913a868e7f317c18fbe8ee5ec060e7b2e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 7 Jan 2021 11:28:53 +0100 Subject: [PATCH 42/61] Fix plan route direction --- .../src/test/java/net/osmand/router/RouteTestingTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java index 06e6ef8fda..612cc4b882 100644 --- a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java @@ -78,6 +78,9 @@ public class RouteTestingTest { } RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params); + if (params.containsKey("planRoadDirection")) { + config.planRoadDirection = Integer.parseInt(params.get("planRoadDirection")); + } RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders, RoutePlannerFrontEnd.RouteCalculationMode.NORMAL); ctx.leftSideNavigation = false; From d9e76169fe0166f7d0bfc38aab76d82f93e0fcc9 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 7 Jan 2021 11:52:50 +0100 Subject: [PATCH 43/61] Make tests to go all possible combinations --- .../net/osmand/router/RouteTestingTest.java | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java index 612cc4b882..0a0601b41a 100644 --- a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java @@ -15,13 +15,11 @@ import java.util.TreeSet; import net.osmand.binary.BinaryMapIndexReader; -import net.osmand.data.LatLon; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -76,44 +74,52 @@ public class RouteTestingTest { } else { binaryMapIndexReaders = new BinaryMapIndexReader[]{new BinaryMapIndexReader(raf, new File(fl))}; } - RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car", - RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params); - if (params.containsKey("planRoadDirection")) { - config.planRoadDirection = Integer.parseInt(params.get("planRoadDirection")); - } - RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders, - RoutePlannerFrontEnd.RouteCalculationMode.NORMAL); - ctx.leftSideNavigation = false; - List routeSegments = fe.searchRoute(ctx, te.getStartPoint(), te.getEndPoint(), te.getTransitPoint()); - Set reachedSegments = new TreeSet(); - Assert.assertNotNull(routeSegments); - int prevSegment = -1; - for (int i = 0; i <= routeSegments.size(); i++) { - if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) { - if (prevSegment >= 0) { - String name = routeSegments.get(prevSegment).getDescription(); - long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (RouteResultPreparation.SHIFT_ID); - System.out.println("segmentId: " + segmentId + " description: " + name); + + for (int planRoadDirection = -1; planRoadDirection <= 1; planRoadDirection++) { + if (params.containsKey("onlyPlanRoadDirection")) { + if (!params.get("onlyPlanRoadDirection").equals(planRoadDirection + "")) { + continue; } - prevSegment = i; } - if (i < routeSegments.size()) { - reachedSegments.add(routeSegments.get(i).getObject().getId() >> (RouteResultPreparation.SHIFT_ID)); - } - } - Map expectedResults = te.getExpectedResults(); - Iterator> it = expectedResults.entrySet().iterator(); - while (it.hasNext()) { - Entry es = it.next(); - if (es.getValue().equals("false")) { - Assert.assertTrue("Expected segment " + (es.getKey()) + " was wrongly reached in route segments " - + reachedSegments.toString(), !reachedSegments.contains(es.getKey())); - } else { - Assert.assertTrue("Expected segment " + (es.getKey()) + " weren't reached in route segments " - + reachedSegments.toString(), reachedSegments.contains(es.getKey())); - } - } + RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car", + RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params); + config.planRoadDirection = planRoadDirection; + RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders, + RoutePlannerFrontEnd.RouteCalculationMode.NORMAL); + ctx.leftSideNavigation = false; + List routeSegments = fe.searchRoute(ctx, te.getStartPoint(), te.getEndPoint(), + te.getTransitPoint()); + Set reachedSegments = new TreeSet(); + Assert.assertNotNull(routeSegments); + int prevSegment = -1; + for (int i = 0; i <= routeSegments.size(); i++) { + if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) { + if (prevSegment >= 0) { + String name = routeSegments.get(prevSegment).getDescription(); + long segmentId = routeSegments.get(prevSegment).getObject() + .getId() >> (RouteResultPreparation.SHIFT_ID); + System.out.println("segmentId: " + segmentId + " description: " + name); + } + prevSegment = i; + } + if (i < routeSegments.size()) { + reachedSegments.add(routeSegments.get(i).getObject().getId() >> (RouteResultPreparation.SHIFT_ID)); + } + } + Map expectedResults = te.getExpectedResults(); + Iterator> it = expectedResults.entrySet().iterator(); + while (it.hasNext()) { + Entry es = it.next(); + if (es.getValue().equals("false")) { + Assert.assertTrue("Expected segment " + (es.getKey()) + " was wrongly reached in route segments " + + reachedSegments.toString(), !reachedSegments.contains(es.getKey())); + } else { + Assert.assertTrue("Expected segment " + (es.getKey()) + " weren't reached in route segments " + + reachedSegments.toString(), reachedSegments.contains(es.getKey())); + } + } + } } } From 3f731c4e508af965f25d044d837363fb3ea17970 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 7 Jan 2021 12:06:35 +0100 Subject: [PATCH 44/61] Fix tests --- .../src/test/java/net/osmand/router/RouteTestingTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java index 0a0601b41a..65b4eb74a5 100644 --- a/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/router/RouteTestingTest.java @@ -76,8 +76,8 @@ public class RouteTestingTest { } for (int planRoadDirection = -1; planRoadDirection <= 1; planRoadDirection++) { - if (params.containsKey("onlyPlanRoadDirection")) { - if (!params.get("onlyPlanRoadDirection").equals(planRoadDirection + "")) { + if (params.containsKey("wrongPlanRoadDirection")) { + if (params.get("wrongPlanRoadDirection").equals(planRoadDirection + "")) { continue; } } From 347324ba5d7f9bb756aa1bb18921e4b6383097be Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 7 Jan 2021 14:50:17 +0300 Subject: [PATCH 45/61] Fix search and lang sorting in TravelObfHelper --- .../plus/wikivoyage/data/TravelObfHelper.java | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 94a9d73033..55c5e6ee32 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.Collator; +import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; @@ -21,6 +22,7 @@ import net.osmand.data.QuadRect; import net.osmand.osm.PoiCategory; import net.osmand.plus.OsmandApplication; import net.osmand.plus.wikivoyage.data.TravelArticle.TravelArticleIdentifier; +import net.osmand.search.core.SearchPhrase.NameStringMatcher; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -191,10 +193,24 @@ public class TravelObfHelper implements TravelHelper { public List search(@NonNull String searchQuery) { List res = new ArrayList<>(); Map> amenityMap = new HashMap<>(); + final String appLang = app.getLanguage(); + final NameStringMatcher nm = new NameStringMatcher(searchQuery, StringMatcherMode.CHECK_STARTS_FROM_SPACE); for (BinaryMapIndexReader reader : getReaders()) { try { SearchRequest searchRequest = BinaryMapIndexReader.buildSearchPoiRequest(0, 0, searchQuery, - 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), null, null); + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchRouteArticleFilter(), new ResultMatcher() { + @Override + public boolean publish(Amenity object) { + List otherNames = object.getAllNames(false); + String localeName = object.getName(appLang); + return nm.matches(localeName) || nm.matches(otherNames); + } + + @Override + public boolean isCancelled() { + return false; + } + }, null); List amenities = reader.searchPoiByName(searchRequest); if (!Algorithms.isEmpty(amenities)) { @@ -205,14 +221,35 @@ public class TravelObfHelper implements TravelHelper { } } if (!Algorithms.isEmpty(amenityMap)) { - String appLang = app.getLanguage(); + final boolean appLangEn = "en".equals(appLang); for (Entry> entry : amenityMap.entrySet()) { File file = entry.getKey(); for (Amenity amenity : entry.getValue()) { Set nameLangs = getLanguages(amenity); if (nameLangs.contains(appLang)) { TravelArticle article = readArticle(file, amenity, appLang); - WikivoyageSearchResult r = new WikivoyageSearchResult(article, new ArrayList<>(nameLangs)); + ArrayList langs = new ArrayList<>(nameLangs); + Collections.sort(langs, new Comparator() { + @Override + public int compare(String l1, String l2) { + if (l1.equals(appLang)) { + l1 = "1"; + } + if (l2.equals(appLang)) { + l2 = "1"; + } + if (!appLangEn) { + if (l1.equals("en")) { + l1 = "2"; + } + if (l2.equals("en")) { + l2 = "2"; + } + } + return l1.compareTo(l2); + } + }); + WikivoyageSearchResult r = new WikivoyageSearchResult(article, langs); res.add(r); } } From eedff9b43c56d6f96e804e5de4e3280929389d64 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 7 Jan 2021 19:11:14 +0300 Subject: [PATCH 46/61] Fix search and lang sorting in TravelObfHelper --- .../data/TravelLocalDataHelper.java | 2 +- .../explore/WikivoyageExploreActivity.java | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 288b71dd88..6321eab0d8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -508,7 +508,7 @@ public class TravelLocalDataHelper { BOOKMARKS_COL_ROUTE_ID + " = ?, " + BOOKMARKS_COL_CONTENT_JSON + " = ?, " + BOOKMARKS_COL_CONTENT + " = ?, " + - BOOKMARKS_COL_LAST_MODIFIED + " = ?, " + + BOOKMARKS_COL_LAST_MODIFIED + " = ? " + "WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ? " + " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + " AND " + BOOKMARKS_COL_LANG + " = ?" + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 202c834d8d..dae47525aa 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -27,13 +27,14 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView.OnNavigationItemSelectedListener; import net.osmand.AndroidUtils; +import net.osmand.plus.AppInitializer; import net.osmand.plus.LockableViewPager; import net.osmand.plus.OnDialogFragmentResultListener; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.TabActivity; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; @@ -314,7 +315,24 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv public void populateData() { switchProgressBarVisibility(true); - new LoadWikivoyageData(this).execute(); + if (app.isApplicationInitializing()) { + final WeakReference activityRef = new WeakReference<>(this); + app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() { + @Override + public void onProgress(AppInitializer init, AppInitializer.InitEvents event) { + } + + @Override + public void onFinish(AppInitializer init) { + WikivoyageExploreActivity activity = activityRef.get(); + if (AndroidUtils.isActivityNotDestroyed(activity)) { + new LoadWikivoyageData(activity).execute(); + } + } + }); + } else { + new LoadWikivoyageData(this).execute(); + } } private void onDataLoaded() { @@ -364,8 +382,8 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv private static class LoadWikivoyageData extends AsyncTask { - private WeakReference activityRef; - private TravelHelper travelHelper; + private final WeakReference activityRef; + private final TravelHelper travelHelper; LoadWikivoyageData(WikivoyageExploreActivity activity) { travelHelper = activity.getMyApplication().getTravelHelper(); @@ -381,7 +399,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv @Override protected void onPostExecute(Void result) { WikivoyageExploreActivity activity = activityRef.get(); - if (activity != null) { + if (AndroidUtils.isActivityNotDestroyed(activity)) { activity.onDataLoaded(); } } From c8d0b19d505e93caa93ce22c2ed8f35c78c42f7a Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 7 Jan 2021 14:01:58 +0000 Subject: [PATCH 47/61] Translated using Weblate (German) Currently translated at 99.9% (3606 of 3607 strings) --- OsmAnd/res/values-de/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 19175d85be..4e20ce5f44 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -4044,4 +4044,7 @@ Fahrrad Auto Fehler, Parameter erneut prüfen + Subtyp + Leer lassen, wenn kein API-Schlüssel vorhanden + Adresse kopieren \ No newline at end of file From 9f4221a12591d4f828cf6ef18bb4aa3bedf9bedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Thu, 7 Jan 2021 07:49:04 +0000 Subject: [PATCH 48/61] Translated using Weblate (Hungarian) Currently translated at 100.0% (3607 of 3607 strings) --- OsmAnd/res/values-hu/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index a9e91052bd..f411c3da1b 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -4035,4 +4035,5 @@ Az összes paraméterrel rendelkező URL így néz ki: Útvonaltervezés kipróbálása Hiba, ellenőrizze újra a paramétereket + Cím másolása \ No newline at end of file From 8a7c935159770290b4d42a17e6e2a0c31ee1e99c Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Thu, 7 Jan 2021 07:46:49 +0000 Subject: [PATCH 49/61] Translated using Weblate (Hebrew) Currently translated at 99.9% (3606 of 3607 strings) --- OsmAnd/res/values-iw/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index f2f971e562..fa7a3545a9 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -4047,4 +4047,5 @@ אופנוע מכונית שגיאה, נא לבדוק את המשתנים מחדש + העתקת כתובת \ No newline at end of file From f6f1ef0354808e125e6af7791522c57f021e0e69 Mon Sep 17 00:00:00 2001 From: WaldiS Date: Thu, 7 Jan 2021 12:54:28 +0000 Subject: [PATCH 50/61] Translated using Weblate (Polish) Currently translated at 99.4% (3587 of 3607 strings) --- OsmAnd/res/values-pl/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index 2fcf1a61c4..9ed8923f81 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -4032,4 +4032,17 @@ Zezwalaj na strumienie i dreny Zezwalaj na przerywane drogi wodne Zezwalaj na przerywane drogi wodne + Czas monitów głosowych + Podtyp + Pojazd + Klucz API + Adres URL serwera + Wpisz param + Jeśli nie, zostaw to puste + Adres URL ze wszystkimi parametrami będzie wyglądał następująco: + Obliczanie trasy testowej + Rower + Samochód + Błąd, ponownie sprawdź parametry + Skopiuj adres \ No newline at end of file From 9bf9efe4d3e17a2aa9d2c9613fffbe2d5602bf11 Mon Sep 17 00:00:00 2001 From: Gontzal Manuel Pujana Onaindia Date: Thu, 7 Jan 2021 08:43:05 +0000 Subject: [PATCH 51/61] Translated using Weblate (Basque) Currently translated at 98.6% (3557 of 3607 strings) --- OsmAnd/res/values-eu/strings.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-eu/strings.xml b/OsmAnd/res/values-eu/strings.xml index 4b641200f9..e1a7e107c2 100644 --- a/OsmAnd/res/values-eu/strings.xml +++ b/OsmAnd/res/values-eu/strings.xml @@ -785,7 +785,7 @@ Ez dago gogoko punturik gordetzeko Inportatu Ezin izan da GPX kargatu. - Bidali informea + Bidali txostena Ezin izan da deskargatutako maparik aurkitu memoria txartelean. Idatzi interesgune bat bilatzeko Edozein @@ -4008,4 +4008,18 @@ Area honi dagokio: %1$s x %2$s Zatitu aurretik Zatitu ondoren Gehitu segmentu berria + Azpimota + Ibilgailua + API gakoa + Zerbitzariaren URLa + Sartu parametroa + Mantendu hutsik hala ez bada + Parametro guztiak dituen URLak itxura hau izango du: + Proba ibilbidearen kalkulua + Gidatzen + Oinez + Bizikleta + Kotxea + Errorea, egiaztatu parametroak berriro + Kopiatu helbidea \ No newline at end of file From 401aa58437ca34a4e38f066b2c93710059dd5ccd Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Thu, 7 Jan 2021 18:43:03 +0000 Subject: [PATCH 52/61] Translated using Weblate (Sardinian) Currently translated at 99.3% (3583 of 3607 strings) --- OsmAnd/res/values-sc/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 473e0bae95..4dea386d11 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -618,7 +618,7 @@ Imprea sas mapas in lìnia (iscàrriga e archìvia sos tasseddos in s’ischeda de memòria). Mapas in lìnia Ischerta sas mitzas de sas mapas in lìnia o de sos tasseddos in cache. - Permitit de impreare sas funtzionalidades pro s\'atzessibilidade de su dispositivu ditetamente in OsmAnd, e fatzilitat, pro nàrrere, sa modìfica de sa lestresa de sas boghes de sìntesi vocale, sa cunfiguratzione de su movimentu de s\'ischermu, s’impreu de una trackball pro s\'ismanniamentu o de un’interfàtzia vocale pro cosas che s\'annùntziu de sa positzione tua. + Permitit de impreare sas funtzionalidades pro s\'atzessibilidade de su dispositivu diretamente in OsmAnd, e fatzìlitat, pro nàrrere, sa modìfica de sa lestresa de sas boghes de sìntesi vocale, sa cunfiguratzione de su movimentu de s\'ischermu, s’impreu de una trackball pro s\'ismanniamentu o de un’interfache vocale pro cosas che s\'annùntziu de sa positzione tua. Estensiones Sas estensiones abìlitant funtzionalidades agiuntivas e impostatziones avantzadas. Estensiones @@ -909,7 +909,7 @@ Chirca impreende sa positzione geogràfica Sistema Limba de interfache de s\'aplicatzione (impreada a pustis chi as a torrare a allùghere OsmAnd). - Limba interfàtzia + Limba de interfache non cumpridu Imbeniente Antepostu From 532f08a5098b10e5240fc4f9140a65ef7fe884dd Mon Sep 17 00:00:00 2001 From: WaldiS Date: Thu, 7 Jan 2021 12:58:59 +0000 Subject: [PATCH 53/61] Translated using Weblate (Polish) Currently translated at 99.2% (3852 of 3881 strings) --- OsmAnd/res/values-pl/phrases.xml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-pl/phrases.xml b/OsmAnd/res/values-pl/phrases.xml index 1c3724bfe8..a16c536915 100644 --- a/OsmAnd/res/values-pl/phrases.xml +++ b/OsmAnd/res/values-pl/phrases.xml @@ -121,7 +121,7 @@ Stacja diagnostyczna Myjnia samochodowa Stacja benzynowa;Stacja paliw;CPN;Tanksztela - Stacja ładowania + Stacja ładująca; Stacja ładowania pojazdów elektrycznych; Stacja ładująca EV; Elektryczny punkt ładowania; Punkt ładowania; Elektroniczna stacja ładująca; Sprzęt do zasilania pojazdów elektrycznych Podnośnik Kompresor Parking @@ -3880,4 +3880,20 @@ Rzeka Szczepienia: COVID19 Szczepienia + Kąpielisko + Stacja przeładunkowa + Waga pomostowa + Stacja strażników + Pompa zasilana + Stacja uzdatniania wody + Studnia rurowa + Baza ratowników + Mobilny agent pieniędzy + Subnarodowe + Przedstawicielstwo + Konsul honorowy + Biuro konsularne + Sekcja zainteresowań + Łączność + Łączność \ No newline at end of file From 144b1d5c58b6046a1957ba5de892d8b507927a52 Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 7 Jan 2021 18:16:21 +0000 Subject: [PATCH 54/61] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3606 of 3607 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index cb5bb0ca9b..2b3d261317 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -4033,4 +4033,20 @@ Permite cursos de agua intermitentes Permitir cursos de agua intermitentes Tiempo de los avisos por voz + Añadir motor de navegación en línea + Editar motor de navegación en línea + Subtipo + Vehículo + Clave de la API + URL del servidor + Ingresa parámetro + Si no, mantenerlo vacío + La URL con todos los parámetros se verá así: + Cálculo de la ruta de prueba + Automóvil + Peatón + Bicicleta + Automóvil + Error, vuelve a comprobar los parámetros + Copiar dirección \ No newline at end of file From 9add5f0ef65938f90dce8b30a99f3317f0df6e9a Mon Sep 17 00:00:00 2001 From: Verdulo Date: Thu, 7 Jan 2021 14:48:46 +0000 Subject: [PATCH 55/61] Translated using Weblate (Esperanto) Currently translated at 100.0% (3607 of 3607 strings) --- OsmAnd/res/values-eo/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 2c1f95858b..604d169270 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4043,4 +4043,5 @@ Biciklo Aŭtomobilo Eraro, rekontrolu parametrojn + Kopii adreson \ No newline at end of file From 5024623d64f2ea49e004dc5bff6c25b8f569183b Mon Sep 17 00:00:00 2001 From: Gontzal Manuel Pujana Onaindia Date: Thu, 7 Jan 2021 08:38:03 +0000 Subject: [PATCH 56/61] Translated using Weblate (Basque) Currently translated at 99.6% (270 of 271 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/eu/ --- OsmAnd-telegram/res/values-eu/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd-telegram/res/values-eu/strings.xml b/OsmAnd-telegram/res/values-eu/strings.xml index 1aa22910d7..f6f73a80e6 100644 --- a/OsmAnd-telegram/res/values-eu/strings.xml +++ b/OsmAnd-telegram/res/values-eu/strings.xml @@ -267,4 +267,7 @@ \"Jarraitu\" sakatuz, Telegram eta OsmAnd pribatutasun-politiken baldintzak onartzen dituzu. OsmAnd aztarnariak Telegram plataforma irekia erabiltzen duten bezeroetako bat da. Zure kontaktuek Telegram-eko beste edozein bezero erabil dezakete. Telegram-eko azken eguneratzea: %1$s + Esportatu + Logcat bufferra + Bidali txostena \ No newline at end of file From 371e60b3af447771fb1ffb68e0079936f0fc3c66 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Thu, 7 Jan 2021 21:28:35 +0200 Subject: [PATCH 57/61] add condition for 0 planRoadDirection --- .../src/main/java/net/osmand/router/BinaryRoutePlanner.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index ebfe18940c..5309866f45 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -543,6 +543,10 @@ public class BinaryRoutePlanner { } break; } + + if (from.getRoad().getRestrictionType(i) == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + return false; + } } } return true; From 80f083cf3a4faa6614791ff95807a0887cd45729 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Thu, 7 Jan 2021 21:30:15 +0200 Subject: [PATCH 58/61] add condition for 0 planRoadDirection --- .../java/net/osmand/router/BinaryRoutePlanner.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 5309866f45..dabefe81b3 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -533,18 +533,17 @@ public class BinaryRoutePlanner { long fid = to.getRoad().getId(); for (int i = 0; i < from.getRoad().getRestrictionLength(); i++) { long id = from.getRoad().getRestrictionId(i); + int tp = from.getRoad().getRestrictionType(i); if (fid == id) { - int tp = from.getRoad().getRestrictionType(i); - if (tp == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN || - tp == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN || - tp == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON || - tp == MapRenderingTypes.RESTRICTION_NO_U_TURN) { + if (tp == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN + || tp == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN + || tp == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON + || tp == MapRenderingTypes.RESTRICTION_NO_U_TURN) { return false; } break; } - - if (from.getRoad().getRestrictionType(i) == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + if (tp == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { return false; } } From fa4aa8fde5355071f25d5471cde32ac9a90e819d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 8 Jan 2021 00:18:12 +0200 Subject: [PATCH 59/61] Add export and import of online routing --- OsmAnd/res/values/strings.xml | 2 + .../onlinerouting/OnlineRoutingEngine.java | 16 +- .../OnlineRoutingEngineFragment.java | 10 +- .../onlinerouting/OnlineRoutingHelper.java | 69 ++++----- .../settings/backend/ExportSettingsType.java | 5 +- .../plus/settings/backend/OsmandSettings.java | 3 +- .../backup/OnlineRoutingSettingsItem.java | 142 ++++++++++++++++++ .../backend/backup/SettingsHelper.java | 19 +++ .../backend/backup/SettingsItemType.java | 3 +- .../backend/backup/SettingsItemsFactory.java | 3 + .../fragments/DuplicatesSettingsAdapter.java | 4 + .../fragments/ExportItemsBottomSheet.java | 5 + .../fragments/ImportDuplicatesFragment.java | 8 + .../fragments/ImportSettingsFragment.java | 9 ++ .../ImportedSettingsItemsAdapter.java | 7 +- 15 files changed, 249 insertions(+), 56 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 4991659469..47645eb555 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,8 @@ --> + Online routing engines + Online routing engine Copy address Error, recheck parameters Car diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngine.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngine.java index 10ba169cb1..aae11a39b9 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngine.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngine.java @@ -3,6 +3,7 @@ package net.osmand.plus.onlinerouting; import android.content.Context; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.osmand.plus.R; import net.osmand.util.Algorithms; @@ -26,11 +27,13 @@ public class OnlineRoutingEngine { private Map params = new HashMap<>(); public OnlineRoutingEngine(@NonNull String stringKey, - @NonNull ServerType serverType, - @NonNull String vehicleKey, - Map params) { + @NonNull ServerType serverType, + @NonNull String vehicleKey, + @Nullable Map params) { this(stringKey, serverType, vehicleKey); - this.params = params; + if (!Algorithms.isEmpty(params)) { + this.params.putAll(params); + } } public OnlineRoutingEngine(@NonNull String stringKey, @@ -96,8 +99,9 @@ public class OnlineRoutingEngine { } public static OnlineRoutingEngine createNewEngine(@NonNull ServerType serverType, - @NonNull String vehicleKey) { - return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey); + @NonNull String vehicleKey, + @Nullable Map params) { + return new OnlineRoutingEngine(generateKey(), serverType, vehicleKey, params); } private static String generateKey() { diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngineFragment.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngineFragment.java index 18b24a8762..46e47bc8f2 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngineFragment.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingEngineFragment.java @@ -132,8 +132,8 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, - @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { view = getInflater().inflate( R.layout.online_routing_engine_fragment, container, false); segmentsContainer = (ViewGroup) view.findViewById(R.id.segments_container); @@ -402,7 +402,7 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { if (isEditingMode()) { engineToSave = new OnlineRoutingEngine(editedEngineKey, engine.serverType, engine.getVehicleKey()); } else { - engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey()); + engineToSave = OnlineRoutingEngine.createNewEngine(engine.serverType, engine.getVehicleKey(), null); } engineToSave.putParameter(EngineParameterType.CUSTOM_SERVER_URL, engine.customServerUrl); @@ -568,8 +568,8 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { } public static void showInstance(@NonNull FragmentActivity activity, - @NonNull ApplicationMode appMode, - String editedEngineKey) { + @NonNull ApplicationMode appMode, + String editedEngineKey) { FragmentManager fm = activity.getSupportFragmentManager(); if (!fm.isStateSaved() && fm.findFragmentByTag(OnlineRoutingEngineFragment.TAG) == null) { OnlineRoutingEngineFragment fragment = new OnlineRoutingEngineFragment(); diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java index 8a9e42bd54..54a5467bc1 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/OnlineRoutingHelper.java @@ -91,7 +91,7 @@ public class OnlineRoutingHelper { JSONObject json = new JSONObject(jsonString); readFromJson(json, engines); } catch (JSONException e) { - LOG.debug("Error when create a new JSONObject: " + e.toString()); + LOG.debug("Error when reading engines from JSON ", e); } } return engines; @@ -99,57 +99,50 @@ public class OnlineRoutingHelper { private void saveToSettings() { if (!Algorithms.isEmpty(cachedEngines)) { - JSONObject json = new JSONObject(); - if (writeToJson(json, cachedEngines)) { + try { + JSONObject json = new JSONObject(); + writeToJson(json, cachedEngines); settings.ONLINE_ROUTING_ENGINES.set(json.toString()); + } catch (JSONException e) { + LOG.debug("Error when writing engines to JSON ", e); } } else { settings.ONLINE_ROUTING_ENGINES.set(null); } } - private static void readFromJson(JSONObject json, List engines) { - try { - if (!json.has("items")) { - return; - } - Gson gson = new Gson(); - Type type = new TypeToken>() { - }.getType(); - JSONArray itemsJson = json.getJSONArray("items"); - for (int i = 0; i < itemsJson.length(); i++) { - JSONObject object = itemsJson.getJSONObject(i); - String key = object.getString("key"); - String vehicleKey = object.getString("vehicle"); - ServerType serverType = ServerType.valueOf(object.getString("serverType")); - String paramsString = object.getString("params"); - HashMap params = gson.fromJson(paramsString, type); - engines.add(new OnlineRoutingEngine(key, serverType, vehicleKey, params)); - } - } catch (JSONException e) { - LOG.debug("Error when reading engines from JSON: " + e.toString()); + public static void readFromJson(JSONObject json, List engines) throws JSONException { + if (!json.has("items")) { + return; + } + Gson gson = new Gson(); + Type type = new TypeToken>() { + }.getType(); + JSONArray itemsJson = json.getJSONArray("items"); + for (int i = 0; i < itemsJson.length(); i++) { + JSONObject object = itemsJson.getJSONObject(i); + String key = object.getString("key"); + String vehicleKey = object.getString("vehicle"); + ServerType serverType = ServerType.valueOf(object.getString("serverType")); + String paramsString = object.getString("params"); + HashMap params = gson.fromJson(paramsString, type); + engines.add(new OnlineRoutingEngine(key, serverType, vehicleKey, params)); } } - private static boolean writeToJson(JSONObject json, List engines) { + public static void writeToJson(JSONObject json, List engines) throws JSONException { JSONArray jsonArray = new JSONArray(); Gson gson = new Gson(); Type type = new TypeToken>() { }.getType(); - try { - for (OnlineRoutingEngine engine : engines) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("key", engine.getStringKey()); - jsonObject.put("serverType", engine.getServerType().name()); - jsonObject.put("vehicle", engine.getVehicleKey()); - jsonObject.put("params", gson.toJson(engine.getParams(), type)); - jsonArray.put(jsonObject); - } - json.put("items", jsonArray); - return true; - } catch (JSONException e) { - LOG.debug("Error when writing engines to JSON: " + e.toString()); - return false; + for (OnlineRoutingEngine engine : engines) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("key", engine.getStringKey()); + jsonObject.put("serverType", engine.getServerType().name()); + jsonObject.put("vehicle", engine.getVehicleKey()); + jsonObject.put("params", gson.toJson(engine.getParams(), type)); + jsonArray.put(jsonObject); } + json.put("items", jsonArray); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index c3b1e63a75..7ee75c4092 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -24,7 +24,8 @@ public enum ExportSettingsType { MAP_SOURCES(R.string.quick_action_map_source_title, R.drawable.ic_map), OFFLINE_MAPS(R.string.shared_string_maps, R.drawable.ic_map), TTS_VOICE(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up), - VOICE(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up); + VOICE(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up), + ONLINE_ROUTING_ENGINES(R.string.online_routing_engines, R.drawable.ic_world_globe_dark); @StringRes private final int titleId; @@ -59,6 +60,6 @@ public enum ExportSettingsType { public boolean isResourcesCategory() { return this == CUSTOM_RENDER_STYLE || this == CUSTOM_ROUTING || this == MAP_SOURCES - || this == OFFLINE_MAPS || this == VOICE || this == TTS_VOICE; + || this == OFFLINE_MAPS || this == VOICE || this == TTS_VOICE || this == ONLINE_ROUTING_ENGINES; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index efaaff576b..dfaaea9468 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -48,7 +48,6 @@ import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapillary.MapillaryPlugin; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; import net.osmand.plus.mapmarkers.MapMarkersMode; -import net.osmand.plus.onlinerouting.OnlineRoutingEngine; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; @@ -1016,7 +1015,7 @@ public class OsmandSettings { ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT); } - public final CommonPreference ONLINE_ROUTING_ENGINES = new StringPreference(this, "online_routing_engines", null); + public final CommonPreference ONLINE_ROUTING_ENGINES = new StringPreference(this, "online_routing_engines", null).makeGlobal(); public final CommonPreference NAVIGATION_ICON = new EnumStringPreference<>(this, "navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java new file mode 100644 index 0000000000..19f29daafe --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java @@ -0,0 +1,142 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.onlinerouting.OnlineRoutingEngine; +import net.osmand.plus.onlinerouting.OnlineRoutingEngine.EngineParameterType; +import net.osmand.plus.onlinerouting.OnlineRoutingHelper; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +public class OnlineRoutingSettingsItem extends CollectionSettingsItem { + + private OnlineRoutingHelper onlineRoutingHelper; + + public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @Nullable OnlineRoutingSettingsItem baseItem, @NonNull List items) { + super(app, baseItem, items); + } + + public OnlineRoutingSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + onlineRoutingHelper = app.getOnlineRoutingHelper(); + existingItems = new ArrayList<>(onlineRoutingHelper.getEngines()); + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.ONLINE_ROUTING_ENGINES; + } + + @NonNull + @Override + public String getName() { + return "online_routing_engines"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.online_routing_engine); + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (OnlineRoutingEngine duplicate : duplicateItems) { + if (shouldReplace) { + onlineRoutingHelper.deleteEngine(duplicate.getStringKey()); + } + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + for (OnlineRoutingEngine engine : appliedItems) { + onlineRoutingHelper.saveEngine(engine); + } + } + } + + @Override + public boolean isDuplicate(@NonNull OnlineRoutingEngine routingEngine) { + for (OnlineRoutingEngine engine : existingItems) { + if (engine.getStringKey().equals(routingEngine.getStringKey()) + || engine.getName(app).equals(routingEngine.getName(app))) { + return true; + } + } + return false; + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @NonNull + @Override + public OnlineRoutingEngine renameItem(@NonNull OnlineRoutingEngine item) { + int number = 0; + while (true) { + number++; + OnlineRoutingEngine renamedItem = OnlineRoutingEngine.createNewEngine(item.getServerType(), item.getVehicleKey(), item.getParams()); + renamedItem.putParameter(EngineParameterType.CUSTOM_NAME, renamedItem.getName(app) + "_" + number); + if (!isDuplicate(renamedItem)) { + return renamedItem; + } + } + } + + @Override + void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { + try { + OnlineRoutingHelper.readFromJson(json, items); + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + throw new IllegalArgumentException("Json parse error", e); + } + } + + @Override + void writeItemsToJson(@NonNull JSONObject json) { + if (!items.isEmpty()) { + try { + OnlineRoutingHelper.writeToJson(json, items); + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to json", e); + } + } + } + + @Nullable + @Override + SettingsItemReader getReader() { + return getJsonReader(); + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return getJsonWriter(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 69ac3b1a13..afe3a9c9ec 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -33,6 +33,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.plus.onlinerouting.OnlineRoutingEngine; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmNotesPoint; @@ -624,6 +625,10 @@ public class SettingsHelper { resourcesItems.put(ExportSettingsType.CUSTOM_ROUTING, Arrays.asList(fl)); } } + List onlineRoutingEngines = app.getOnlineRoutingHelper().getEngines(); + if (!Algorithms.isEmpty(onlineRoutingEngines)) { + resourcesItems.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines); + } List iTileSources = new ArrayList<>(); Set tileSourceNames = app.getSettings().getTileSourceEntries(true).keySet(); for (String name : tileSourceNames) { @@ -701,6 +706,7 @@ public class SettingsHelper { List markersGroups = new ArrayList<>(); List markersHistoryGroups = new ArrayList<>(); List historyEntries = new ArrayList<>(); + List onlineRoutingEngines = new ArrayList<>(); for (Object object : data) { if (object instanceof QuickAction) { @@ -741,6 +747,8 @@ public class SettingsHelper { historyEntries.add((HistoryEntry) object); } else if (object instanceof GlobalSettingsItem) { settingsItems.add((GlobalSettingsItem) object); + } else if (object instanceof OnlineRoutingEngine) { + onlineRoutingEngines.add((OnlineRoutingEngine) object); } } if (!quickActions.isEmpty()) { @@ -793,6 +801,9 @@ public class SettingsHelper { if (!historyEntries.isEmpty()) { settingsItems.add(new SearchHistorySettingsItem(app, historyEntries)); } + if (!onlineRoutingEngines.isEmpty()) { + settingsItems.add(new OnlineRoutingSettingsItem(app, onlineRoutingEngines)); + } return settingsItems; } @@ -848,6 +859,7 @@ public class SettingsHelper { List markersGroups = new ArrayList<>(); List markersHistoryGroups = new ArrayList<>(); List historyEntries = new ArrayList<>(); + List onlineRoutingEngines = new ArrayList<>(); for (SettingsItem item : settingsItems) { switch (item.getType()) { @@ -942,6 +954,10 @@ public class SettingsHelper { case GPX: tracksFilesList.add((GpxSettingsItem) item); break; + case ONLINE_ROUTING_ENGINES: + OnlineRoutingSettingsItem onlineRoutingSettingsItem = (OnlineRoutingSettingsItem) item; + onlineRoutingEngines.addAll(onlineRoutingSettingsItem.getItems()); + break; default: break; } @@ -1004,6 +1020,9 @@ public class SettingsHelper { if (!historyEntries.isEmpty()) { settingsToOperate.put(ExportSettingsType.SEARCH_HISTORY, historyEntries); } + if (!onlineRoutingEngines.isEmpty()) { + settingsToOperate.put(ExportSettingsType.ONLINE_ROUTING_ENGINES, onlineRoutingEngines); + } return settingsToOperate; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index 9af8424ffc..de002efff4 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -19,5 +19,6 @@ public enum SettingsItemType { FAVOURITES, ACTIVE_MARKERS, HISTORY_MARKERS, - SEARCH_HISTORY + SEARCH_HISTORY, + ONLINE_ROUTING_ENGINES } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java index 39846f1826..47cee4b0fc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -146,6 +146,9 @@ class SettingsItemsFactory { case GPX: item = new GpxSettingsItem(app, json); break; + case ONLINE_ROUTING_ENGINES: + item = new OnlineRoutingSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index fc6982a7a6..575dc74db2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -23,6 +23,7 @@ import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.onlinerouting.OnlineRoutingEngine; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; @@ -163,6 +164,9 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter mapMarkers = new ArrayList<>(); List mapMarkersGroups = new ArrayList<>(); List historyEntries = new ArrayList<>(); + List onlineRoutingEngines = new ArrayList<>(); for (Object object : duplicatesList) { if (object instanceof ApplicationMode.ApplicationModeBean) { @@ -250,6 +252,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { } } else if (object instanceof HistoryEntry) { historyEntries.add((HistoryEntry) object); + } else if (object instanceof OnlineRoutingEngine) { + onlineRoutingEngines.add((OnlineRoutingEngine) object); } } if (!profiles.isEmpty()) { @@ -320,6 +324,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { duplicates.add(getString(R.string.markers_history)); duplicates.addAll(mapMarkersGroups); } + if (!onlineRoutingEngines.isEmpty()) { + duplicates.add(getString(R.string.online_routing_engines)); + duplicates.addAll(onlineRoutingEngines); + } return duplicates; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 2d7d50046d..970acb24bc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -36,6 +36,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.plus.onlinerouting.OnlineRoutingEngine; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; @@ -50,6 +51,7 @@ import net.osmand.plus.settings.backend.backup.GpxSettingsItem; import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem; import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem; import net.osmand.plus.settings.backend.backup.MarkersSettingsItem; +import net.osmand.plus.settings.backend.backup.OnlineRoutingSettingsItem; import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem; @@ -347,6 +349,7 @@ public class ImportSettingsFragment extends BaseSettingsListFragment { List markersGroups = new ArrayList<>(); List markersHistoryGroups = new ArrayList<>(); List historyEntries = new ArrayList<>(); + List onlineRoutingEngines = new ArrayList<>(); for (Object object : data) { if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -384,6 +387,8 @@ public class ImportSettingsFragment extends BaseSettingsListFragment { } } else if (object instanceof HistoryEntry) { historyEntries.add((HistoryEntry) object); + } else if (object instanceof OnlineRoutingEngine) { + onlineRoutingEngines.add((OnlineRoutingEngine) object); } } if (!appModeBeans.isEmpty()) { @@ -435,6 +440,10 @@ public class ImportSettingsFragment extends BaseSettingsListFragment { SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class); settingsItems.add(new SearchHistorySettingsItem(app, baseItem, historyEntries)); } + if (!onlineRoutingEngines.isEmpty()) { + OnlineRoutingSettingsItem baseItem = getBaseItem(SettingsItemType.ONLINE_ROUTING_ENGINES, OnlineRoutingSettingsItem.class); + settingsItems.add(new OnlineRoutingSettingsItem(app, baseItem, onlineRoutingEngines)); + } return settingsItems; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java index 94228d4945..b8f8d31d82 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java @@ -16,7 +16,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.settings.backend.ExportSettingsType; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -33,7 +32,7 @@ public class ImportedSettingsItemsAdapter extends private OnItemClickListener listener; ImportedSettingsItemsAdapter(@NonNull OsmandApplication app, Map> itemsMap, - boolean nightMode, OnItemClickListener listener) { + boolean nightMode, OnItemClickListener listener) { this.app = app; this.itemsMap = itemsMap; this.nightMode = nightMode; @@ -154,6 +153,10 @@ public class ImportedSettingsItemsAdapter extends holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_history, activeColorRes)); holder.title.setText(R.string.shared_string_search_history); break; + case ONLINE_ROUTING_ENGINES: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_world_globe_dark, activeColorRes)); + holder.title.setText(R.string.online_routing_engines); + break; } } From d0d95e92cca1ca45d36764e713fd452daf4c1098 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 8 Jan 2021 00:34:09 +0200 Subject: [PATCH 60/61] Fix ImportCompleteFragment and remove duplicated code --- .../backup/AvoidRoadsSettingsItem.java | 5 -- .../backup/CollectionSettingsItem.java | 5 ++ .../backend/backup/FavoritesSettingsItem.java | 5 -- .../backup/HistoryMarkersSettingsItem.java | 5 -- .../backup/MapSourcesSettingsItem.java | 5 -- .../backend/backup/MarkersSettingsItem.java | 5 -- .../backup/OnlineRoutingSettingsItem.java | 5 -- .../backend/backup/OsmEditsSettingsItem.java | 5 -- .../backend/backup/OsmNotesSettingsItem.java | 5 -- .../backup/PoiUiFiltersSettingsItem.java | 5 -- .../backup/QuickActionsSettingsItem.java | 5 -- .../backup/SearchHistorySettingsItem.java | 5 -- .../fragments/ImportCompleteFragment.java | 48 +++++++++++++------ 13 files changed, 38 insertions(+), 70 deletions(-) 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 a65a60b2d7..6f53a11b07 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java @@ -92,11 +92,6 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem extends SettingsItem { return true; } + @Override + public boolean shouldReadOnCollecting() { + return true; + } + public abstract boolean isDuplicate(@NonNull T item); @NonNull diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java index acb96be110..515b9885c7 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java @@ -109,11 +109,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem return false; } - @Override - public boolean shouldReadOnCollecting() { - return true; - } - @NonNull @Override public FavoriteGroup renameItem(@NonNull FavoriteGroup item) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java index 9f441b7ec8..ba0c3d7dc0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java @@ -103,11 +103,6 @@ public class HistoryMarkersSettingsItem extends CollectionSettingsItem return "map_sources"; } - @Override - public boolean shouldReadOnCollecting() { - return true; - } - @Override void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { try { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 0698846638..daa6b9b485 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -103,11 +103,6 @@ public class MarkersSettingsItem extends CollectionSettingsItem { return false; } - @Override - public boolean shouldReadOnCollecting() { - return true; - } - @NonNull @Override public MapMarker renameItem(@NonNull MapMarker item) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java index 19f29daafe..e5ae306cf0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OnlineRoutingSettingsItem.java @@ -87,11 +87,6 @@ public class OnlineRoutingSettingsItem extends CollectionSettingsItem return ctx.getString(R.string.osm_notes); } - @Override - public boolean shouldReadOnCollecting() { - return true; - } - @Override public boolean shouldShowDuplicates() { return false; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java index 29e20679d9..16be1f26bc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java @@ -105,11 +105,6 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem Date: Fri, 8 Jan 2021 11:12:01 +0300 Subject: [PATCH 61/61] Fix travel search crash --- .../src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java | 4 ++-- 1 file changed, 2 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 55c5e6ee32..45a8442614 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -83,7 +83,7 @@ public class TravelObfHelper implements TravelHelper { } @NonNull - public List loadPopularArticles() { + public synchronized List loadPopularArticles() { String lang = app.getLanguage(); List popularArticles = new ArrayList<>(); for (BinaryMapIndexReader reader : getReaders()) { @@ -190,7 +190,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override - public List search(@NonNull String searchQuery) { + public synchronized List search(@NonNull String searchQuery) { List res = new ArrayList<>(); Map> amenityMap = new HashMap<>(); final String appLang = app.getLanguage();