diff --git a/OsmAnd/src/net/osmand/plus/CustomRegion.java b/OsmAnd/src/net/osmand/plus/CustomRegion.java index 2be92ba26a..6280c0d866 100644 --- a/OsmAnd/src/net/osmand/plus/CustomRegion.java +++ b/OsmAnd/src/net/osmand/plus/CustomRegion.java @@ -148,6 +148,9 @@ public class CustomRegion extends WorldRegion { String size = new DecimalFormat("#.#").format(containerSize / (1024f * 1024f)); Map indexNames = JsonUtils.getLocalizedMapFromJson("name", itemJson); + Map firstSubNames = JsonUtils.getLocalizedMapFromJson("firstsubname", itemJson); + Map secondSubNames = JsonUtils.getLocalizedMapFromJson("secondsubname", itemJson); + DownloadDescriptionInfo descriptionInfo = DownloadDescriptionInfo.fromJson(itemJson.optJSONObject("description")); DownloadActivityType type = DownloadActivityType.getIndexType(indexType); @@ -157,6 +160,8 @@ public class CustomRegion extends WorldRegion { .setSubfolder(subfolder) .setDownloadUrl(downloadUrl) .setNames(indexNames) + .setFirstSubNames(firstSubNames) + .setSecondSubNames(secondSubNames) .setDescriptionInfo(descriptionInfo) .setTimestamp(timestamp) .setSize(size) diff --git a/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java b/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java index f8448b90f8..6d154d5cc4 100644 --- a/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java @@ -19,6 +19,8 @@ public class CustomIndexItem extends IndexItem { private String downloadUrl; private Map names; + private Map firstSubNames; + private Map secondSubNames; private DownloadDescriptionInfo descriptionInfo; @@ -30,10 +32,14 @@ public class CustomIndexItem extends IndexItem { long contentSize, long containerSize, Map names, + Map firstSubNames, + Map secondSubNames, @NonNull DownloadActivityType type, DownloadDescriptionInfo descriptionInfo) { super(fileName, null, timestamp, size, contentSize, containerSize, type); this.names = names; + this.firstSubNames = firstSubNames; + this.secondSubNames = secondSubNames; this.subfolder = subfolder; this.downloadUrl = downloadUrl; this.descriptionInfo = descriptionInfo; @@ -68,6 +74,24 @@ public class CustomIndexItem extends IndexItem { return JsonUtils.getLocalizedResFromMap(ctx, names, name); } + public String getSubName(Context ctx) { + String subName = getFirstSubName(ctx); + + String secondSubName = getSecondSubName(ctx); + if (secondSubName != null) { + subName = subName == null ? secondSubName : subName + " • " + secondSubName; + } + return subName; + } + + public String getFirstSubName(Context ctx) { + return JsonUtils.getLocalizedResFromMap(ctx, firstSubNames, null); + } + + public String getSecondSubName(Context ctx) { + return JsonUtils.getLocalizedResFromMap(ctx, secondSubNames, null); + } + public DownloadDescriptionInfo getDescriptionInfo() { return descriptionInfo; } @@ -84,6 +108,8 @@ public class CustomIndexItem extends IndexItem { private long containerSize; private Map names; + private Map firstSubNames; + private Map secondSubNames; private DownloadActivityType type; private DownloadDescriptionInfo descriptionInfo; @@ -128,6 +154,16 @@ public class CustomIndexItem extends IndexItem { return this; } + public CustomIndexItemBuilder setFirstSubNames(Map firstSubNames) { + this.firstSubNames = firstSubNames; + return this; + } + + public CustomIndexItemBuilder setSecondSubNames(Map secondSubNames) { + this.secondSubNames = secondSubNames; + return this; + } + public CustomIndexItemBuilder setDescriptionInfo(DownloadDescriptionInfo descriptionInfo) { this.descriptionInfo = descriptionInfo; return this; @@ -139,7 +175,18 @@ public class CustomIndexItem extends IndexItem { } public CustomIndexItem create() { - return new CustomIndexItem(fileName, subfolder, downloadUrl, size, timestamp, contentSize, containerSize, names, type, descriptionInfo); + return new CustomIndexItem(fileName, + subfolder, + downloadUrl, + size, + timestamp, + contentSize, + containerSize, + names, + firstSubNames, + secondSubNames, + type, + descriptionInfo); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadItemFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadItemFragment.java index 012ab25d2c..7d38a92f73 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadItemFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadItemFragment.java @@ -135,6 +135,7 @@ public class DownloadItemFragment extends DialogFragment implements DownloadEven if (banner != null) { banner.updateBannerInProgress(); } + reloadData(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 0190cfb5e7..ec1c70fd41 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -27,6 +27,7 @@ import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.download.CityItem; +import net.osmand.plus.download.CustomIndexItem; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadResourceGroup; @@ -179,22 +180,24 @@ public class ItemViewHolder { if (!isDownloading) { progressBar.setVisibility(View.GONE); descrTextView.setVisibility(View.VISIBLE); - if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE && !depthContoursPurchased) { + if (indexItem instanceof CustomIndexItem && (((CustomIndexItem) indexItem).getSubName(context) != null)) { + descrTextView.setText(((CustomIndexItem) indexItem).getSubName(context)); + } else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE && !depthContoursPurchased) { descrTextView.setText(context.getString(R.string.depth_contour_descr)); } else if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || indexItem.getType() == DownloadActivityType.HILLSHADE_FILE || indexItem.getType() == DownloadActivityType.SLOPE_FILE) && srtmDisabled) { - if(showTypeInName) { + if (showTypeInName) { descrTextView.setText(""); } else { descrTextView.setText(indexItem.getType().getString(context)); } } else if (showTypeInDesc) { - descrTextView.setText(indexItem.getType().getString(context) + + descrTextView.setText(indexItem.getType().getString(context) + " • " + indexItem.getSizeDescription(context) + " • " + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat))); } else { - descrTextView.setText(indexItem.getSizeDescription(context) + " • " + + descrTextView.setText(indexItem.getSizeDescription(context) + " • " + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat))); }