Wikivoyage show in downloads Android

This commit is contained in:
Dima-1 2020-12-08 22:19:54 +02:00
parent c949f98329
commit 094b8e04e0
5 changed files with 35 additions and 10 deletions

View file

@ -20,6 +20,8 @@ public class IndexConstants {
public static final String BINARY_MAP_INDEX_EXT_ZIP = ".obf.zip"; //$NON-NLS-1$
public static final String BINARY_WIKIVOYAGE_MAP_INDEX_EXT = ".sqlite"; //$NON-NLS-1$
public static final String BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT = ".travel.obf"; //$NON-NLS-1$
public static final String BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT_ZIP = ".travel.obf.zip"; //$NON-NLS-1$
public static final String BINARY_WIKI_MAP_INDEX_EXT = ".wiki.obf"; //$NON-NLS-1$
public static final String BINARY_WIKI_MAP_INDEX_EXT_ZIP = ".wiki.obf.zip"; //$NON-NLS-1$
public static final String BINARY_ROAD_MAP_INDEX_EXT = ".road.obf"; //$NON-NLS-1$

View file

@ -316,7 +316,8 @@ public class LocalIndexHelper {
private void loadTravelData(File mapPath, List<LocalIndexInfo> result, AbstractLoadLocalIndexTask loadTask) {
if (mapPath.canRead()) {
for (File mapFile : listFilesSorted(mapPath)) {
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT) ||
mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT)) {
LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TRAVEL_DATA, mapFile, false, app);
updateDescription(info);
result.add(info);

View file

@ -49,6 +49,8 @@ public class DownloadActivityType {
new DownloadActivityType(R.string.download_wikipedia_maps, R.drawable.ic_plugin_wikipedia, "wikimap", 60);
public static final DownloadActivityType WIKIVOYAGE_FILE =
new DownloadActivityType(R.string.shared_string_wikivoyage, R.drawable.ic_plugin_wikipedia, "wikivoyage", 65);
public static final DownloadActivityType TRAVEL_FILE =
new DownloadActivityType(R.string.shared_string_wikivoyage, R.drawable.ic_plugin_wikipedia, "travel", 66);
public static final DownloadActivityType LIVE_UPDATES_FILE =
new DownloadActivityType(R.string.download_live_updates, "live_updates", 70);
public static final DownloadActivityType GPX_FILE =
@ -131,7 +133,10 @@ public class DownloadActivityType {
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT_ZIP,
IndexConstants.BINARY_MAP_VERSION));
} else if (WIKIVOYAGE_FILE == this) {
return fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT);
return fileName.endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT);
} else if (TRAVEL_FILE == this) {
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT_ZIP,
IndexConstants.BINARY_MAP_VERSION));
} else if (SRTM_COUNTRY_FILE == this) {
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP,
IndexConstants.BINARY_MAP_VERSION));
@ -165,7 +170,7 @@ public class DownloadActivityType {
return ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (WIKIPEDIA_FILE == this) {
return ctx.getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (WIKIVOYAGE_FILE == this) {
} else if (WIKIVOYAGE_FILE == this || TRAVEL_FILE == this) {
return ctx.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR);
} else if (LIVE_UPDATES_FILE == this) {
return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR);
@ -220,6 +225,8 @@ public class DownloadActivityType {
return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
} else if (WIKIVOYAGE_FILE == this) {
return IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT;
} else if (TRAVEL_FILE == this) {
return IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT;
} else if (LIVE_UPDATES_FILE == this) {
return BINARY_MAP_INDEX_EXT;
} else if (HILLSHADE_FILE == this) {
@ -247,6 +254,8 @@ public class DownloadActivityType {
return "&wiki=yes";
} else if (this == WIKIVOYAGE_FILE) {
return "&wikivoyage=yes";
} else if (this == TRAVEL_FILE) {
return "&wikivoyage=yes";
} else if (this == HILLSHADE_FILE) {
return "&hillshade=yes";
} else if (this == SLOPE_FILE) {
@ -415,7 +424,9 @@ public class DownloadActivityType {
if (this == WIKIVOYAGE_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT;
}
if (this == TRAVEL_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT;
}
if (this == ROADS_FILE) {
return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
}

View file

@ -130,14 +130,18 @@ public class DownloadResources extends DownloadResourceGroup {
java.text.DateFormat dateFormat = app.getResourceManager().getDateFormat();
Map<String, String> indexActivatedFileNames = app.getResourceManager().getIndexFileNames();
listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT, indexActivatedFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT,
indexActivatedFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR),
IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT, indexActivatedFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR),
IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, indexActivatedFileNames);
Map<String, String> indexFileNames = app.getResourceManager().getIndexFileNames();
listWithAlternatives(dateFormat, app.getAppPath(""), IndexConstants.EXTRA_EXT, indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.TILES_INDEX_DIR), IndexConstants.SQLITE_EXT,
indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT,
indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR),
IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT, indexFileNames);
listWithAlternatives(dateFormat, app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR),
IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, indexFileNames);
app.getResourceManager().getBackupIndexes(indexFileNames);
this.indexFileNames = indexFileNames;
this.indexActivatedFileNames = indexActivatedFileNames;
@ -179,7 +183,8 @@ public class DownloadResources extends DownloadResourceGroup {
|| item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|| item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
outdated = true;
} else if(item.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
} else if (item.getType() == DownloadActivityType.WIKIVOYAGE_FILE
|| item.getType() == DownloadActivityType.TRAVEL_FILE) {
long itemSize = item.getContentSize();
long oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR +
item.getTargetFileName()).length();
@ -343,7 +348,11 @@ public class DownloadResources extends DownloadResourceGroup {
}
continue;
}
if(ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
if (ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
wikivoyageMaps.addItem(ii);
continue;
}
if (ii.getType() == DownloadActivityType.TRAVEL_FILE) {
wikivoyageMaps.addItem(ii);
continue;
}

View file

@ -415,6 +415,8 @@ public class ItemViewHolder {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.TRAVEL_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
tp = LocalIndexType.FONT_DATA;
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {