diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index c9ba352897..ba65d29dbd 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -815,7 +815,7 @@ public class SettingsHelper { @NonNull DownloadActivityType tp = DownloadActivityType.getIndexType(indexType); if (tp != null) { - IndexItem indexItem = new CustomIndexItem(fileName, description, downloadurl, timestamp, size, contentSize, containerSize, tp); + IndexItem indexItem = new CustomIndexItem(fileName, subfolder, description, downloadurl, timestamp, size, contentSize, containerSize, tp); region.downloadItems.add(indexItem); } } diff --git a/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java b/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java index 4b59234c61..f9044b8309 100644 --- a/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/CustomIndexItem.java @@ -1,15 +1,20 @@ package net.osmand.plus.download; import net.osmand.plus.OsmandApplication; +import net.osmand.util.Algorithms; + +import java.io.File; public class CustomIndexItem extends IndexItem { - private final String downloadurl; + private String downloadurl; + private String subfolder; - public CustomIndexItem(String fileName, String description, String downloadurl, + public CustomIndexItem(String fileName, String subfolder, String description, String downloadurl, long dateModified, String size, long contentSize, long containerSize, DownloadActivityType type) { super(fileName, description, dateModified, size, contentSize, containerSize, type); + this.subfolder = subfolder; this.downloadurl = downloadurl; } @@ -22,4 +27,13 @@ public class CustomIndexItem extends IndexItem { return entry; } + + @Override + public File getTargetFile(OsmandApplication ctx) { + String basename = getTranslatedBasename(); + if (!Algorithms.isEmpty(subfolder)) { + basename = subfolder + "/" + basename; + } + return new File(type.getDownloadFolder(ctx, this), basename + type.getUnzipExtension(ctx, this)); + } } diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index 48c966832c..52c738faaa 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -135,19 +135,22 @@ public class IndexItem implements Comparable { public String getBasename() { return type.getBasename(this); } - + public File getTargetFile(OsmandApplication ctx) { - String basename; - if (type == DownloadActivityType.HILLSHADE_FILE) { - basename = (FileNameTranslationHelper.HILL_SHADE + getBasename()).replace("_", " "); - } else if (type == DownloadActivityType.SLOPE_FILE) { - basename = (FileNameTranslationHelper.SLOPE + getBasename()).replace('_', ' '); - } else { - basename = getBasename(); - } + String basename = getTranslatedBasename(); return new File(type.getDownloadFolder(ctx, this), basename + type.getUnzipExtension(ctx, this)); } + public String getTranslatedBasename() { + if (type == DownloadActivityType.HILLSHADE_FILE) { + return (FileNameTranslationHelper.HILL_SHADE + getBasename()).replace("_", " "); + } else if (type == DownloadActivityType.SLOPE_FILE) { + return (FileNameTranslationHelper.SLOPE + getBasename()).replace('_', ' '); + } else { + return getBasename(); + } + } + public File getBackupFile(OsmandApplication ctx) { File backup = new File(ctx.getAppPath(IndexConstants.BACKUP_INDEX_DIR), getTargetFile(ctx).getName()); return backup;