Change version track mechanism. Split mapcreator and osmand.

This commit is contained in:
Victor Shcherb 2012-01-24 00:14:25 +01:00
parent 853dd08d7a
commit 93af937d89
27 changed files with 136 additions and 97 deletions

View file

@ -3,28 +3,15 @@ package net.osmand;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Version {
public class MapCreatorVersion {
public static String APP_VERSION = "0.7.1"; //$NON-NLS-1$
public static final String APP_DESCRIPTION = "alpha"; //$NON-NLS-1$
public static final String APP_MAP_CREATOR_NAME = "OsmAndMapCreator"; //$NON-NLS-1$
public static final String APP_MAP_CREATOR_VERSION = APP_MAP_CREATOR_NAME + " " + APP_VERSION; //$NON-NLS-1$
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 APP_NAME = "OsmAnd"; //$NON-NLS-1$
public static String APP_NAME_VERSION = APP_NAME + " " + APP_VERSION; //$NON-NLS-1$
public static String APP_FULL_NAME = APP_NAME + " " + APP_VERSION + " " +APP_DESCRIPTION; //$NON-NLS-1$ //$NON-NLS-2$
public static void setAppVersionAndName(String appName, String appVersion){
APP_VERSION = appVersion;
APP_NAME = appName;
APP_NAME_VERSION = APP_NAME + " " + APP_VERSION; //$NON-NLS-1$
APP_FULL_NAME = APP_NAME + " " + APP_VERSION + " " +APP_DESCRIPTION; //$NON-NLS-1$ //$NON-NLS-2$
}
public static String getVersionAsURLParam() {
try {
return "osmandver=" + URLEncoder.encode(APP_VERSION + " " + APP_DESCRIPTION, "UTF-8");

View file

@ -17,7 +17,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import net.osmand.Algoritms;
import net.osmand.Version;
import net.osmand.LogUtil;
import org.apache.commons.logging.Log;
@ -32,7 +31,7 @@ public class MapTileDownloader {
private static MapTileDownloader downloader = null;
private static Log log = LogUtil.getLog(MapTileDownloader.class);
public static String USER_AGENT = Version.APP_NAME_VERSION;
public static String USER_AGENT = "Osmand~";
private ThreadPoolExecutor threadPoolExecutor;
@ -43,12 +42,6 @@ public class MapTileDownloader {
private int currentErrors = 0;
public static MapTileDownloader getInstance(){
return getInstance(Version.APP_NAME_VERSION);
}
public static MapTileDownloader getInstance(String userAgent){
if(downloader == null){
downloader = new MapTileDownloader(TILE_DOWNLOAD_THREADS);

View file

@ -31,7 +31,7 @@ import javax.xml.parsers.ParserConfigurationException;
import net.osmand.Algoritms;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.MapCreatorVersion;
import net.osmand.data.IndexConstants;
import net.osmand.data.preparation.DBDialect;
import net.osmand.data.preparation.IndexCreator;
@ -455,7 +455,7 @@ public class IndexBatchCreator {
FileOutputStream fout = new FileOutputStream(logFileName);
fout.write((new Date() + "\n").getBytes());
fout.write((Version.APP_MAP_CREATOR_FULL_NAME + "\n").getBytes());
fout.write((MapCreatorVersion.APP_MAP_CREATOR_FULL_NAME + "\n").getBytes());
fout.close();
fh = new FileHandler(logFileName.getAbsolutePath(), 5000000, 1, true);
fh.setFormatter(new SimpleFormatter());

View file

@ -29,7 +29,7 @@ import org.xml.sax.helpers.DefaultHandler;
import net.osmand.Algoritms;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.MapCreatorVersion;
import net.osmand.data.preparation.IndexCreator;
import net.osmand.impl.ConsoleProgressImplementation;
@ -251,7 +251,7 @@ public class WikiIndexer {
streamWriter.writeCharacters("\n");
streamWriter.writeStartElement("osm");
streamWriter.writeAttribute("version", "0.6");
streamWriter.writeAttribute("generator", Version.APP_MAP_CREATOR_VERSION);
streamWriter.writeAttribute("generator", MapCreatorVersion.APP_MAP_CREATOR_VERSION);
progress.startTask("Parse wiki xml", progIS.available());
}

View file

@ -23,7 +23,6 @@ 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;
@ -320,10 +319,10 @@ public class TileSourceManager {
}
public static List<TileSourceTemplate> downloadTileSourceTemplates() {
public static List<TileSourceTemplate> downloadTileSourceTemplates(String versionAsUrl) {
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
try {
URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + Version.getVersionAsURLParam()).openConnection();
URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection();
final SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(connection.getInputStream(), new DefaultHandler(){
@Override

View file

@ -41,7 +41,7 @@ import javax.swing.UIManager;
import net.osmand.Algoritms;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.MapCreatorVersion;
import net.osmand.data.DataTileManager;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
@ -99,7 +99,7 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback {
final JMenu downloadedMenu = new JMenu("Additional"); //$NON-NLS-1$
final File tilesDirectory = DataExtractionSettings.getSettings().getTilesDirectory();
Map<String, TileSourceTemplate> udf = getCommonTemplates(tilesDirectory);
final List<TileSourceTemplate> downloaded = TileSourceManager.downloadTileSourceTemplates();
final List<TileSourceTemplate> downloaded = TileSourceManager.downloadTileSourceTemplates(MapCreatorVersion.APP_VERSION);
final Map<TileSourceTemplate, JCheckBoxMenuItem> items = new IdentityHashMap<TileSourceTemplate, JCheckBoxMenuItem>();
tiles.add(downloadedMenu);
@ -251,7 +251,7 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback {
private int xStartingImage = 0;
private int yStartingImage = 0;
private MapTileDownloader downloader = MapTileDownloader.getInstance(Version.APP_MAP_CREATOR_VERSION);
private MapTileDownloader downloader = MapTileDownloader.getInstance(MapCreatorVersion.APP_MAP_CREATOR_VERSION);
Map<String, Image> cache = new HashMap<String, Image>();
private JPopupMenu popupMenu;

View file

@ -39,7 +39,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.xml.stream.XMLStreamException;
import net.osmand.Version;
import net.osmand.MapCreatorVersion;
import net.osmand.data.preparation.IndexCreator;
import net.osmand.map.IMapLocationListener;
import net.osmand.map.ITileSource;
@ -252,7 +252,7 @@ public class OsmExtractionUI implements IMapLocationListener {
aboutApplication.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, Version.APP_MAP_CREATOR_FULL_NAME);
JOptionPane.showMessageDialog(frame, MapCreatorVersion.APP_MAP_CREATOR_FULL_NAME);
}
});

View file

@ -24,7 +24,7 @@ import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import net.osmand.Version;
import net.osmand.MapCreatorVersion;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
@ -185,7 +185,7 @@ public class TileBundleDownloadDialog extends JDialog {
numberTiles += (x2 - x1 + 1) * (y2 - y1 + 1);
}
final int number = numberTiles;
final MapTileDownloader instance = MapTileDownloader.getInstance(Version.APP_MAP_CREATOR_VERSION);
final MapTileDownloader instance = MapTileDownloader.getInstance(MapCreatorVersion.APP_MAP_CREATOR_VERSION);
progressDialog.setRunnable(new Runnable(){
@Override

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="app_name">Osmand+</string>
<string name="app_version">0.7.0 beta</string>
<string name="app_version">0.7.0 alpha</string>
<!-- Not translatable -->
<string name="ga_api_key">UA-28342846-2</string>
<string name="ga_dispatchPeriod">10</string>

View file

@ -137,7 +137,7 @@ public class GPXUtilities {
serializer.startTag(null, "gpx"); //$NON-NLS-1$
serializer.attribute(null, "version", "1.1"); //$NON-NLS-1$ //$NON-NLS-2$
if(file.author == null ){
serializer.attribute(null, "creator", Version.APP_NAME_VERSION); //$NON-NLS-1$
serializer.attribute(null, "creator", Version.getAppName(ctx)); //$NON-NLS-1$
} else {
serializer.attribute(null, "creator", file.author); //$NON-NLS-1$
}

View file

@ -0,0 +1,50 @@
package net.osmand;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import net.osmand.plus.R;
import android.content.Context;
public class Version {
private final String appVersion;
private final String appName;
private Version(Context ctx) {
appVersion = ctx.getString(R.string.app_version);
appName = ctx.getString(R.string.app_name);
}
private static Version ver = null;
private static Version getVersion(Context ctx){
if(ver == null){
ver = new Version(ctx);
}
return ver;
}
public static String getFullVersion(Context ctx){
Version v = getVersion(ctx);
return v.appName + " " + v.appVersion;
}
public static String getAppName(Context ctx){
Version v = getVersion(ctx);
return v.appName;
}
public static boolean isProductionVersion(Context ctx){
Version v = getVersion(ctx);
return !v.appVersion.startsWith("#");
}
public static String getVersionAsURLParam(Context ctx) {
try {
return "osmandver=" + URLEncoder.encode(getFullVersion(ctx), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
}

View file

@ -12,7 +12,6 @@ import net.osmand.Algoritms;
import net.osmand.LogUtil;
import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.TransportStop;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
@ -34,7 +33,6 @@ public class AsyncLoadingThread extends Thread {
AmenityLoadRequest poiLoadRequest = null;
TransportLoadRequest transportLoadRequest = null;
private static final MapTileDownloader downloader = MapTileDownloader.getInstance();
private final ResourceManager resourceManger;
@ -57,7 +55,7 @@ public class AsyncLoadingThread extends Thread {
private int calculateProgressStatus(){
int progress = 0;
if (downloader.isSomethingBeingDownloaded()) {
if (resourceManger.getMapTileDownloader().isSomethingBeingDownloaded()) {
progress = BusyIndicator.STATUS_GREEN;
} else if (resourceManger.getContext().getRoutingHelper().isRouteBeingCalculated()) {
progress = BusyIndicator.STATUS_BLUE;
@ -118,14 +116,14 @@ public class AsyncLoadingThread extends Thread {
} else if (req instanceof MapLoadRequest) {
if (!mapLoaded) {
MapLoadRequest r = (MapLoadRequest) req;
resourceManger.getRenderer().loadMap(r.tileBox, downloader.getDownloaderCallbacks());
resourceManger.getRenderer().loadMap(r.tileBox, resourceManger.getMapTileDownloader().getDownloaderCallbacks());
mapLoaded = true;
}
}
}
if (tileLoaded || amenityLoaded || transportLoaded || mapLoaded) {
// use downloader callback
for (IMapDownloaderCallback c : downloader.getDownloaderCallbacks()) {
for (IMapDownloaderCallback c : resourceManger.getMapTileDownloader().getDownloaderCallbacks()) {
c.tileDownloaded(null);
}
}
@ -163,11 +161,11 @@ public class AsyncLoadingThread extends Thread {
}
public boolean isFileCurrentlyDownloaded(File fileToSave) {
return downloader.isFileCurrentlyDownloaded(fileToSave);
return resourceManger.getMapTileDownloader().isFileCurrentlyDownloaded(fileToSave);
}
public void requestToDownload(TileLoadDownloadRequest req) {
downloader.requestToDownload(req);
resourceManger.getMapTileDownloader().requestToDownload(req);
}
protected static class TileLoadDownloadRequest extends DownloadRequest {
@ -185,7 +183,7 @@ public class AsyncLoadingThread extends Thread {
}
}
protected static class MapObjectLoadRequest<T> implements ResultMatcher<T> {
protected class MapObjectLoadRequest<T> implements ResultMatcher<T> {
protected double topLatitude;
protected double bottomLatitude;
protected double leftLongitude;
@ -217,7 +215,7 @@ public class AsyncLoadingThread extends Thread {
public void finish() {
running = false;
// use downloader callback
for (IMapDownloaderCallback c : downloader.getDownloaderCallbacks()) {
for (IMapDownloaderCallback c : resourceManger.getMapTileDownloader().getDownloaderCallbacks()) {
c.tileDownloaded(null);
}
}
@ -234,7 +232,7 @@ public class AsyncLoadingThread extends Thread {
}
protected static class AmenityLoadRequest extends MapObjectLoadRequest<Amenity> {
protected class AmenityLoadRequest extends MapObjectLoadRequest<Amenity> {
private final List<AmenityIndexRepository> res;
private final PoiFilter filter;
private final int zoom;
@ -277,7 +275,7 @@ public class AsyncLoadingThread extends Thread {
}
protected static class TransportLoadRequest extends MapObjectLoadRequest<TransportStop> {
protected class TransportLoadRequest extends MapObjectLoadRequest<TransportStop> {
private final List<TransportIndexRepository> repos;
private int zoom;

View file

@ -4,7 +4,6 @@ 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;
@ -17,12 +16,12 @@ import android.content.Context;
public class DownloadOsmandIndexesHelper {
private final static Log log = LogUtil.getLog(DownloadOsmandIndexesHelper.class);
public static IndexFileList downloadIndexesListFromInternet(){
public static IndexFileList downloadIndexesListFromInternet(String versionAsUrl){
try {
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?" + Version.getVersionAsURLParam()); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/get_indexes?" + versionAsUrl ); //$NON-NLS-1$
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setInput(url.openStream(), "UTF-8"); //$NON-NLS-1$
int next;

View file

@ -122,7 +122,7 @@ public class NavigationService extends Service implements LocationListener {
Notification notification = new Notification(R.drawable.icon, "", //$NON-NLS-1$
System.currentTimeMillis());
notification.flags = Notification.FLAG_NO_CLEAR;
notification.setLatestEventInfo(this, Version.APP_NAME,
notification.setLatestEventInfo(this, Version.getAppName(this),
getString(R.string.service_stop_background_service), PendingIntent.getBroadcast(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT));
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

View file

@ -8,6 +8,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.Version;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
@ -590,7 +591,7 @@ public class OsmandSettings {
public List<TileSourceTemplate> getInternetAvailableSourceTemplates(){
if(internetAvailableSourceTemplates == null && isInternetConnectionAvailable()){
internetAvailableSourceTemplates = TileSourceManager.downloadTileSourceTemplates();
internetAvailableSourceTemplates = TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(ctx));
}
return internetAvailableSourceTemplates;
}

View file

@ -26,6 +26,7 @@ import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.IndexConstants;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.TransportStop;
import net.osmand.map.ITileSource;
@ -107,6 +108,8 @@ public class ResourceManager {
protected final MapRenderRepositories renderer;
protected final MapTileDownloader tileDownloader;
public final AsyncLoadingThread asyncLoadingThread = new AsyncLoadingThread(this);
protected boolean internetIsNotAccessible = false;
@ -118,6 +121,8 @@ public class ResourceManager {
this.renderer = new MapRenderRepositories(context);
asyncLoadingThread.start();
tileDownloader = MapTileDownloader.getInstance(Version.getFullVersion(context));
resetStoreDirectory();
WindowManager mgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
@ -128,6 +133,10 @@ public class ResourceManager {
log.info("Tiles to load in memory : " + tiles);
maxImgCacheSize = (int) (tiles) ;
}
public MapTileDownloader getMapTileDownloader() {
return tileDownloader;
}
public void resetStoreDirectory() {
@ -370,7 +379,7 @@ public class ResourceManager {
}
private List<String> checkAssets(IProgress progress) {
if (!Version.APP_VERSION.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get())) {
if (!Version.getFullVersion(context).equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get())) {
File file = context.getSettings().extendOsmandPath(APP_DIR);
file.mkdirs();
if(file.canWrite()){
@ -378,7 +387,7 @@ public class ResourceManager {
progress.startTask(context.getString(R.string.installing_new_resources), -1);
AssetManager assetManager = context.getAssets();
copyingAssets(assetManager, "", file, progress);
context.getSettings().PREVIOUS_INSTALLED_VERSION.set(Version.APP_VERSION);
context.getSettings().PREVIOUS_INSTALLED_VERSION.set(Version.getFullVersion(context));
} catch (IOException e) {
log.error(e.getMessage(), e);
} catch (XmlPullParserException e) {
@ -661,7 +670,7 @@ public class ResourceManager {
}
}
if(!repos.isEmpty()){
AmenityLoadRequest req = new AmenityLoadRequest(repos, zoom, filter);
AmenityLoadRequest req = asyncLoadingThread.new AmenityLoadRequest(repos, zoom, filter);
req.setBoundaries(topLatitude, leftLongitude, bottomLatitude, rightLongitude);
asyncLoadingThread.requestToLoadAmenities(req);
}
@ -700,7 +709,7 @@ public class ResourceManager {
}
}
if(!repos.isEmpty()){
TransportLoadRequest req = new TransportLoadRequest(repos, zoom);
TransportLoadRequest req = asyncLoadingThread.new TransportLoadRequest(repos, zoom);
req.setBoundaries(topLatitude, leftLongitude, bottomLatitude, rightLongitude);
asyncLoadingThread.requestToLoadTransport(req);
}

View file

@ -64,7 +64,7 @@ public class DownloadFileHelper {
}
}
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", Version.APP_NAME); //$NON-NLS-1$
conn.setRequestProperty("User-Agent", Version.getFullVersion(ctx)); //$NON-NLS-1$
conn.setReadTimeout(30000);
if (fileread > 0) {
String range = "bytes="+fileread + "-" + (length -1); //$NON-NLS-1$ //$NON-NLS-2$
@ -137,11 +137,11 @@ public class DownloadFileHelper {
out = new FileOutputStream(fileToDownload);
try {
if(parts == 1){
URL url = new URL("http://download.osmand.net/download?file="+fileName + "&" + Version.getVersionAsURLParam()); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/download?file="+fileName + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$
downloadFile(fileName, out, url, null, indexOfAllFiles, progress, forceWifi);
} else {
for(int i=1; i<=parts; i++){
URL url = new URL("http://download.osmand.net/download?file="+fileName+"-"+i + "&" + Version.getVersionAsURLParam()); //$NON-NLS-1$
URL url = new URL("http://download.osmand.net/download?file="+fileName+"-"+i + "&" + Version.getVersionAsURLParam(ctx)); //$NON-NLS-1$
downloadFile(fileName, out, url, " ["+i+"/"+parts+"]", indexOfAllFiles, progress, forceWifi);
}
}

View file

@ -90,7 +90,7 @@ public class DownloadIndexActivity extends ExpandableListActivity {
private static final int MB = 1 << 20;
public static final String FILTER_KEY = "filter";
private static DownloadIndexListThread downloadListIndexThread = new DownloadIndexListThread();
private static DownloadIndexListThread downloadListIndexThread;
private ProgressDialog progressFileDlg = null;
private Map<String, String> indexFileNames = null;
@ -108,7 +108,7 @@ public class DownloadIndexActivity extends ExpandableListActivity {
private void setCustomVarsToTracker(){
tracker.setCustomVar(1, "App", Version.APP_NAME_VERSION);
tracker.setCustomVar(1, "App", Version.getFullVersion(this));
tracker.setCustomVar(2, "Device", Build.DEVICE);
tracker.setCustomVar(3, "Brand", Build.BRAND);
tracker.setCustomVar(4, "Model", Build.MODEL);
@ -127,13 +127,16 @@ public class DownloadIndexActivity extends ExpandableListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(downloadListIndexThread == null) {
downloadListIndexThread = new DownloadIndexListThread(Version.getVersionAsURLParam(this));
}
// recreation upon rotation is prevented in manifest file
setContentView(R.layout.download_index);
tracker = GoogleAnalyticsTracker.getInstance();
// Start the tracker in manual dispatch mode...
tracker.startNewSession(getString(R.string.ga_api_key), 60, this);
setCustomVarsToTracker();
tracker.trackPageView("/download.activity?" +Version.getVersionAsURLParam());
tracker.trackPageView("/download.activity?" +Version.getVersionAsURLParam(this));
downloadFileHelper = new DownloadFileHelper(this);
findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener(){
@ -213,7 +216,7 @@ public class DownloadIndexActivity extends ExpandableListActivity {
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == RELOAD_ID){
//re-create the thread
downloadListIndexThread = new DownloadIndexListThread();
downloadListIndexThread = new DownloadIndexListThread(Version.getVersionAsURLParam(this));
downloadIndexList();
} else {
final DownloadIndexAdapter listAdapter = (DownloadIndexAdapter)getExpandableListAdapter();
@ -254,10 +257,12 @@ public class DownloadIndexActivity extends ExpandableListActivity {
private static class DownloadIndexListThread extends Thread {
private DownloadIndexActivity uiActivity = null;
private IndexFileList indexFiles = null;
private IndexFileList indexFiles = null;
private final String versionUrlParam;
public DownloadIndexListThread(){
public DownloadIndexListThread(String versionUrlParam){
super("DownloadIndexes"); //$NON-NLS-1$
this.versionUrlParam = versionUrlParam;
}
public void setUiActivity(DownloadIndexActivity uiActivity) {
this.uiActivity = uiActivity;
@ -269,7 +274,7 @@ public class DownloadIndexActivity extends ExpandableListActivity {
@Override
public void run() {
indexFiles = DownloadOsmandIndexesHelper.downloadIndexesListFromInternet();
indexFiles = DownloadOsmandIndexesHelper.downloadIndexesListFromInternet(versionUrlParam);
if(uiActivity != null) {
uiActivity.removeDialog(DIALOG_PROGRESS_LIST);
uiActivity.runOnUiThread(new Runnable() {
@ -342,14 +347,14 @@ public class DownloadIndexActivity extends ExpandableListActivity {
case DIALOG_PROGRESS_FILE:
DownloadIndexesAsyncTask task = new DownloadIndexesAsyncTask(new ProgressDialogImplementation(progressFileDlg,true));
String[] indexes = entriesToDownload.keySet().toArray(new String[0]);
String v = Version.APP_NAME_VERSION;
if(Version.APP_DESCRIPTION.equals("beta")){
v +="beta";
String v = Version.getAppName(this);
if(Version.isProductionVersion(this)){
v = Version.getFullVersion(this);
} else {
v +="test";
v +=" test";
}
for(String index : indexes) {
tracker.trackEvent(v, Version.APP_NAME, index, 1);
tracker.trackEvent(v, Version.getAppName(this), index, 1);
}
task.execute(indexes);
break;
@ -359,7 +364,7 @@ public class DownloadIndexActivity extends ExpandableListActivity {
downloadListIndexThread.start();
} else if(downloadListIndexThread.getState() == Thread.State.TERMINATED){
// possibly exception occurred we don't have cache of files
downloadListIndexThread = new DownloadIndexListThread();
downloadListIndexThread = new DownloadIndexListThread(Version.getVersionAsURLParam(this));
downloadListIndexThread.setUiActivity(this);
downloadListIndexThread.start();
}

View file

@ -4,6 +4,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
@ -144,7 +145,7 @@ public class DownloadTilesDialog {
}
});
final MapTileDownloader instance = MapTileDownloader.getInstance();
final MapTileDownloader instance = MapTileDownloader.getInstance(Version.getFullVersion(ctx));
final ArrayList<IMapDownloaderCallback> previousCallbacks =
new ArrayList<IMapDownloaderCallback>(instance.getDownloaderCallbacks());

View file

@ -567,7 +567,7 @@ public class EditingPOIActivity implements DialogProvider {
ser.startTag(null, "tag"); //$NON-NLS-1$
ser.attribute(null, "k", "created_by"); //$NON-NLS-1$ //$NON-NLS-2$
ser.attribute(null, "v", Version.APP_NAME_VERSION); //$NON-NLS-1$
ser.attribute(null, "v", Version.getFullVersion(ctx)); //$NON-NLS-1$
ser.endTag(null, "tag"); //$NON-NLS-1$
ser.endTag(null, "changeset"); //$NON-NLS-1$
ser.endTag(null, "osm"); //$NON-NLS-1$
@ -699,10 +699,10 @@ public class EditingPOIActivity implements DialogProvider {
ser.startDocument("UTF-8", true); //$NON-NLS-1$
ser.startTag(null, "osmChange"); //$NON-NLS-1$
ser.attribute(null, "version", "0.6"); //$NON-NLS-1$ //$NON-NLS-2$
ser.attribute(null, "generator", Version.APP_NAME); //$NON-NLS-1$
ser.attribute(null, "generator", Version.getFullVersion(ctx)); //$NON-NLS-1$
ser.startTag(null, action);
ser.attribute(null, "version", "0.6"); //$NON-NLS-1$ //$NON-NLS-2$
ser.attribute(null, "generator", Version.APP_NAME); //$NON-NLS-1$
ser.attribute(null, "generator", Version.getFullVersion(ctx)); //$NON-NLS-1$
writeNode(n, info, ser, changeSetId, OsmandSettings.getOsmandSettings(ctx).USER_NAME.get());
ser.endTag(null, action);
ser.endTag(null, "osmChange"); //$NON-NLS-1$

View file

@ -77,7 +77,7 @@ public class MainMenuActivity extends TrackedActivity {
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.APP_NAME_VERSION); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.getAppName(MainMenuActivity.this)); //$NON-NLS-1$
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
if (info != null) {
@ -130,7 +130,7 @@ public class MainMenuActivity extends TrackedActivity {
rightview = (View) window.findViewById(R.id.SearchButton);
rightview.startAnimation(getAnimation(1, 0));
String textVersion = Version.APP_VERSION + " " + Version.APP_DESCRIPTION;
String textVersion = Version.getFullVersion(activity);
final TextView textVersionView = (TextView) window.findViewById(R.id.TextVersion);
textVersionView.setText(textVersion);
SharedPreferences prefs = activity.getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
@ -245,7 +245,7 @@ public class MainMenuActivity extends TrackedActivity {
if(!pref.contains(FIRST_TIME_APP_RUN)){
firstTime = true;
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
pref.edit().putString(VERSION_INSTALLED, Version.APP_VERSION).commit();
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(activity)).commit();
applicationInstalledFirstTime();
} else {
@ -254,8 +254,8 @@ public class MainMenuActivity extends TrackedActivity {
pref.edit().putInt(TIPS_SHOW, ++i).commit();
}
boolean appVersionChanged = false;
if(!Version.APP_VERSION.equals(pref.getString(VERSION_INSTALLED, ""))){
pref.edit().putString(VERSION_INSTALLED, Version.APP_VERSION).commit();
if(!Version.getFullVersion(activity).equals(pref.getString(VERSION_INSTALLED, ""))){
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(activity)).commit();
appVersionChanged = true;
}

View file

@ -11,7 +11,6 @@ import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.map.IMapLocationListener;
@ -135,7 +134,7 @@ public class MapActivity extends TrackedActivity implements IMapLocationListener
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Notification notification = new Notification(R.drawable.icon, "", //$NON-NLS-1$
System.currentTimeMillis());
notification.setLatestEventInfo(this, Version.APP_NAME,
notification.setLatestEventInfo(this, Version.getAppName(this),
getString(R.string.go_back_to_osmand), PendingIntent.getActivity(
this, 0, notificationIndent,
PendingIntent.FLAG_UPDATE_CURRENT));
@ -175,7 +174,7 @@ public class MapActivity extends TrackedActivity implements IMapLocationListener
});
poiActions = new EditingPOIActivity(this);
MapTileDownloader.getInstance().addDownloaderCallback(new IMapDownloaderCallback(){
getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(new IMapDownloaderCallback(){
@Override
public void tileDownloaded(DownloadRequest request) {
if(request != null && !request.error && request.fileToSave != null){
@ -583,7 +582,7 @@ public class MapActivity extends TrackedActivity implements IMapLocationListener
if(mNotificationManager != null){
mNotificationManager.cancel(APP_NOTIFICATION_ID);
}
MapTileDownloader.getInstance().removeDownloaderCallback(mapView);
getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(mapView);
}

View file

@ -6,7 +6,6 @@ import java.util.Locale;
import java.util.StringTokenizer;
import com.google.android.apps.analytics.easytracking.TrackedActivity;
import com.google.android.apps.analytics.easytracking.TrackedListActivity;
import net.osmand.LogUtil;
import net.osmand.osm.LatLon;
@ -16,7 +15,6 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.location.Location;

View file

@ -14,7 +14,6 @@ import net.osmand.Algoritms;
import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities;
import net.osmand.LogUtil;
import net.osmand.Version;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.FavouritesDbHelper;
@ -75,7 +74,6 @@ public class OsmandApplication extends Application {
super.onCreate();
long timeToStart = System.currentTimeMillis();
osmandSettings = OsmandSettings.getOsmandSettings(this);
Version.setAppVersionAndName(getString(R.string.app_name), getString(R.string.app_version));
routingHelper = new RoutingHelper(osmandSettings, OsmandApplication.this, player);
manager = new ResourceManager(this);
daynightHelper = new DayNightHelper(this);

View file

@ -11,6 +11,7 @@ import java.util.Map.Entry;
import java.util.Set;
import net.osmand.ResultMatcher;
import net.osmand.Version;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.NavigationService;
@ -806,7 +807,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
Toast.makeText(activity, R.string.internet_not_available, Toast.LENGTH_LONG).show();
return;
}
final List<TileSourceTemplate> downloaded = TileSourceManager.downloadTileSourceTemplates();
final List<TileSourceTemplate> downloaded = TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(activity));
if(downloaded == null || downloaded.isEmpty()){
Toast.makeText(activity, R.string.error_io_error, Toast.LENGTH_SHORT).show();
return;

View file

@ -138,7 +138,7 @@ public class SearchAddressOnlineActivity extends ListActivity implements SearchA
URL url = new URL(b.toString());
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setRequestProperty("User-Agent", Version.APP_NAME_VERSION); //$NON-NLS-1$
conn.setRequestProperty("User-Agent", Version.getFullVersion(SearchAddressOnlineActivity.this)); //$NON-NLS-1$
conn.connect();
InputStream is = conn.getInputStream();
XmlPullParser parser = Xml.newPullParser();

View file

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import net.osmand.LogUtil;
import net.osmand.data.MapTileDownloader;
import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.map.IMapLocationListener;
@ -427,7 +426,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
boolean useInternet = getSettings().USE_INTERNET_TO_DOWNLOAD_TILES.get();
if (useInternet) {
MapTileDownloader.getInstance().refuseAllPreviousRequests();
if(application != null) {
application.getResourceManager().getMapTileDownloader().refuseAllPreviousRequests();
}
}