From 25744449aff4d656c15b8feb2c28881046c697cb Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 16 Feb 2021 21:44:33 +0200 Subject: [PATCH] Add "Russia", "Canada", "USA" Don't show country name in for the maps: "Germany Bavaria" > "Bavaria" --- .../main/java/net/osmand/map/WorldRegion.java | 27 ++++++++++++------- .../plus/download/DownloadResources.java | 10 +++++-- .../download/MultipleIndexesUiHelper.java | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/map/WorldRegion.java b/OsmAnd-java/src/main/java/net/osmand/map/WorldRegion.java index 99eca34f19..b6fdb4f7d4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/map/WorldRegion.java +++ b/OsmAnd-java/src/main/java/net/osmand/map/WorldRegion.java @@ -76,12 +76,12 @@ public class WorldRegion implements Serializable { } } - - + + public boolean isRegionMapDownload() { return regionMapDownload; } - + public String getLocaleName() { if(!Algorithms.isEmpty(regionNameLocale)) { return regionNameLocale; @@ -92,14 +92,14 @@ public class WorldRegion implements Serializable { if(!Algorithms.isEmpty(regionName)) { return regionName; } - + return capitalize(regionFullName.replace('_', ' ')); } - + public String getRegionDownloadName() { return regionDownloadName; } - + public String getRegionDownloadNameLC() { return regionDownloadName == null ? null : regionDownloadName.toLowerCase(); } @@ -111,7 +111,7 @@ public class WorldRegion implements Serializable { public LatLon getRegionCenter() { return regionCenter; } - + public String getRegionSearchText() { return regionSearchText; } @@ -145,7 +145,7 @@ public class WorldRegion implements Serializable { this.regionDownloadName = downloadName; superregion = null; subregions = new LinkedList(); - + } public WorldRegion(String id) { this(id, null); @@ -154,7 +154,7 @@ public class WorldRegion implements Serializable { public String getRegionId() { return regionFullName; } - + private String capitalize(String s) { String[] words = s.split(" "); if (words[0].length() > 0) { @@ -191,4 +191,13 @@ public class WorldRegion implements Serializable { } return false; } + + public boolean isContinent() { + if (superregion != null) { + String superRegionId = superregion.getRegionId(); + String thisRegionId = getRegionId(); + return WORLD.equals(superRegionId) && !RUSSIA_REGION_ID.equals(thisRegionId); + } + return false; + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 66a6621851..a90275c40d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -418,12 +418,14 @@ public class DownloadResources extends DownloadResourceGroup { mainGrp.region = reg; parentGroup.addGroup(mainGrp); + DownloadResourceGroup flatFiles = new DownloadResourceGroup(mainGrp, REGION_MAPS); List list = groupByRegion.get(reg); if (list != null) { - DownloadResourceGroup flatFiles = new DownloadResourceGroup(mainGrp, REGION_MAPS); for (IndexItem ii : list) { flatFiles.addItem(ii); } + } + if (list != null || !reg.isContinent()) { mainGrp.addGroup(flatFiles); } DownloadResourceGroup subRegions = new DownloadResourceGroup(mainGrp, DownloadResourceGroupType.SUBREGIONS); @@ -467,12 +469,16 @@ public class DownloadResources extends DownloadResourceGroup { addGroup(otherGroup); createHillshadeSRTMGroups(); + collectMultipleIndexesItems(); trimEmptyGroups(); updateLoadedFiles(); - collectMultipleIndexesItems(region); return true; } + private void collectMultipleIndexesItems() { + collectMultipleIndexesItems(region); + } + private void collectMultipleIndexesItems(@NonNull WorldRegion region) { List subRegions = region.getSubregions(); if (Algorithms.isEmpty(subRegions)) return; diff --git a/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java b/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java index c7e9a05b66..f84da0a74a 100644 --- a/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/MultipleIndexesUiHelper.java @@ -29,7 +29,7 @@ public class MultipleIndexesUiHelper { OsmandRegions osmandRegions = app.getRegions(); for (IndexItem indexItem : multipleIndexItem.getAllIndexes()) { SelectableItem selectableItem = new SelectableItem(); - selectableItem.setTitle(indexItem.getVisibleName(app, osmandRegions)); + selectableItem.setTitle(indexItem.getVisibleName(app, osmandRegions, false)); String size = indexItem.getSizeDescription(app); String date = indexItem.getDate(dateFormat, showRemoteDate);