diff --git a/vtm-android-app b/vtm-android-app
index 6093f289..2173ae1f 160000
--- a/vtm-android-app
+++ b/vtm-android-app
@@ -1 +1 @@
-Subproject commit 6093f28947a9188f58c6a362d196920dfd5d02c8
+Subproject commit 2173ae1f3f4349c44908a8be97d93fdce6734094
diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml
index 16905066..b22f46ed 100644
--- a/vtm-android-example/AndroidManifest.xml
+++ b/vtm-android-example/AndroidManifest.xml
@@ -10,7 +10,7 @@
+ android:targetSdkVersion="10" />
+
+
+
diff --git a/vtm-android-example/res/menu/theme_menu.xml b/vtm-android-example/res/menu/theme_menu.xml
new file mode 100644
index 00000000..91d58b89
--- /dev/null
+++ b/vtm-android-example/res/menu/theme_menu.xml
@@ -0,0 +1,10 @@
+
+
diff --git a/vtm-android-example/res/values/strings.xml b/vtm-android-example/res/values/strings.xml
index 82ce024a..8e666a04 100644
--- a/vtm-android-example/res/values/strings.xml
+++ b/vtm-android-example/res/values/strings.xml
@@ -4,5 +4,8 @@
Hello world!
Settings
MapActivity
+ Default
+ Tubes
+ Osmarender
\ No newline at end of file
diff --git a/vtm-android-example/src/org/oscim/android/test/BaseMapActivity.java b/vtm-android-example/src/org/oscim/android/test/BaseMapActivity.java
index ccbce436..bcd72fce 100644
--- a/vtm-android-example/src/org/oscim/android/test/BaseMapActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/BaseMapActivity.java
@@ -28,7 +28,7 @@ import android.view.Menu;
public class BaseMapActivity extends MapActivity {
- private final static boolean USE_CACHE = false;
+ private final static boolean USE_CACHE = true;
MapView mMapView;
VectorTileLayer mBaseLayer;
@@ -42,6 +42,7 @@ public class BaseMapActivity extends MapActivity {
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapView);
+ registerMapView(mMapView);
mTileSource = new OSciMap4TileSource();
mTileSource.setOption("url", "http://opensciencemap.org/tiles/vtm");
diff --git a/vtm-android-example/src/org/oscim/android/test/BitmapTileMapActivity.java b/vtm-android-example/src/org/oscim/android/test/BitmapTileMapActivity.java
new file mode 100644
index 00000000..927f30a6
--- /dev/null
+++ b/vtm-android-example/src/org/oscim/android/test/BitmapTileMapActivity.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 Hannes Janetzek
+ *
+ * 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 .
+ */
+package org.oscim.android.test;
+
+import org.oscim.android.MapActivity;
+import org.oscim.android.MapView;
+import org.oscim.layers.tile.bitmap.BitmapTileLayer;
+import org.oscim.layers.tile.bitmap.StamenTonerTiles;
+
+import android.os.Bundle;
+
+public class BitmapTileMapActivity extends MapActivity {
+ MapView mMapView;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map);
+
+ mMapView = (MapView) findViewById(R.id.mapView);
+ //registerMapView(mMapView);
+
+ mMap.getLayers().add(new BitmapTileLayer(mMap, StamenTonerTiles.INSTANCE, 20));
+ }
+}
diff --git a/vtm-android-example/src/org/oscim/android/test/MarkerOverlayActivity.java b/vtm-android-example/src/org/oscim/android/test/MarkerOverlayActivity.java
index 8953a0db..0d41c00c 100644
--- a/vtm-android-example/src/org/oscim/android/test/MarkerOverlayActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/MarkerOverlayActivity.java
@@ -43,6 +43,7 @@ public class MarkerOverlayActivity extends MapActivity implements OnItemGestureL
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapView);
+ registerMapView(mMapView);
MarkerSymbol symbol = AndroidGraphics.makeMarker(getResources(),
R.drawable.marker_poi,
diff --git a/vtm-android-example/src/org/oscim/android/test/PathOverlayActivity.java b/vtm-android-example/src/org/oscim/android/test/PathOverlayActivity.java
index fe5bde6a..86b62368 100644
--- a/vtm-android-example/src/org/oscim/android/test/PathOverlayActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/PathOverlayActivity.java
@@ -24,6 +24,8 @@ import org.oscim.android.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.core.GeoPoint;
import org.oscim.layers.PathLayer;
+import org.oscim.layers.tile.bitmap.BitmapTileLayer;
+import org.oscim.layers.tile.bitmap.StamenTonerTiles;
import android.os.Bundle;
@@ -37,6 +39,9 @@ public class PathOverlayActivity extends MapActivity {
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapView);
+ registerMapView(mMapView);
+
+ mMap.getLayers().add(new BitmapTileLayer(mMap, StamenTonerTiles.INSTANCE, 20));
for (double lon = -180; lon < 180; lon += 5) {
List pts = new ArrayList();
diff --git a/vtm-android-example/src/org/oscim/android/test/Samples.java b/vtm-android-example/src/org/oscim/android/test/Samples.java
index b8efdf5d..c217df8d 100644
--- a/vtm-android-example/src/org/oscim/android/test/Samples.java
+++ b/vtm-android-example/src/org/oscim/android/test/Samples.java
@@ -36,6 +36,7 @@ public class Samples extends Activity {
setContentView(R.layout.activity_samples);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
linearLayout.addView(createButton(SimpleMapActivity.class));
+ linearLayout.addView(createButton(BitmapTileMapActivity.class));
linearLayout.addView(createButton(PathOverlayActivity.class));
linearLayout.addView(createButton(MarkerOverlayActivity.class));
}
diff --git a/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java b/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java
index 0f6aeacf..c9091e18 100644
--- a/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java
@@ -15,11 +15,12 @@
* this program. If not, see .
*/package org.oscim.android.test;
-import org.oscim.layers.tile.vector.BuildingLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.theme.InternalRenderTheme;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
public class SimpleMapActivity extends BaseMapActivity {
@@ -27,7 +28,8 @@ public class SimpleMapActivity extends BaseMapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mMap.getLayers().add(new BuildingLayer(mMap, mBaseLayer.getTileLayer()));
+ //mMap.getLayers().add(new BuildingLayer(mMap, mBaseLayer.getTileLayer()));
+
mMap.getLayers().add(new LabelLayer(mMap, mBaseLayer.getTileLayer()));
//mMap.getLayers().add(new GenericLayer(mMap, new GridRenderer()));
@@ -37,5 +39,55 @@ public class SimpleMapActivity extends BaseMapActivity {
//mMap.setTheme(InternalRenderTheme.OSMARENDER);
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 14));
+
+ //loooop(0);
+ }
+
+ void loooop(final int i) {
+ mMapView.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ InternalRenderTheme t;
+ if (i == 0)
+ t = InternalRenderTheme.DEFAULT;
+ else if (i == 1)
+ t = InternalRenderTheme.TRONRENDER;
+ else
+ t = InternalRenderTheme.OSMARENDER;
+
+ mMapView.getMap().setTheme(t);
+
+ loooop((i + 1) % 3);
+ }
+ }, 300 + (int)(Math.random() * 200));
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.theme_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.theme_default:
+ mMap.setTheme(InternalRenderTheme.DEFAULT);
+ item.setChecked(true);
+ return true;
+
+ case R.id.theme_tubes:
+ mMap.setTheme(InternalRenderTheme.TRONRENDER);
+ item.setChecked(true);
+ return true;
+
+ case R.id.theme_osmarender:
+ mMap.setTheme(InternalRenderTheme.OSMARENDER);
+ item.setChecked(true);
+ return true;
+ }
+
+ return false;
}
}
diff --git a/vtm-android/src/org/oscim/android/Compass.java b/vtm-android/src/org/oscim/android/Compass.java
index fc8c0099..f8a2148b 100644
--- a/vtm-android/src/org/oscim/android/Compass.java
+++ b/vtm-android/src/org/oscim/android/Compass.java
@@ -50,9 +50,9 @@ public class Compass {
private final SensorManager mSensorManager;
private final Sensor mSensor;
- public Compass(MapActivity mapActivity, Map map) {
+ public Compass(Context context, Map map) {
mMap = map;
- mSensorManager = (SensorManager) mapActivity
+ mSensorManager = (SensorManager) context
.getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
diff --git a/vtm-android/src/org/oscim/android/MapActivity.java b/vtm-android/src/org/oscim/android/MapActivity.java
index 98a7d092..d45bd2e7 100644
--- a/vtm-android/src/org/oscim/android/MapActivity.java
+++ b/vtm-android/src/org/oscim/android/MapActivity.java
@@ -45,8 +45,6 @@ public abstract class MapActivity extends Activity {
private static final String PREFERENCES_FILE = "MapActivity";
- //private static final String KEY_THEME = "Theme";
-
private static boolean containsViewport(SharedPreferences sharedPreferences) {
return sharedPreferences.contains(KEY_LATITUDE)
&& sharedPreferences.contains(KEY_LONGITUDE)
@@ -100,8 +98,8 @@ public abstract class MapActivity extends Activity {
* @param map
* the calling MapView.
*/
- public final void registerMapView(Map map) {
- mMap = map;
+ public final void registerMapView(MapView map) {
+ mMap = map.getMap();
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE,
MODE_PRIVATE);
diff --git a/vtm-android/src/org/oscim/android/MapView.java b/vtm-android/src/org/oscim/android/MapView.java
index 5e25afb8..80f058ca 100644
--- a/vtm-android/src/org/oscim/android/MapView.java
+++ b/vtm-android/src/org/oscim/android/MapView.java
@@ -35,7 +35,6 @@ import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
-import android.view.View;
import android.widget.RelativeLayout;
/**
@@ -91,9 +90,6 @@ public class MapView extends RelativeLayout {
public MapView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
- if (!(context instanceof MapActivity))
- throw new IllegalArgumentException("context is not an instance of MapActivity");
-
CanvasAdapter.g = AndroidGraphics.INSTANCE;
AssetAdapter.g = new AndroidAssetAdapter(context);
GLAdapter.g = new AndroidGL();
@@ -108,13 +104,8 @@ public class MapView extends RelativeLayout {
// TODO make this dpi dependent
Tile.SIZE = 400;
- MapActivity mapActivity = (MapActivity) context;
-
mMap = new AndroidMap(this);
-
- mCompass = new Compass(mapActivity, mMap);
-
- mapActivity.registerMapView(mMap);
+ mCompass = new Compass(context, mMap);
mMap.clearMap();
mMap.updateMap(false);
@@ -122,9 +113,7 @@ public class MapView extends RelativeLayout {
mGestureDetector = new GestureDetector(context, new OnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
- boolean handled = mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
- mMotionEvent.wrap(null);
- return handled;
+ return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
}
@Override
@@ -139,7 +128,6 @@ public class MapView extends RelativeLayout {
@Override
public void onLongPress(MotionEvent e) {
mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e));
- mMotionEvent.wrap(null);
}
@Override
@@ -149,34 +137,9 @@ public class MapView extends RelativeLayout {
@Override
public boolean onDown(MotionEvent e) {
- boolean handled = mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
- mMotionEvent.wrap(null);
- return handled;
+ return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
}
});
-
- //mGestureDetector.setOnDoubleTapListener(new OnDoubleTapListener() {
- //
- // @Override
- // public boolean onSingleTapConfirmed(MotionEvent e) {
- // return false;
- // }
- //
- // @Override
- // public boolean onDoubleTapEvent(MotionEvent e) {
- // return false;
- // }
- //
- // @Override
- // public boolean onDoubleTap(MotionEvent e) {
- // return false;
- // }
- //});
-
- }
-
- View getView() {
- return this;
}
public Map getMap() {
@@ -220,7 +183,6 @@ public class MapView extends RelativeLayout {
return true;
}
- // synchronized ???
@Override
protected void onSizeChanged(int width, int height,
int oldWidth, int oldHeight) {
diff --git a/vtm-android/src/org/oscim/android/cache/TileCache.java b/vtm-android/src/org/oscim/android/cache/TileCache.java
index 8a8451c3..dc8ff5c1 100644
--- a/vtm-android/src/org/oscim/android/cache/TileCache.java
+++ b/vtm-android/src/org/oscim/android/cache/TileCache.java
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory;
import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
-import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDoneException;
import android.database.sqlite.SQLiteOpenHelper;
@@ -108,9 +107,14 @@ public class TileCache implements ITileCache {
mDatabase.close();
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public TileCache(Context context, String cacheDirectory, String dbName) {
dbHelper = new SQLiteHelper(context);
+
+ if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
+ dbHelper.setWriteAheadLoggingEnabled(true);
+
mDatabase = dbHelper.getWritableDatabase();
mStmtGetTile = mDatabase.compileStatement("" +
@@ -154,7 +158,7 @@ public class TileCache implements ITileCache {
class SQLiteHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "tile.db";
- private static final int DATABASE_VERSION = 3;
+ private static final int DATABASE_VERSION = 8;
private static final String DATABASE_CREATE =
"CREATE TABLE "
@@ -209,13 +213,12 @@ public class TileCache implements ITileCache {
mStmtPutTile.bindBlob(6, bytes);
mStmtPutTile.execute();
-
mStmtPutTile.clearBindings();
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public synchronized TileReader getTileApi11(Tile tile) {
+ public TileReader getTileApi11(Tile tile) {
InputStream in = null;
mStmtGetTile.bindLong(1, tile.tileX);
@@ -242,8 +245,8 @@ public class TileCache implements ITileCache {
@Override
public synchronized TileReader getTile(Tile tile) {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
- return getTileApi11(tile);
+ //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
+ // return getTileApi11(tile);
mQueryVals[0] = String.valueOf(tile.zoomLevel);
mQueryVals[1] = String.valueOf(tile.tileX);
@@ -268,12 +271,7 @@ public class TileCache implements ITileCache {
return new CacheTileReader(tile, in, Integer.MAX_VALUE);
}
- public SQLiteDatabase open() throws SQLException {
- return dbHelper.getWritableDatabase();
- }
-
@Override
public void setCacheSize(long size) {
- // TODO Auto-generated method stub
}
}
diff --git a/vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java b/vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java
index b5c14291..ab5675c1 100644
--- a/vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java
+++ b/vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java
@@ -24,23 +24,23 @@ public class AndroidCanvas implements Canvas {
final android.graphics.Canvas canvas;
public AndroidCanvas() {
- this.canvas = new android.graphics.Canvas();
+ canvas = new android.graphics.Canvas();
}
@Override
public void setBitmap(Bitmap bitmap) {
- this.canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
+ canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
}
@Override
public void drawText(String string, float x, float y, Paint stroke) {
- this.canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
-
+ if (string != null)
+ canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
}
@Override
public void drawBitmap(Bitmap bitmap, float x, float y) {
- this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
+ canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
}