From 6ef86099af058553d749a1c74cfad6952702af0a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 14 Jun 2015 20:41:28 +0200 Subject: [PATCH] Fix download --- OsmAnd/res/values/strings.xml | 1 + .../plus/download/DownloadActivity.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 21723751e4..cacb038fc4 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + You have old incompatible wikipedia data downloaded. Do you want to archive it? Do you want to download additional Wikipedia data (%1$s MB) ? Location service is not enabled. Do you want to turn it on? Prevent standalone logging diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 5309ef9714..824237f0fd 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -1,5 +1,6 @@ package net.osmand.plus.download; +import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; @@ -350,6 +351,7 @@ public class DownloadActivity extends BaseDownloadActivity { addToDownload(i); } updateDownloadButton(); + checkOldWikiFiles(); } }); bld.setNegativeButton(R.string.shared_string_cancel, null); @@ -359,6 +361,34 @@ public class DownloadActivity extends BaseDownloadActivity { } } + protected void checkOldWikiFiles() { + Map fileNames = getMyApplication().getResourceManager().getIndexFileNames(); + final Set wiki = new HashSet(); + for(String s : fileNames.keySet()) { + if(s.contains("_wiki")) { + wiki.add(s); + } + } + if(wiki.size() > 0) { + Builder bld = new AlertDialog.Builder(this); + bld.setMessage(R.string.archive_wikipedia_data); + bld.setNegativeButton(R.string.shared_string_cancel, null); + bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + for(String w : wiki) { + File fl = new File(w); + File nf = new File(fl.getParentFile() +"/" + IndexConstants.BACKUP_INDEX_DIR, fl.getName()); + fl.renameTo(nf); + } + } + }); + bld.show(); + } + } + + @Override public void updateDownloadButton() { // View view = getView();