diff --git a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java index 1e613066ee..a893bde8e5 100644 --- a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java +++ b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java @@ -319,33 +319,33 @@ public class TileSourceManager { final List templates = new ArrayList(); // FIXME android.os.NetworkOnMainThreadException // at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118) -// try { -// URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection(); -// XmlPullParser parser = PlatformUtil.newXMLPullParser(); -// parser.setInput(connection.getInputStream(), "UTF-8"); -// int tok; -// while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { -// if (tok == XmlPullParser.START_TAG) { -// String name = parser.getName(); -// if (name.equals("tile_source")) { -// Map attrs = new LinkedHashMap(); -// for(int i=0; i< parser.getAttributeCount(); i++) { -// attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i)); -// } -// TileSourceTemplate template = createTileSourceTemplate(attrs); -// if (template != null) { -// templates.add(template); -// } -// } -// } -// } -// } catch (IOException e) { -// log.error("Exception while downloading tile sources", e); -// return null; -// } catch (XmlPullParserException e) { -// log.error("Exception while downloading tile sources", e); -// return null; -// } + try { + URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection(); + XmlPullParser parser = PlatformUtil.newXMLPullParser(); + parser.setInput(connection.getInputStream(), "UTF-8"); + int tok; + while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { + if (tok == XmlPullParser.START_TAG) { + String name = parser.getName(); + if (name.equals("tile_source")) { + Map attrs = new LinkedHashMap(); + for(int i=0; i< parser.getAttributeCount(); i++) { + attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i)); + } + TileSourceTemplate template = createTileSourceTemplate(attrs); + if (template != null) { + templates.add(template); + } + } + } + } + } catch (IOException e) { + log.error("Exception while downloading tile sources", e); + return null; + } catch (XmlPullParserException e) { + log.error("Exception while downloading tile sources", e); + return null; + } return templates; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 8f571c31b6..1fa63856c1 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -55,6 +55,7 @@ import android.graphics.drawable.BitmapDrawable; import android.os.Build; import android.os.Handler; import android.os.Message; +import android.os.StrictMode; import android.text.format.DateFormat; import android.widget.Toast; @@ -103,7 +104,13 @@ public class OsmandApplication extends Application implements ClientContext { @Override public void onCreate() { long timeToStart = System.currentTimeMillis(); + if (Version.getAppName(this).equals("OsmAnd~")) { + StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls(). + penaltyLog().penaltyDeath().build()); + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build()); + } super.onCreate(); + settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(this); externalServiceAPI = new net.osmand.plus.api.ExternalServiceAPIImpl(this); internalToDoAPI = new net.osmand.plus.api.InternalToDoAPIImpl(this); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index ec789e5f96..af406baf7f 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -15,8 +15,6 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; -import android.os.Build; - import net.osmand.IndexConstants; import net.osmand.StateChangedListener; import net.osmand.data.LatLon; @@ -30,6 +28,7 @@ import net.osmand.plus.api.SettingsAPI.SettingsEditor; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.render.RenderingRulesStorage; +import android.os.Build; public class OsmandSettings { @@ -98,7 +97,6 @@ public class OsmandSettings { // cache variables private long lastTimeInternetConnectionChecked = 0; private boolean internetConnectionAvailable = true; - private List internetAvailableSourceTemplates = null; protected OsmandSettings(OsmandApplication clientContext) { @@ -816,12 +814,6 @@ public class OsmandSettings { public final CommonPreference MAP_TILE_SOURCES = new StringPreference("map_tile_sources", TileSourceManager.getMapnikSource().getName()).makeGlobal(); - public List getInternetAvailableSourceTemplates(){ - if(internetAvailableSourceTemplates == null && isInternetConnectionAvailable()){ - internetAvailableSourceTemplates = TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(ctx)); - } - return internetAvailableSourceTemplates; - } public CommonPreference PREVIOUS_INSTALLED_VERSION = new StringPreference("previous_installed_version", "").makeGlobal(); @@ -868,8 +860,6 @@ public class OsmandSettings { if (ret != null) { return ret; } - // try to find among other templates - ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates()); if (ret != null) { return ret; } @@ -884,16 +874,8 @@ public class OsmandSettings { TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates); if (ret != null) { t = ret; - } else { - // try to find among other templates - ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates()); - if (ret != null) { - t = ret; - } } - } - return t; } return null; diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index 335db59b41..851bd564be 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -23,7 +23,6 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.hardware.SensorManager; import android.media.AudioManager; import android.os.AsyncTask; import android.os.Bundle; @@ -114,7 +113,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { screen.addPreference(applicationDir); } - screen.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr)); screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr)); registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen); diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java index 2d6d9d62c2..70eeb8f55f 100644 --- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java @@ -28,6 +28,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity { R.string.trace_rendering, R.string.trace_rendering_descr); cat.addPreference(dbg); + cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr)); + Preference pref = new Preference(this); pref.setTitle(R.string.test_voice_prompts); pref.setSummary(R.string.play_commands_of_currently_selected_voice); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java index 7bc5de1f42..74cb7c0cf7 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java @@ -105,6 +105,7 @@ public class HillshadeLayer extends MapTileLayer { } } while(cursor.moveToNext()); + cursor.close(); } }