From b77d42c9a30aab687f8c6e341fc90c73f787ecf0 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 6 Oct 2015 13:05:34 +0300 Subject: [PATCH] Downloads: added hillshade layer --- OsmAnd/res/values/strings.xml | 1 + .../plus/download/DownloadActivityType.java | 29 ++++++++++++------- .../net/osmand/plus/download/IndexItem.java | 2 +- .../plus/download/items/ItemViewHolder.java | 12 ++++++-- .../plus/download/items/ItemsListBuilder.java | 24 ++++++++++----- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0dcd453d21..a086f24227 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Hillshade layer disabled Contour lines disabled Add new Select category diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index 0f2775d967..bdd64a221d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -30,35 +30,41 @@ public class DownloadActivityType implements Parcelable { private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy"); private static Map byTag = new HashMap<>(); - public static final DownloadActivityType NORMAL_FILE = new DownloadActivityType(R.string.download_regular_maps, "map"); + public static final DownloadActivityType NORMAL_FILE = + new DownloadActivityType(R.string.download_regular_maps, "map", 10); public static final DownloadActivityType VOICE_FILE = - new DownloadActivityType(R.string.voices, R.drawable.ic_action_volume_up, "voice"); - public static final DownloadActivityType ROADS_FILE = new DownloadActivityType(R.string.download_roads_only_maps, "road_map"); + new DownloadActivityType(R.string.voices, R.drawable.ic_action_volume_up, "voice", 20); + public static final DownloadActivityType ROADS_FILE = + new DownloadActivityType(R.string.download_roads_only_maps, "road_map", 30); public static final DownloadActivityType SRTM_COUNTRY_FILE = new DownloadActivityType(R.string.download_srtm_maps, - R.drawable.ic_plugin_srtm, "srtm_map"); + R.drawable.ic_plugin_srtm, "srtm_map", 40); public static final DownloadActivityType HILLSHADE_FILE = new DownloadActivityType(R.string.download_hillshade_maps, - R.drawable.ic_action_hillshade_dark, "hillshade"); + R.drawable.ic_action_hillshade_dark, "hillshade", 50); public static final DownloadActivityType WIKIPEDIA_FILE = new DownloadActivityType(R.string.download_wikipedia_maps, - R.drawable.ic_world_globe_dark, "wikimap"); - public static final DownloadActivityType LIVE_UPDATES_FILE = new DownloadActivityType(R.string.download_live_updates, "live_updates"); + R.drawable.ic_world_globe_dark, "wikimap", 60); + public static final DownloadActivityType LIVE_UPDATES_FILE = + new DownloadActivityType(R.string.download_live_updates, "live_updates", 70); private final int stringResource; private final int iconResource; private String tag; + private int orderIndex; - public DownloadActivityType(int stringResource, int iconResource, String tag) { + public DownloadActivityType(int stringResource, int iconResource, String tag, int orderIndex) { this.stringResource = stringResource; this.tag = tag; + this.orderIndex = orderIndex; byTag.put(tag, this); this.iconResource = iconResource; } - public DownloadActivityType(int stringResource, String tag) { + public DownloadActivityType(int stringResource, String tag, int orderIndex) { this.stringResource = stringResource; this.tag = tag; + this.orderIndex = orderIndex; byTag.put(tag, this); iconResource = R.drawable.ic_map; } @@ -74,7 +80,10 @@ public class DownloadActivityType implements Parcelable { public String getTag() { return tag; } - + + public int getOrderIndex() { + return orderIndex; + } public static boolean isCountedInDownloads(IndexItem es) { DownloadActivityType tp = es.getType(); diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index ce54f4166c..574fb69228 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -38,7 +38,7 @@ public class IndexItem implements Comparable, HasName, Parcelable { public IndexItem(String fileName, String description, long timestamp, String size, long contentSize, long containerSize, DownloadActivityType tp) { this.fileName = fileName; - this.simplifiedFileName = fileName.toLowerCase().replace("_2.", "."); + this.simplifiedFileName = fileName.toLowerCase().replace("_2.", ".").replace("hillshade_", ""); this.description = description; this.timestamp = timestamp; this.size = size; diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java index 1f54279fa6..3b77cc15a5 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java @@ -85,8 +85,13 @@ public class ItemViewHolder { rightButtonAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN; disabled = true; } - if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE && srtmDisabled) { - nameTextView.setText(context.getString(R.string.srtm_plugin_disabled)); + if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || + indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { + if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { + nameTextView.setText(context.getString(R.string.srtm_plugin_disabled)); + } else { + nameTextView.setText(context.getString(R.string.hillshade_layer_disabled)); + } OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class); if (srtmPlugin == null || srtmPlugin.needsInstallation()) { rightButtonAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_PURCHASE; @@ -105,7 +110,8 @@ public class ItemViewHolder { } } - if (!showTypeInTitle && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE && srtmDisabled) { + if (!showTypeInTitle && (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || + indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { descrTextView.setText(indexItem.getType().getString(context)); } else if (showTypeInDesc) { descrTextView.setText(indexItem.getType().getString(context) + " • " + indexItem.getSizeDescription(context)); diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java index f0bcb7a0e2..01a55c8226 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java @@ -79,14 +79,14 @@ public class ItemsListBuilder { str1 = ((WorldRegion) obj1).getName(); } else { ResourceItem item = (ResourceItem) obj1; - str1 = item.title + item.getIndexItem().getType().getTag(); + str1 = item.title + item.getIndexItem().getType().getOrderIndex(); } if (obj2 instanceof WorldRegion) { str2 = ((WorldRegion) obj2).getName(); } else { ResourceItem item = (ResourceItem) obj2; - str2 = item.title + item.getIndexItem().getType().getTag(); + str2 = item.title + item.getIndexItem().getType().getOrderIndex(); } return str1.compareTo(str2); @@ -110,6 +110,7 @@ public class ItemsListBuilder { private boolean srtmDisabled; private boolean hasSrtm; + private boolean hasHillshade; public List getRegionMapItems() { return regionMapItems; @@ -194,6 +195,7 @@ public class ItemsListBuilder { private void collectSubregionsDataAndItems() { srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null; hasSrtm = false; + hasHillshade = false; // Collect all regions (and their parents) that have at least one // resource available in repository or locally. @@ -234,11 +236,19 @@ public class ItemsListBuilder { resItem.setTitle(name); if (region != this.region && srtmDisabled) { - if (hasSrtm && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) - continue; - - if (!hasSrtm && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) - hasSrtm = true; + if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { + if (hasSrtm) { + continue; + } else { + hasSrtm = true; + } + } else if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) { + if (hasHillshade) { + continue; + } else { + hasHillshade = true; + } + } }