Add app version when accessing download.osmand.net

This commit is contained in:
Pavol Zibrita 2011-10-03 13:14:40 +02:00
parent 33f138a7c8
commit 589ce6d71d
4 changed files with 12 additions and 4 deletions

View file

@ -1,5 +1,7 @@
package net.osmand;
import java.net.URLEncoder;
public class Version {
public static final String APP_NAME = "OsmAnd"; //$NON-NLS-1$
@ -11,4 +13,7 @@ public class Version {
public static final String APP_FULL_NAME = APP_NAME + " " + APP_VERSION + " " +APP_DESCRIPTION; //$NON-NLS-1$ //$NON-NLS-2$
public static final String APP_MAP_CREATOR_FULL_NAME = APP_MAP_CREATOR_NAME + " " + APP_VERSION + " " +APP_DESCRIPTION; //$NON-NLS-1$ //$NON-NLS-2$
public static String getVersionAsURLParam() {
return "osmandver=" + URLEncoder.encode(APP_VERSION + " " + APP_DESCRIPTION);
}
}

View file

@ -23,6 +23,7 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import net.osmand.LogUtil;
import net.osmand.Version;
import org.apache.commons.logging.Log;
import org.xml.sax.Attributes;
@ -321,7 +322,7 @@ public class TileSourceManager {
public static List<TileSourceTemplate> downloadTileSourceTemplates() {
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
try {
URLConnection connection = new URL("http://download.osmand.net//tile_sources.php").openConnection();
URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + Version.getVersionAsURLParam()).openConnection();
final SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(connection.getInputStream(), new DefaultHandler(){
@Override

View file

@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.URL;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.data.IndexConstants;
import org.apache.commons.logging.Log;
@ -21,7 +22,7 @@ public class DownloadOsmandIndexesHelper {
log.debug("Start loading list of index files"); //$NON-NLS-1$
IndexFileList result = new IndexFileList();
try {
URL url = new URL("http://download.osmand.net/get_indexes"); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/get_indexes?" + Version.getVersionAsURLParam()); //$NON-NLS-1$
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setInput(url.openStream(), "UTF-8"); //$NON-NLS-1$
int next;

View file

@ -18,6 +18,7 @@ import android.app.Activity;
import net.osmand.IProgress;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.data.IndexConstants;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -127,11 +128,11 @@ public class DownloadFileHelper {
try {
if(parts == 1){
URL url = new URL("http://download.osmand.net/download?file="+fileName); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/download?file="+fileName + "&" + Version.getVersionAsURLParam()); //$NON-NLS-1$
downloadFile(fileName, out, url, null, indexOfAllFiles, progress);
} else {
for(int i=1; i<=parts; i++){
URL url = new URL("http://download.osmand.net/download?file="+fileName+"-"+i); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/download?file="+fileName+"-"+i + "&" + Version.getVersionAsURLParam()); //$NON-NLS-1$
downloadFile(fileName, out, url, " ["+i+"/"+parts+"]", indexOfAllFiles, progress);
}
}