From 461bfe0282f5160d57a566b803564eef980c236c Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 9 Oct 2014 15:28:41 +0300 Subject: [PATCH] Fixed issue with _config.p not copying from assets --- .../plus/download/DownloadFileHelper.java | 20 +++++++++++++++++++ .../plus/download/DownloadIndexesThread.java | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java index 94b89a9d50..b4e7cfb6a1 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java @@ -217,6 +217,9 @@ public class DownloadFileHelper { return false; } } + if (de.type == DownloadActivityType.VOICE_FILE){ + copyVoiceConfig(de); + } toReIndex.add(de.targetFile); showWarningCallback.showWarning(ctx.getString(R.string.download_index_success)); return true; @@ -229,6 +232,23 @@ public class DownloadFileHelper { } } + private void copyVoiceConfig(DownloadEntry de) { + File f = ctx.getAppPath("/voice/" + de.baseName + "/_config.p"); + if (f.exists()) try { + InputStream is = ctx.getAssets().open("voice/" + de.baseName + "/config.p"); + int size = is.available(); + byte[] buffer = new byte[size]; + is.read(buffer); + is.close(); + + FileOutputStream fos = new FileOutputStream(f); + fos.write(buffer); + fos.close(); + } catch (Exception ex){ + log.debug(ex.getMessage()); + } + } + private void unzipFile(DownloadEntry de, IProgress progress, List is) throws IOException { CountingMultiInputStream fin = new CountingMultiInputStream(is); int len = (int) fin.available(); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index a079ae9d00..e3f579b181 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -328,8 +328,8 @@ public class DownloadIndexesThread { boolean res = false; if (de.isAsset) { try { - if (uiActivity != null) { - ResourceManager.copyAssets(uiActivity.getAssets(), de.assetName, de.targetFile); + if (ctx != null) { + ResourceManager.copyAssets(ctx.getAssets(), de.assetName, de.targetFile); boolean changedDate = de.targetFile.setLastModified(de.dateModified); if(!changedDate) { log.error("Set last timestamp is not supported");