Update routing.xml while installing new version

This commit is contained in:
Alexey Kulish 2017-02-16 18:18:38 +03:00
parent aa46df8385
commit db55b50704

View file

@ -49,6 +49,7 @@ import net.osmand.plus.resources.AsyncLoadingThread.MapLoadRequest;
import net.osmand.plus.resources.AsyncLoadingThread.TileLoadDownloadRequest;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.router.RoutingConfiguration;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -552,6 +553,7 @@ public class ResourceManager {
context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv);
copyRegionsBoundaries();
copyPoiTypes();
copyRoutingXml();
for (String internalStyle : context.getRendererRegistry().getInternalRenderers().keySet()) {
File fl = context.getRendererRegistry().getFileForInternalStyle(internalStyle);
if (fl.exists()) {
@ -596,6 +598,19 @@ public class ResourceManager {
}
}
private void copyRoutingXml() {
try {
File file = context.getAppPath(IndexConstants.ROUTING_XML_FILE);
if (file != null) {
FileOutputStream fout = new FileOutputStream(file);
Algorithms.streamCopy(RoutingConfiguration.class.getResourceAsStream("routing.xml"), fout);
fout.close();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
private final static String ASSET_INSTALL_MODE__alwaysCopyOnFirstInstall = "alwaysCopyOnFirstInstall";
private final static String ASSET_COPY_MODE__overwriteOnlyIfExists = "overwriteOnlyIfExists";
private final static String ASSET_COPY_MODE__alwaysOverwriteOrCopy = "alwaysOverwriteOrCopy";