From 2fbadfdde456ad288876e42fee34dbd513fe5186 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 13 Aug 2014 14:43:07 +0200 Subject: [PATCH 1/2] Update download type --- OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java index 0867f24236..3d6d0b38b5 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourDownloadType.java @@ -45,7 +45,7 @@ public class TourDownloadType extends DownloadActivityType { } public String getBaseUrl(OsmandApplication ctx, String fileName) { - return "http://" + SherpafyCustomization.TOUR_SERVER + "/download?event=2&" + return "http://" + SherpafyCustomization.TOUR_SERVER + "/download_tour.php?event=2&" + Version.getVersionAsURLParam(ctx) + "&file=" + fileName; } From 5ffec93bfcb9dd0c69a1a1fbf6a65f7e37e1a6da Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 13 Aug 2014 18:55:01 +0200 Subject: [PATCH 2/2] Update sherpafy downloads --- OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/OsmAndAppCustomization.java | 1 + .../activities/DownloadIndexActivity.java | 39 +++++++++++++------ .../plus/download/DownloadIndexesThread.java | 5 +-- .../plus/sherpafy/SherpafyCustomization.java | 2 +- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 627a714137..bca18bdfc0 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 --> + Download missing maps $1%s ($2%d MB)? More... Browse map Car diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index cf11404940..540649381f 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -115,6 +115,7 @@ public class OsmAndAppCustomization { } public void preDownloadActivity(final DownloadIndexActivity da, final List downloadTypes, ActionBar actionBar ) { + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter spinnerAdapter = new ArrayAdapter(actionBar.getThemedContext(), R.layout.sherlock_spinner_item, toString(downloadTypes) ); diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index 7a03ea027b..d7ffea8939 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -40,7 +40,6 @@ import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; -import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; @@ -51,8 +50,6 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.ActionBar.OnNavigationListener; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.SubMenu; @@ -111,7 +108,6 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity { makeSureUserCancelDownload(); } }); - getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setTitle(R.string.local_index_download); // recreation upon rotation is pgetaprevented in manifest file findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener(){ @@ -256,18 +252,37 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity { } public void showDialogToDownloadMaps(List maps) { - DownloadIndexAdapter a = (DownloadIndexAdapter) getListAdapter(); - boolean e = true; - for (IndexItem i : a.getIndexFiles()) { + int count = 0; + int sz = 0; + String s = ""; + for (IndexItem i : downloadListIndexThread.getCachedIndexFiles()) { for (String map : maps) { - if (i.getFileName().equals(map + ".obf.zip")) { - e = false; - getEntriesToDownload().put(i, i.createDownloadEntry(getMyApplication(), type, new ArrayList(1))); + if (i.getFileName().equals(map + ".obf.zip") && i.getType() == DownloadActivityType.NORMAL_FILE) { + final List de = i.createDownloadEntry(getMyApplication(), i.getType(), new ArrayList(1)); + for(DownloadEntry d : de ) { + count++; + sz += d.sizeMB; + } + if(s.length() > 0) { + s +=", "; + } + s += i.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions()); + getEntriesToDownload().put(i, de); } } } - if(!e){ - downloadFilesCheckInternet(); + if(count > 0){ + Builder builder = new AlertDialog.Builder(this); + builder.setMessage(MessageFormat.format(getString(R.string.download_additional_maps), s, sz)); + builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + downloadFilesCheckInternet(); + } + }); + builder.setNegativeButton(R.string.default_buttons_no, null); + builder.show(); + } } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 3b3cba8c90..e2596278be 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -277,14 +277,13 @@ public class DownloadIndexesThread { private String reindexFiles(List filesToReindex) { boolean vectorMapsToReindex = false; + // reindex vector maps all at one time + ResourceManager manager = app.getResourceManager(); for (File f : filesToReindex) { if (f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { vectorMapsToReindex = true; - break; } } - // reindex vector maps all at one time - ResourceManager manager = app.getResourceManager(); List warnings = new ArrayList(); manager.indexVoiceFiles(this); if (vectorMapsToReindex) { diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java index a4a0833c74..9476df0198 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java @@ -197,7 +197,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization { da.showDialogToDownloadMaps(suggestToDownloadMap); } - }); + }, 2000); } } return warns;