@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 Stephan Leuschner
|
* Copyright 2016 Stephan Leuschner
|
||||||
|
* Copyright 2016 devemux86
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@@ -107,7 +108,9 @@ public class TileCache implements ITileCache {
|
|||||||
if (dbg)
|
if (dbg)
|
||||||
log.debug("open cache {}, {}", cacheDirectory, dbName);
|
log.debug("open cache {}, {}", cacheDirectory, dbName);
|
||||||
|
|
||||||
dbHelper = new SQLiteHelper(context, new File(cacheDirectory, dbName).getAbsolutePath());
|
if (cacheDirectory != null)
|
||||||
|
dbName = new File(cacheDirectory, dbName).getAbsolutePath();
|
||||||
|
dbHelper = new SQLiteHelper(context, dbName);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||||
dbHelper.setWriteAheadLoggingEnabled(true);
|
dbHelper.setWriteAheadLoggingEnabled(true);
|
||||||
|
|||||||
@@ -1,6 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 devemux86
|
||||||
|
*
|
||||||
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.oscim.app;
|
package org.oscim.app;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.oscim.android.cache.TileCache;
|
import org.oscim.android.cache.TileCache;
|
||||||
import org.oscim.layers.GenericLayer;
|
import org.oscim.layers.GenericLayer;
|
||||||
@@ -26,8 +44,6 @@ public class MapLayers {
|
|||||||
|
|
||||||
final static Logger log = LoggerFactory.getLogger(MapLayers.class);
|
final static Logger log = LoggerFactory.getLogger(MapLayers.class);
|
||||||
|
|
||||||
private static final String CACHE_DIRECTORY = "/Android/data/org.oscim.app/cache/";
|
|
||||||
|
|
||||||
abstract static class Config {
|
abstract static class Config {
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@@ -71,7 +87,8 @@ public class MapLayers {
|
|||||||
setBackgroundMap(-1);
|
setBackgroundMap(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBaseMap(SharedPreferences preferences) {
|
void setBaseMap(Context context) {
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String dbname = preferences.getString("mapDatabase", "OPENSCIENCEMAP4");
|
String dbname = preferences.getString("mapDatabase", "OPENSCIENCEMAP4");
|
||||||
|
|
||||||
if (dbname.equals(mMapDatabase) && mBaseLayer != null)
|
if (dbname.equals(mMapDatabase) && mBaseLayer != null)
|
||||||
@@ -89,7 +106,7 @@ public class MapLayers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tileSource instanceof UrlTileSource) {
|
if (tileSource instanceof UrlTileSource) {
|
||||||
mCache = new TileCache(App.activity, CACHE_DIRECTORY, dbname);
|
mCache = new TileCache(App.activity, context.getExternalCacheDir().getAbsolutePath(), dbname);
|
||||||
mCache.setCacheSize(512 * (1 << 10));
|
mCache.setCacheSize(512 * (1 << 10));
|
||||||
tileSource.setCache(mCache);
|
tileSource.setCache(mCache);
|
||||||
} else {
|
} else {
|
||||||
@@ -106,8 +123,10 @@ public class MapLayers {
|
|||||||
mMapDatabase = dbname;
|
mMapDatabase = dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPreferences(SharedPreferences preferences) {
|
void setPreferences(Context context) {
|
||||||
setBaseMap(preferences);
|
setBaseMap(context);
|
||||||
|
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
ThemeFile theme = VtmThemes.DEFAULT;
|
ThemeFile theme = VtmThemes.DEFAULT;
|
||||||
if (preferences.contains("theme")) {
|
if (preferences.contains("theme")) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* Copyright 2010, 2011, 2012 mapsforge.org
|
/* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
* Copyright 2012 Hannes Janetzek
|
* Copyright 2012 Hannes Janetzek
|
||||||
|
* Copyright 2016 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@@ -12,7 +13,6 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.oscim.app;
|
package org.oscim.app;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -81,8 +81,9 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
|
|||||||
App.activity = this;
|
App.activity = this;
|
||||||
|
|
||||||
mMapLayers = new MapLayers();
|
mMapLayers = new MapLayers();
|
||||||
|
mMapLayers.setBaseMap(this);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mMapLayers.setBaseMap(prefs);
|
|
||||||
|
|
||||||
if (!prefs.contains("distanceTouch"))
|
if (!prefs.contains("distanceTouch"))
|
||||||
prefs.edit().putBoolean("distanceTouch", true).apply();
|
prefs.edit().putBoolean("distanceTouch", true).apply();
|
||||||
@@ -347,8 +348,9 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
|
|||||||
mCompass.resume();
|
mCompass.resume();
|
||||||
mLocation.resume();
|
mLocation.resume();
|
||||||
|
|
||||||
|
mMapLayers.setPreferences(this);
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mMapLayers.setPreferences(preferences);
|
|
||||||
|
|
||||||
if (preferences.getBoolean("fullscreen", false)) {
|
if (preferences.getBoolean("fullscreen", false)) {
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|||||||
Reference in New Issue
Block a user