diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index f9026c75a5..92ec1e61af 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -17,14 +17,14 @@ public class ToDoConstants { // TODO ANDROID // 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions. // Some icons are not fine (as back menu from map - it is blured). + // Got by Andrei - // 46. Implement downloading strategy for tiles : select max zoom to download [16,15,14,...] - // That means you can save internet because from [16 -> zoom -> 18], [14 -> zoom -> 16 - suitable for speed > 40], ... - - // 61. Provide route information for YOURS (calclate turns/angle/expected time) - // 60. Audio guidance for routing - // 58. Upload/Download zip-index from site & unzip them on phone // 50. Invent opening hours editor in order to edit POI hours better on device + // GOT by Olga + + // 60. Audio guidance for routing + // 61. Provide route information for YOURS (calclate turns/angle/expected time) + // 58. Upload/Download zip-index from site & unzip them on phone // 53. Add progress bars : to internet communication activities [editing/commiting/deleting poi], do not hide edit poi dialog if operation failed // [move close buttons from alertdialog to own view] // 55. Update POI data from internet for selected area [suggest to create new POI index or extend exising of none exist] @@ -58,6 +58,8 @@ public class ToDoConstants { // 57. Implement routing information about expected time arriving // 58. Implement difference about show route/follow route (show travel time/arrival time, show mini map/next turn, etc) // 59. Show route information (directions/time, ....). Now is shown in context menu route (about route) + // 46. Implement downloading strategy for tiles : select max zoom to download [16,15,14,...] + // That means you can save internet because from [16 -> zoom -> 18], [14 -> zoom -> 16 - suitable for speed > 40], ... // DONE SWING diff --git a/DataExtractionOSM/src/com/osmand/osm/MapUtils.java b/DataExtractionOSM/src/com/osmand/osm/MapUtils.java index a2920390f8..2669a31e5d 100644 --- a/DataExtractionOSM/src/com/osmand/osm/MapUtils.java +++ b/DataExtractionOSM/src/com/osmand/osm/MapUtils.java @@ -211,9 +211,9 @@ public class MapUtils { if(meters >= 100000){ return meters / 1000 + " " + Messages.getMessage(Messages.KEY_KM); //$NON-NLS-1$ } else if(meters >= 10000){ - return MessageFormat.format("{0, number, #.#} "+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$ + return MessageFormat.format("{0,number,#.#} "+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$ } else if(meters > 1500){ - return MessageFormat.format("{0, number, #.##}"+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$ + return MessageFormat.format("{0,number,#.##}"+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$ } else { return meters + " "+Messages.getMessage(Messages.KEY_M); //$NON-NLS-1$ } diff --git a/OsmAnd/res/values-ru-rRU/strings.xml b/OsmAnd/res/values-ru-rRU/strings.xml index 8b663307a2..b8348d6bde 100644 --- a/OsmAnd/res/values-ru-rRU/strings.xml +++ b/OsmAnd/res/values-ru-rRU/strings.xml @@ -1,5 +1,7 @@ + Уровень детализация + Выберите максимальный уровень для загрузки из интернета О маршруте Общая протяженность = {0}, время в пути = ''{1}''. Выберите сервис для прокладки маршрута diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 4c030fad21..96c403114e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,5 +1,7 @@ + Max zoom level + Choose max zoom level to download using internet About route Overall distance = {0}, travelling time = ''{1}''. Choose routing service diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index fadccf781c..004c59d803 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -7,6 +7,7 @@ + diff --git a/OsmAnd/src/com/osmand/OsmandSettings.java b/OsmAnd/src/com/osmand/OsmandSettings.java index 7a1ae5c292..57a55bff11 100644 --- a/OsmAnd/src/com/osmand/OsmandSettings.java +++ b/OsmAnd/src/com/osmand/OsmandSettings.java @@ -190,6 +190,14 @@ public class OsmandSettings { SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); return prefs.getInt(POSITION_ON_MAP, CENTER_CONSTANT); } + + // this value string is synchronized with settings_pref.xml preference name + public static final String MAX_LEVEL_TO_DOWNLOAD_TILE = "max_level_download_tile"; //$NON-NLS-1$ + + public static int getMaximumLevelToDownloadTile(Context ctx) { + SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); + return prefs.getInt(MAX_LEVEL_TO_DOWNLOAD_TILE, 18); + } // this value string is synchronized with settings_pref.xml preference name public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$ diff --git a/OsmAnd/src/com/osmand/activities/SettingsActivity.java b/OsmAnd/src/com/osmand/activities/SettingsActivity.java index 3470b56c9f..3a468734ed 100644 --- a/OsmAnd/src/com/osmand/activities/SettingsActivity.java +++ b/OsmAnd/src/com/osmand/activities/SettingsActivity.java @@ -48,6 +48,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference private Preference reloadIndexes; private Preference downloadIndexes; private ListPreference routerPreference; + private ListPreference maxLevelToDownload; @Override public void onCreate(Bundle savedInstanceState) { @@ -93,6 +94,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP); positionOnMap.setOnPreferenceChangeListener(this); + maxLevelToDownload =(ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE); + maxLevelToDownload.setOnPreferenceChangeListener(this); tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES); tileSourcePreference.setOnPreferenceChangeListener(this); routerPreference =(ListPreference) screen.findPreference(OsmandSettings.ROUTER_SERVICE); @@ -156,6 +159,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference routerPreference.setEntryValues(entries); routerPreference.setValue(entry); + int startZoom = 12; + int endZoom = 19; + entries = new String[endZoom - startZoom + 1]; + for (int i = startZoom; i <= endZoom; i++) { + entries[i - startZoom] = i + ""; //$NON-NLS-1$ + } + maxLevelToDownload.setEntries(entries); + maxLevelToDownload.setEntryValues(entries); + maxLevelToDownload.setValue(OsmandSettings.getMaximumLevelToDownloadTile(this)+""); //$NON-NLS-1$ + List list = TileSourceManager.getKnownSourceTemplates(); entries = new String[list.size()]; @@ -220,6 +233,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference } else if(preference == positionOnMap){ edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue)); edit.commit(); + } else if (preference == maxLevelToDownload) { + edit.putInt(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE, Integer.parseInt((String) newValue)); + edit.commit(); } else if (preference == routerPreference) { RouteService s = null; for(RouteService r : RouteService.values()){ diff --git a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java index ee31c7fcf0..b763df6e0d 100644 --- a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java @@ -373,6 +373,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall if (canvas != null) { ResourceManager mgr = ResourceManager.getResourceManager(); boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getContext()); + int maxLevel = OsmandSettings.getMaximumLevelToDownloadTile(getContext()); canvas.save(); canvas.rotate(rotate, w , h); boundsRect.set(0, 0, getWidth(), getHeight()); @@ -390,7 +391,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall // asking tile image async boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile); Bitmap bmp = null; - if (imgExist || useInternet) { + boolean originalBeLoaded = useInternet && zoom <= maxLevel; + if (imgExist || originalBeLoaded) { bmp = mgr.getTileImageForMapAsync(ordImgTile, map, left + i, top + j, zoom, useInternet); } if (bmp == null) { @@ -398,7 +400,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall // asking if there is small version of the map (in cache) String imgTile2 = mgr.calculateTileId(map, (left + i) / 2, (top + j) / 2, zoom - 1); String imgTile4 = mgr.calculateTileId(map, (left + i) / 4, (top + j) / 4, zoom - 2); - if(useInternet || imgExist){ + if(originalBeLoaded || imgExist){ bmp = mgr.getTileImageFromCache(imgTile2); div = 2; if(bmp == null){ @@ -406,12 +408,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall div = 4; } } - if(!useInternet && !imgExist){ - if(mgr.tileExistOnFileSystem(imgTile2)){ - bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, false); + if(!originalBeLoaded && !imgExist){ + if (mgr.tileExistOnFileSystem(imgTile2) || (useInternet && zoom - 1 <= maxLevel)) { + bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, useInternet); div = 2; - } else if(mgr.tileExistOnFileSystem(imgTile4)){ - bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, false); + } else if (mgr.tileExistOnFileSystem(imgTile4) || (useInternet && zoom - 2 <= maxLevel)) { + bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, useInternet); div = 4; } }