diff --git a/res/layout/activity_advanced_map_viewer.xml b/res/layout/activity_tilemap.xml similarity index 88% rename from res/layout/activity_advanced_map_viewer.xml rename to res/layout/activity_tilemap.xml index 2be2dc14..87753b92 100644 --- a/res/layout/activity_advanced_map_viewer.xml +++ b/res/layout/activity_tilemap.xml @@ -3,25 +3,24 @@ android:id="@+id/mainView" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:windowActionBarOverlay="true" - > + android:windowActionBarOverlay="true" > - + android:visibility="gone" /> \ No newline at end of file diff --git a/res/menu/options_menu.xml b/res/menu/options_menu.xml index c525f985..f2318ef1 100644 --- a/res/menu/options_menu.xml +++ b/res/menu/options_menu.xml @@ -22,10 +22,18 @@ - + + + - - - - OpenScienceMap - - - Imperial - Metric - + - - tiny - small - normal - large - huge - + + + OpenScienceMap + + + Imperial + Metric + + + tiny + small + normal + large + huge + + + OpenScienceMap + Cancel + Error + The last location is unknown + The selected file is invalid. + Please select a file. + byte + bytes + kB + MB + GB + Go to position + Area + Comment + Created by + Date + Debug information + not included + included + Language preference + File + File size + Start position + Start zoom level + Version + Latitude + Longitude + Info + Map file properties + About this software + Map file + Position + Enable rotation + Enable compass + Disable rotation + Disable compass + Enter coordinates + Last known location + Map file center + Show my location + Remove my location + Preferences + Render theme + Default Theme + Tube Theme + Select XML file … + Screenshot + JPEG (lossy) + PNG (lossless) + No location source available + OK + Debug settings + General settings + Cache persistence + Keep cached images on exit + External storage + Adjust the size of the cache + %.1f MB + Full screen mode + Hide the status bar + Fix screen orientation + Fix screen orientation + Map settings + Map mode + Select the operating mode + Move speed + Adjust the move speed of the map + %d %% move speed + Scale bar unit + Select the unit for the map scale bar + Frame rate + Enable frames per second counter + Map scale bar + Show the scale of the map + Tile coordinates + Show coordinates on tiles + Draw unmatched ways + Tile boundaries + Draw tile boundaries + Disable Polygon rendering + Highlight tiles which have the water flag set + Font size + Select the text size of map labels + Stay awake + Stop the screen from dimming + Snap to position is activated + Snap to position is disabled +  km +  m + Zoom level + Options - OpenScienceMap - Cancel - Error - The last location is unknown - The selected file is invalid. - Please select a file. - byte - bytes - kB - MB - GB - Go to position - Area - Comment - Created by - Date - Debug information - not included - included - Language preference - File - File size - Start position - Start zoom level - Version - Latitude - Longitude - Info - Map file properties - About this software - Map file - Position - Enable rotation - Enter coordinates - Last known location - Map file center - Show my location - Remove my location - Preferences - Render theme - Default Theme - Tube Theme - Select XML file … - Screenshot - JPEG (lossy) - PNG (lossless) - No location source available - OK - Debug settings - General settings - Cache persistence - Keep cached images on exit - External storage - Adjust the size of the cache - %.1f MB - Full screen mode - Hide the status bar - Map settings - Map mode - Select the operating mode - Move speed - Adjust the move speed of the map - %d %% move speed - Scale bar unit - Select the unit for the map scale bar - Frame rate - Enable frames per second counter - Map scale bar - Show the scale of the map - Tile coordinates - Show coordinates on tiles - Draw unmatched ways - Tile boundaries - Draw tile boundaries - Disable Polygon rendering - Highlight tiles which have the water flag set - Font size - Select the text size of map labels - Stay awake - Stop the screen from dimming - Snap to position is activated - Snap to position is disabled -  km -  m - Zoom level - Options \ No newline at end of file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 2dad5457..1935bc7b 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -1,40 +1,71 @@ - - - - - - - + - - - - + + + + + + + + + - + android:title="@string/preferences_move_speed" android:summary="@string/preferences_move_speed_desc" android:key="moveSpeed" /> + --> + + + + + + + + - - - - - - \ No newline at end of file diff --git a/src/org/mapsforge/android/Compass.java b/src/org/mapsforge/android/Compass.java new file mode 100644 index 00000000..b702fcc7 --- /dev/null +++ b/src/org/mapsforge/android/Compass.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010, 2011, 2012 mapsforge.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 . + */ +package org.mapsforge.android; + +import android.content.Context; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; + +public class Compass { + private final SensorEventListener mListener = new SensorEventListener() { + @Override + public void onSensorChanged(SensorEvent event) { + // if (true) Log.d(TAG, + // "sensorChanged (" + event.values[0] + ", " + event.values[1] + ", " + event.values[2] + ")"); + // mValues = event.values; + if (Math.abs(event.values[0] - mAngle) > 0.25) { + mAngle = event.values[0]; + + if (mMapView != null) { + mMapView.getMapPosition().setRotation(mAngle); + mMapView.redrawTiles(); + } + } + } + + @Override + public void onAccuracyChanged(Sensor sensor, int accuracy) { + } + }; + + /* package */float mAngle = 0; + /* package */MapView mMapView; + + private SensorManager mSensorManager; + private Sensor mSensor; + + // private float[] mValues; + + public Compass(MapActivity mapActivity, MapView mapView) { + mMapView = mapView; + mSensorManager = (SensorManager) mapActivity + .getSystemService(Context.SENSOR_SERVICE); + mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); + } + + void enable() { + mSensorManager.registerListener(mListener, mSensor, + SensorManager.SENSOR_DELAY_GAME); + } + + void disable() { + mSensorManager.unregisterListener(mListener); + mMapView.getMapPosition().setRotation(0); + } +} diff --git a/src/org/mapsforge/android/MapController.java b/src/org/mapsforge/android/MapController.java deleted file mode 100644 index 716c7a08..00000000 --- a/src/org/mapsforge/android/MapController.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2010, 2011, 2012 mapsforge.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 . - */ -package org.mapsforge.android; - -import org.mapsforge.core.GeoPoint; - -import android.view.KeyEvent; -import android.view.View; - -/** - * A MapController is used to programmatically modify the position and zoom level of a MapView. Each MapController is - * assigned to a single MapView instance. To retrieve a MapController for a given MapView, use the - * {@link MapView#getController()} method. - */ -public final class MapController implements View.OnKeyListener { - private final MapView mMapView; - - /** - * @param mapView - * the MapView which should be controlled by this MapController. - */ - MapController(MapView mapView) { - mMapView = mapView; - } - - @Override - public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { - if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { - // forward the event to the MapView - return mMapView.onKeyDown(keyCode, keyEvent); - } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) { - // forward the event to the MapView - return mMapView.onKeyUp(keyCode, keyEvent); - } - return false; - } - - /** - * Sets the center of the MapView without an animation to the given point. - * - * @param geoPoint - * the new center point of the map. - */ - public void setCenter(GeoPoint geoPoint) { - mMapView.setCenter(geoPoint); - } - - /** - * Sets the zoom level of the MapView. - * - * @param zoomLevel - * the new zoom level, will be limited by the maximum and minimum possible zoom level. - * @return the new zoom level. - */ - public int setZoom(int zoomLevel) { - mMapView.zoom((byte) (zoomLevel - mMapView.getMapPosition().getZoomLevel())); - return mMapView.getMapPosition().getZoomLevel(); - } - - /** - * Increases the zoom level of the MapView, unless the maximum zoom level has been reached. - * - * @return true if the zoom level has been changed, false otherwise. - */ - public boolean zoomIn() { - return mMapView.zoom((byte) 1); - } - - /** - * Decreases the zoom level of the MapView, unless the minimum zoom level has been reached. - * - * @return true if the zoom level has been changed, false otherwise. - */ - public boolean zoomOut() { - return mMapView.zoom((byte) -1); - } -} diff --git a/src/org/mapsforge/android/MapView.java b/src/org/mapsforge/android/MapView.java index 35c54987..7504b115 100644 --- a/src/org/mapsforge/android/MapView.java +++ b/src/org/mapsforge/android/MapView.java @@ -53,8 +53,7 @@ import android.view.MotionEvent; /** * A MapView shows a map on the display of the device. It handles all user input and touch gestures to move and zoom the - * map. This MapView also includes a scale bar and zoom controls. The {@link #getController()} method returns a - * {@link MapController} to programmatically modify the position and zoom level of the map. + * map. This MapView also includes a scale bar and zoom controls. *

* This implementation supports offline map rendering as well as downloading map images (tiles) over an Internet * connection. The operation mode of a MapView can be set in the constructor and changed at runtime with the @@ -78,14 +77,16 @@ public class MapView extends GLSurfaceView { private static final Byte DEFAULT_START_ZOOM_LEVEL = Byte.valueOf((byte) 16); public final static boolean debugFrameTime = false; - public boolean enableRotation = false; - private final MapController mMapController; + public boolean enableRotation = false; + public boolean enableCompass = false; + private final MapViewPosition mMapViewPosition; private final MapZoomControls mMapZoomControls; private final Projection mProjection; private final TouchHandler mTouchEventHandler; + private final Compass mCompass; private IMapDatabase mMapDatabase; private MapDatabases mMapDatabaseType; @@ -131,6 +132,7 @@ public class MapView extends GLSurfaceView { throw new IllegalArgumentException( "context is not an instance of MapActivity"); } + Log.d(TAG, "create MapView: " + mapDatabaseType.name()); // TODO make this dpi dependent @@ -140,8 +142,6 @@ public class MapView extends GLSurfaceView { debugSettings = new DebugSettings(false, false, false, false); - mMapController = new MapController(this); - mMapDatabaseType = mapDatabaseType; mMapViewPosition = new MapViewPosition(this); @@ -152,6 +152,8 @@ public class MapView extends GLSurfaceView { mTouchEventHandler = new TouchHandler(mapActivity, this); + mCompass = new Compass(mapActivity, this); + mJobQueue = new JobQueue(); mMapRenderer = MapRendererFactory.createMapRenderer(this, mapGeneratorType); @@ -194,6 +196,8 @@ public class MapView extends GLSurfaceView { if (!debugFrameTime) setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); + + // mCompass.enable(); } private void initMapStartPosition() { @@ -208,13 +212,6 @@ public class MapView extends GLSurfaceView { } } - /** - * @return the MapController for this MapView. - */ - public MapController getController() { - return mMapController; - } - /** * @return the debug settings which are used in this MapView. */ @@ -259,7 +256,10 @@ public class MapView extends GLSurfaceView { @Override public boolean onTouchEvent(MotionEvent motionEvent) { - return mTouchEventHandler.handleMotionEvent(motionEvent); + if (this.isClickable()) + return mTouchEventHandler.handleMotionEvent(motionEvent); + + return false; } /** @@ -279,17 +279,6 @@ public class MapView extends GLSurfaceView { mMapRenderer.updateMap(true); } - /** - * Sets the visibility of the zoom controls. - * - * @param showZoomControls - * true if the zoom controls should be visible, false otherwise. - */ - public void setBuiltInZoomControls(boolean showZoomControls) { - mMapZoomControls.setShowMapZoomControls(showZoomControls); - - } - /** * Sets the center of the MapView and triggers a redraw. * @@ -299,6 +288,7 @@ public class MapView extends GLSurfaceView { public void setCenter(GeoPoint geoPoint) { MapPosition mapPosition = new MapPosition(geoPoint, mMapViewPosition.getZoomLevel(), 1); + setCenterAndZoom(mapPosition); } @@ -562,12 +552,13 @@ public class MapView extends GLSurfaceView { int oldHeight) { mJobQueue.clear(); - + mCompass.disable(); mapWorkersPause(true); super.onSizeChanged(width, height, oldWidth, oldHeight); mapWorkersProceed(); + mCompass.enable(); } void destroy() { @@ -619,12 +610,18 @@ public class MapView extends GLSurfaceView { public void onPause() { super.onPause(); mapWorkersPause(false); + + if (this.enableCompass) + mCompass.disable(); } @Override public void onResume() { super.onResume(); mapWorkersProceed(); + + if (this.enableCompass) + mCompass.enable(); } /** @@ -634,7 +631,9 @@ public class MapView extends GLSurfaceView { * the new map position of this MapView. */ void setCenterAndZoom(MapPosition mapPosition) { - + Log.d(TAG, "setCenterAndZoom " + + " lat: " + mapPosition.lat + + " lon: " + mapPosition.lon); mMapViewPosition.setMapCenterAndZoomLevel(mapPosition); redrawTiles(); } @@ -687,8 +686,40 @@ public class MapView extends GLSurfaceView { public void enableRotation(boolean enable) { enableRotation = enable; + + if (enable && this.enableCompass) { + this.enableCompass = false; + mCompass.disable(); + } } + public void enableCompass(boolean enable) { + if (enable == this.enableCompass) + return; + + this.enableCompass = enable; + + if (enable) + this.enableRotation = false; + + if (enable) + mCompass.enable(); + else + mCompass.disable(); + + } + + // /** + // * Sets the visibility of the zoom controls. + // * + // * @param showZoomControls + // * true if the zoom controls should be visible, false otherwise. + // */ + // public void setBuiltInZoomControls(boolean showZoomControls) { + // mMapZoomControls.setShowMapZoomControls(showZoomControls); + // + // } + // public final int // public Handler messageHandler = new Handler() { // diff --git a/src/org/mapsforge/android/MapViewPosition.java b/src/org/mapsforge/android/MapViewPosition.java index e8f650eb..922febd7 100644 --- a/src/org/mapsforge/android/MapViewPosition.java +++ b/src/org/mapsforge/android/MapViewPosition.java @@ -60,6 +60,7 @@ public class MapViewPosition { if (!isValid()) { return null; } + // Log.d("MapViewPosition", "lat: " + mLatitude + " lon: " + mLongitude); return new MapPosition(mLatitude, mLongitude, mZoomLevel, mScale, mRotation); } @@ -113,7 +114,7 @@ public class MapViewPosition { double pixelY = MercatorProjection.latitudeToPixelY(mLatitude, mZoomLevel); double dx, dy; - if (mMapView.enableRotation) { + if (mMapView.enableRotation || mMapView.enableCompass) { float rad = (float) Math.toRadians(mRotation); dx = mx / mScale; dy = my / mScale; @@ -142,6 +143,10 @@ public class MapViewPosition { mRotation -= angle; } + public void setRotation(float f) { + mRotation = f; + } + synchronized void setMapCenter(GeoPoint geoPoint) { mLatitude = MercatorProjection.limitLatitude(geoPoint.getLatitude()); mLongitude = MercatorProjection.limitLongitude(geoPoint.getLongitude()); diff --git a/src/org/mapsforge/android/MapZoomControls.java b/src/org/mapsforge/android/MapZoomControls.java index 2d6ecbd3..0170e1a4 100644 --- a/src/org/mapsforge/android/MapZoomControls.java +++ b/src/org/mapsforge/android/MapZoomControls.java @@ -160,7 +160,7 @@ public class MapZoomControls { * true if the zoom controls should be visible, false otherwise. */ public void setShowMapZoomControls(boolean showMapZoomControls) { - mShowMapZoomControls = false; // showMapZoomControls; + mShowMapZoomControls = false; } /** diff --git a/src/org/mapsforge/android/glrenderer/MapRenderer.java b/src/org/mapsforge/android/glrenderer/MapRenderer.java index a9ce0e0a..087caaa8 100644 --- a/src/org/mapsforge/android/glrenderer/MapRenderer.java +++ b/src/org/mapsforge/android/glrenderer/MapRenderer.java @@ -461,8 +461,10 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer { if (MapView.debugFrameTime) start = SystemClock.uptimeMillis(); - mRotate = mMapView.enableRotation; - + if (mRotate != (mMapView.enableRotation || mMapView.enableCompass)) { + Matrix.setIdentityM(mMVPMatrix, 0); + mRotate = mMapView.enableRotation || mMapView.enableCompass; + } if (mUpdateColor && mClearColor != null) { glClearColor(mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]); mUpdateColor = false; diff --git a/src/org/mapsforge/android/glrenderer/QuadTree.java b/src/org/mapsforge/android/glrenderer/QuadTree.java index 27c8d0ee..5bf47fad 100644 --- a/src/org/mapsforge/android/glrenderer/QuadTree.java +++ b/src/org/mapsforge/android/glrenderer/QuadTree.java @@ -19,13 +19,18 @@ import android.util.Log; class QuadTree { private static String TAG = "QuadTree"; + // pointer to tile 0/0/0 private static QuadTree root; // parent pointer is used to link pool items private static QuadTree pool; - // TreeTile members QuadTree parent; + // .... x y + // 0 => 0 0 + // 1 => 1 0 + // 2 => 0 1 + // 3 => 1 1 final QuadTree[] child = new QuadTree[4]; int refs = 0; byte id; diff --git a/src/org/mapsforge/android/glrenderer/TileLoader.java b/src/org/mapsforge/android/glrenderer/TileLoader.java index 7fd85c1f..71b99837 100644 --- a/src/org/mapsforge/android/glrenderer/TileLoader.java +++ b/src/org/mapsforge/android/glrenderer/TileLoader.java @@ -79,10 +79,14 @@ class TileLoader { newTiles = new TilesData(numTiles); } - static void updateMap(boolean clear) { + static synchronized void updateMap(boolean clear) { boolean changedPos = false; boolean changedZoom = false; + + if (mMapView == null || mMapView.getMapPosition() == null) + return; + MapPosition mapPosition = mMapView.getMapPosition().getMapPosition(); if (mapPosition == null) { @@ -100,8 +104,6 @@ class TileLoader { mTiles.clear(); mTilesLoaded.clear(); QuadTree.init(); - // curTiles.cnt = 0; - // mBufferMemoryUsage = 0; } } @@ -161,24 +163,10 @@ class TileLoader { limitCache(mapPosition, remove); } - int size = mTilesLoaded.size(); - if (size > MAX_TILES_IN_QUEUE) - limitLoadQueue(size); + limitLoadQueue(); } - /** - * Manage tiles that have data to be uploaded to gl - * - * @param tile - * tile processed by MapGenerator - */ - static void addTileLoaded(MapTile tile) { - synchronized (mTilesLoaded) { - mTilesLoaded.add(tile); - } - } - private static boolean updateVisibleList(MapPosition mapPosition, int zdir) { double x = mapPosition.x; double y = mapPosition.y; @@ -398,7 +386,7 @@ class TileLoader { int removes = remove; int size = mTiles.size(); - int tmp = size; + // int tmp = size; // remove orphaned tiles for (int i = 0; i < size;) { @@ -417,7 +405,7 @@ class TileLoader { i++; } - Log.d(TAG, "remove tiles: " + removes + " " + size + " " + tmp); + // Log.d(TAG, "remove tiles: " + removes + " " + size + " " + tmp); if (removes <= 0) return; @@ -461,8 +449,11 @@ class TileLoader { } } - private static void limitLoadQueue(int remove) { - int size = remove; + private static void limitLoadQueue() { + int size = mTilesLoaded.size(); + + if (size < MAX_TILES_IN_QUEUE) + return; synchronized (mTilesLoaded) { @@ -481,8 +472,11 @@ class TileLoader { // clear loaded but not used tiles if (size < MAX_TILES_IN_QUEUE) return; + // Log.d(TAG, "queue: " + mTilesLoaded.size() + " " + size + " " + // + (size - MAX_TILES_IN_QUEUE / 2)); + + for (int i = 0, n = size - MAX_TILES_IN_QUEUE / 2; i < n; n--) { - for (int i = 0, n = size - MAX_TILES_IN_QUEUE + 20; i < n; i++) { MapTile t = mTilesLoaded.get(i); synchronized (t) { @@ -493,15 +487,28 @@ class TileLoader { if (tileInUse(t)) { // Log.d(TAG, "keep unused tile data: " + t + " " + t.isActive); + i++; continue; } + // Log.d(TAG, "remove unused tile data: " + t); mTilesLoaded.remove(i); mTiles.remove(t); - // Log.d(TAG, "remove unused tile data: " + t); clearTile(t); } } } } + + /** + * Manage tiles that have data to be uploaded to gl + * + * @param tile + * tile processed by MapGenerator + */ + static void addTileLoaded(MapTile tile) { + synchronized (mTilesLoaded) { + mTilesLoaded.add(tile); + } + } } diff --git a/src/org/mapsforge/app/LocationHandler.java b/src/org/mapsforge/app/LocationHandler.java new file mode 100644 index 00000000..310a8e34 --- /dev/null +++ b/src/org/mapsforge/app/LocationHandler.java @@ -0,0 +1,254 @@ +/* + * Copyright 2010, 2011, 2012 mapsforge.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 . + */ +package org.mapsforge.app; + +import org.mapsforge.core.GeoPoint; + +import android.content.Context; +import android.location.Criteria; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ToggleButton; + +public class LocationHandler { + private static final int DIALOG_LOCATION_PROVIDER_DISABLED = 2; + + private MyLocationListener mLocationListener; + private LocationManager mLocationManager; + private boolean mShowMyLocation; + + private ToggleButton mSnapToLocationView; + private boolean mSnapToLocation; + + /* package */final TileMap mTileMap; + + LocationHandler(TileMap tileMap) { + mTileMap = tileMap; + mLocationManager = (LocationManager) tileMap + .getSystemService(Context.LOCATION_SERVICE); + mLocationListener = new MyLocationListener(tileMap); + + mSnapToLocationView = (ToggleButton) tileMap + .findViewById(R.id.snapToLocationView); + + mSnapToLocationView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if (isSnapToLocationEnabled()) { + disableSnapToLocation(true); + } else { + enableSnapToLocation(true); + } + } + }); + } + + boolean enableShowMyLocation(boolean centerAtFirstFix) { + Log.d("TileMap", "enableShowMyLocation " + mShowMyLocation); + + if (!mShowMyLocation) { + Criteria criteria = new Criteria(); + criteria.setAccuracy(Criteria.ACCURACY_FINE); + String bestProvider = mLocationManager.getBestProvider(criteria, true); + + if (bestProvider == null) { + mTileMap.showDialog(DIALOG_LOCATION_PROVIDER_DISABLED); + return false; + } + + mShowMyLocation = true; + + Log.d("TileMap", "enableShowMyLocation " + mShowMyLocation); + + mLocationListener.setCenterAtFirstFix(centerAtFirstFix); + + mLocationManager.requestLocationUpdates(bestProvider, 1000, 0, + mLocationListener); + + mSnapToLocationView.setVisibility(View.VISIBLE); + + return true; + } + return false; + } + + void gotoLastKnownPosition() { + Location currentLocation; + Location bestLocation = null; + for (String provider : mLocationManager.getProviders(true)) { + currentLocation = mLocationManager.getLastKnownLocation(provider); + if (currentLocation == null) + continue; + if (bestLocation == null + || currentLocation.getAccuracy() < bestLocation.getAccuracy()) { + bestLocation = currentLocation; + } + } + + if (bestLocation != null) { + GeoPoint point = new GeoPoint(bestLocation.getLatitude(), + bestLocation.getLongitude()); + + mTileMap.mMapView.setCenter(point); + + } else { + mTileMap.showToastOnUiThread(mTileMap + .getString(R.string.error_last_location_unknown)); + } + } + + /** + * Disables the "show my location" mode. + * + * @return ... + */ + boolean disableShowMyLocation() { + if (mShowMyLocation) { + mShowMyLocation = false; + disableSnapToLocation(false); + + mLocationManager.removeUpdates(mLocationListener); + // if (circleOverlay != null) { + // mapView.getOverlays().remove(circleOverlay); + // mapView.getOverlays().remove(itemizedOverlay); + // circleOverlay = null; + // itemizedOverlay = null; + // } + + mSnapToLocationView.setVisibility(View.GONE); + + return true; + } + return false; + } + + /** + * Returns the status of the "show my location" mode. + * + * @return true if the "show my location" mode is enabled, false otherwise. + */ + boolean isShowMyLocationEnabled() { + return mShowMyLocation; + } + + /** + * Disables the "snap to location" mode. + * + * @param showToast + * defines whether a toast message is displayed or not. + */ + void disableSnapToLocation(boolean showToast) { + if (mSnapToLocation) { + mSnapToLocation = false; + mSnapToLocationView.setChecked(false); + + mTileMap.mMapView.setClickable(true); + + if (showToast) { + mTileMap.showToastOnUiThread(mTileMap + .getString(R.string.snap_to_location_disabled)); + } + } + } + + /** + * Enables the "snap to location" mode. + * + * @param showToast + * defines whether a toast message is displayed or not. + */ + void enableSnapToLocation(boolean showToast) { + if (!mSnapToLocation) { + mSnapToLocation = true; + + mTileMap.mMapView.setClickable(false); + + if (showToast) { + mTileMap.showToastOnUiThread(mTileMap + .getString(R.string.snap_to_location_enabled)); + } + } + } + + /** + * Returns the status of the "snap to location" mode. + * + * @return true if the "snap to location" mode is enabled, false otherwise. + */ + boolean isSnapToLocationEnabled() { + return mSnapToLocation; + } + + class MyLocationListener implements LocationListener { + private final TileMap tileMap; + private boolean centerAtFirstFix; + + MyLocationListener(TileMap tileMap) { + this.tileMap = tileMap; + } + + @Override + public void onLocationChanged(Location location) { + + Log.d("LocationListener", "onLocationChanged, " + + " lon:" + location.getLongitude() + + " lat:" + location.getLatitude()); + + if (!isShowMyLocationEnabled()) { + return; + } + + GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude()); + + // this.advancedMapViewer.overlayCircle.setCircleData(point, location.getAccuracy()); + // this.advancedMapViewer.overlayItem.setPoint(point); + // this.advancedMapViewer.circleOverlay.requestRedraw(); + // this.advancedMapViewer.itemizedOverlay.requestRedraw(); + + if (this.centerAtFirstFix || isSnapToLocationEnabled()) { + this.centerAtFirstFix = false; + this.tileMap.mMapView.setCenter(point); + } + } + + @Override + public void onProviderDisabled(String provider) { + // do nothing + } + + @Override + public void onProviderEnabled(String provider) { + // do nothing + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // do nothing + } + + boolean isCenterAtFirstFix() { + return this.centerAtFirstFix; + } + + void setCenterAtFirstFix(boolean centerAtFirstFix) { + this.centerAtFirstFix = centerAtFirstFix; + } + } +} diff --git a/src/org/mapsforge/app/MyLocationListener.java b/src/org/mapsforge/app/MyLocationListener.java deleted file mode 100644 index 88e9c525..00000000 --- a/src/org/mapsforge/app/MyLocationListener.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010, 2011, 2012 mapsforge.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 . - */ -package org.mapsforge.app; - -import org.mapsforge.core.GeoPoint; - -import android.location.Location; -import android.location.LocationListener; -import android.os.Bundle; - -class MyLocationListener implements LocationListener { - private final TileMap advancedMapViewer; - private boolean centerAtFirstFix; - - MyLocationListener(TileMap advancedMapViewer) { - this.advancedMapViewer = advancedMapViewer; - } - - @Override - public void onLocationChanged(Location location) { - if (!this.advancedMapViewer.isShowMyLocationEnabled()) { - return; - } - - GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude()); - // this.advancedMapViewer.overlayCircle.setCircleData(point, location.getAccuracy()); - // this.advancedMapViewer.overlayItem.setPoint(point); - // this.advancedMapViewer.circleOverlay.requestRedraw(); - // this.advancedMapViewer.itemizedOverlay.requestRedraw(); - if (this.centerAtFirstFix || this.advancedMapViewer.isSnapToLocationEnabled()) { - this.centerAtFirstFix = false; - this.advancedMapViewer.mMapController.setCenter(point); - } - } - - @Override - public void onProviderDisabled(String provider) { - // do nothing - } - - @Override - public void onProviderEnabled(String provider) { - // do nothing - } - - @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - // do nothing - } - - boolean isCenterAtFirstFix() { - return this.centerAtFirstFix; - } - - void setCenterAtFirstFix(boolean centerAtFirstFix) { - this.centerAtFirstFix = centerAtFirstFix; - } -} diff --git a/src/org/mapsforge/app/SeekBarChangeListener.java b/src/org/mapsforge/app/SeekBarChangeListener.java deleted file mode 100644 index 83862afa..00000000 --- a/src/org/mapsforge/app/SeekBarChangeListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010, 2011, 2012 mapsforge.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 . - */ -package org.mapsforge.app; - -import android.widget.SeekBar; -import android.widget.TextView; - -class SeekBarChangeListener implements SeekBar.OnSeekBarChangeListener { - private final TextView textView; - - SeekBarChangeListener(TextView textView) { - this.textView = textView; - } - - @Override - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - this.textView.setText(String.valueOf(progress)); - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - // do nothing - } - - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - // do nothing - } -} diff --git a/src/org/mapsforge/app/TileMap.java b/src/org/mapsforge/app/TileMap.java index 87c62ec6..60251b3b 100755 --- a/src/org/mapsforge/app/TileMap.java +++ b/src/org/mapsforge/app/TileMap.java @@ -7,7 +7,6 @@ import java.util.Date; import org.mapsforge.android.DebugSettings; import org.mapsforge.android.MapActivity; -import org.mapsforge.android.MapController; import org.mapsforge.android.MapView; import org.mapsforge.android.mapgenerator.MapDatabases; import org.mapsforge.android.rendertheme.InternalRenderTheme; @@ -30,9 +29,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.location.Criteria; -import android.location.Location; -import android.location.LocationManager; +import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; import android.os.PowerManager; @@ -71,14 +68,12 @@ public class TileMap extends MapActivity { new FilterByFileExtension(".xml"); private static final int SELECT_MAP_FILE = 0; private static final int SELECT_RENDER_THEME_FILE = 1; - private LocationManager mLocationManager; + + LocationHandler mLocation; + private MapDatabases mMapDatabase; - private MyLocationListener mMyLocationListener; - private boolean mShowMyLocation; - private boolean mSnapToLocation; - // private ToggleButton mSnapToLocationView; + private WakeLock mWakeLock; - MapController mMapController; MapView mMapView; private Menu mMenu = null; @@ -108,36 +103,48 @@ public class TileMap extends MapActivity { case R.id.menu_rotation_enable: mMapView.enableRotation(true); + toggleMenuRotation(mMenu, + mMapView.enableRotation, + mMapView.enableCompass); + return true; + + case R.id.menu_rotation_disable: + mMapView.enableRotation(false); + toggleMenuRotation(mMenu, + mMapView.enableRotation, + mMapView.enableCompass); + return true; + + case R.id.menu_compass_enable: + mMapView.enableCompass(true); + toggleMenuRotation(mMenu, + mMapView.enableRotation, + mMapView.enableCompass); + return true; + + case R.id.menu_compass_disable: + mMapView.enableCompass(false); + toggleMenuRotation(mMenu, + mMapView.enableRotation, + mMapView.enableCompass); return true; case R.id.menu_position_my_location_enable: - if (enableShowMyLocation(true)) { - mMenu.findItem(R.id.menu_position_my_location_enable) - .setVisible(false); - mMenu.findItem(R.id.menu_position_my_location_enable) - .setEnabled(false); - mMenu.findItem(R.id.menu_position_my_location_disable) - .setVisible(true); - mMenu.findItem(R.id.menu_position_my_location_disable) - .setEnabled(true); - } + toggleMenuItem(mMenu, + R.id.menu_position_my_location_enable, + R.id.menu_position_my_location_disable, + !mLocation.enableShowMyLocation(true)); return true; case R.id.menu_position_my_location_disable: - if (disableShowMyLocation()) { - mMenu.findItem(R.id.menu_position_my_location_enable) - .setVisible(true); - mMenu.findItem(R.id.menu_position_my_location_enable) - .setEnabled(true); - mMenu.findItem(R.id.menu_position_my_location_disable) - .setVisible(false); - mMenu.findItem(R.id.menu_position_my_location_disable) - .setEnabled(false); - } + toggleMenuItem(mMenu, + R.id.menu_position_my_location_enable, + R.id.menu_position_my_location_disable, + mLocation.disableShowMyLocation()); return true; case R.id.menu_position_last_known: - gotoLastKnownPosition(); + mLocation.gotoLastKnownPosition(); return true; case R.id.menu_position_enter_coordinates: @@ -146,8 +153,9 @@ public class TileMap extends MapActivity { case R.id.menu_position_map_center: // disable GPS follow mode if it is enabled - disableSnapToLocation(true); - mMapController.setCenter(mMapView.getMapDatabase() + mLocation.disableSnapToLocation(true); + + mMapView.setCenter(mMapView.getMapDatabase() .getMapFileInfo().mapCenter); return true; @@ -182,38 +190,68 @@ public class TileMap extends MapActivity { } } + private static void toggleMenuRotation(Menu menu, boolean rotate, boolean compass) { + toggleMenuItem(menu, + R.id.menu_rotation_enable, + R.id.menu_rotation_disable, + !rotate); + + toggleMenuItem(menu, + R.id.menu_compass_enable, + R.id.menu_compass_disable, + !compass); + } + + private static void toggleMenuItem(Menu menu, int id, int id2, boolean enable) { + menu.findItem(id).setVisible(enable); + menu.findItem(id).setEnabled(enable); + menu.findItem(id2).setVisible(!enable); + menu.findItem(id2).setEnabled(!enable); + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); onCreateOptionsMenu(menu); - Log.d("TileMap", "prepare options..."); + toggleMenuItem(menu, + R.id.menu_position_my_location_enable, + R.id.menu_position_my_location_disable, + !mLocation.isShowMyLocationEnabled()); - // menu.findItem(R.id.menu_info_map_file).setEnabled(true); + // if (mLocation.isShowMyLocationEnabled()) { + // menu.findItem(R.id.menu_position_my_location_enable).setVisible(false); + // menu.findItem(R.id.menu_position_my_location_enable).setEnabled(false); + // menu.findItem(R.id.menu_position_my_location_disable).setVisible(true); + // menu.findItem(R.id.menu_position_my_location_disable).setEnabled(true); + // } else { + // menu.findItem(R.id.menu_position_my_location_enable).setVisible(true); + // menu.findItem(R.id.menu_position_my_location_enable).setEnabled(true); + // menu.findItem(R.id.menu_position_my_location_disable).setVisible(false); + // menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false); + // } - if (isShowMyLocationEnabled()) { - menu.findItem(R.id.menu_position_my_location_enable).setVisible(false); - menu.findItem(R.id.menu_position_my_location_enable).setEnabled(false); - menu.findItem(R.id.menu_position_my_location_disable).setVisible(true); - menu.findItem(R.id.menu_position_my_location_disable).setEnabled(true); + menu.findItem(R.id.menu_render_theme).setEnabled(true); + + if (mMapDatabase == MapDatabases.MAP_READER) { + menu.findItem(R.id.menu_mapfile).setVisible(true); + menu.findItem(R.id.menu_position_map_center).setVisible(true); } else { - menu.findItem(R.id.menu_position_my_location_enable).setVisible(true); - menu.findItem(R.id.menu_position_my_location_enable).setEnabled(true); - menu.findItem(R.id.menu_position_my_location_disable).setVisible(false); - menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false); + menu.findItem(R.id.menu_mapfile).setVisible(false); + menu.findItem(R.id.menu_position_map_center).setVisible(false); } - menu.findItem(R.id.menu_position_map_center).setEnabled(true); - menu.findItem(R.id.menu_render_theme).setEnabled(true); - // menu.findItem(R.id.menu_mapfile).setEnabled(true); + toggleMenuItem(menu, + R.id.menu_compass_enable, + R.id.menu_compass_disable, + !mMapView.enableCompass); - if (mMapDatabase == MapDatabases.MAP_READER) - menu.findItem(R.id.menu_mapfile).setVisible(true); - else - menu.findItem(R.id.menu_mapfile).setVisible(false); + toggleMenuItem(mMenu, + R.id.menu_rotation_enable, + R.id.menu_rotation_disable, + !mMapView.enableRotation); return super.onPrepareOptionsMenu(menu); - // return true; } @Override @@ -225,52 +263,8 @@ public class TileMap extends MapActivity { private void configureMapView() { // configure the MapView and activate the zoomLevel buttons mMapView.setClickable(true); - mMapView.setBuiltInZoomControls(true); + // mMapView.setBuiltInZoomControls(true); mMapView.setFocusable(true); - - mMapController = mMapView.getController(); - } - - private boolean enableShowMyLocation(boolean centerAtFirstFix) { - if (!mShowMyLocation) { - Criteria criteria = new Criteria(); - criteria.setAccuracy(Criteria.ACCURACY_FINE); - String bestProvider = mLocationManager.getBestProvider(criteria, true); - if (bestProvider == null) { - showDialog(DIALOG_LOCATION_PROVIDER_DISABLED); - return false; - } - - mShowMyLocation = true; - mMyLocationListener.setCenterAtFirstFix(centerAtFirstFix); - mLocationManager.requestLocationUpdates(bestProvider, 1000, 0, - mMyLocationListener); - // mSnapToLocationView.setVisibility(View.VISIBLE); - return true; - } - return false; - } - - private void gotoLastKnownPosition() { - Location currentLocation; - Location bestLocation = null; - for (String provider : mLocationManager.getProviders(true)) { - currentLocation = mLocationManager.getLastKnownLocation(provider); - if (currentLocation == null) - continue; - if (bestLocation == null - || currentLocation.getAccuracy() < bestLocation.getAccuracy()) { - bestLocation = currentLocation; - } - } - - if (bestLocation != null) { - GeoPoint point = new GeoPoint(bestLocation.getLatitude(), - bestLocation.getLongitude()); - mMapController.setCenter(point); - } else { - showToastOnUiThread(getString(R.string.error_last_location_unknown)); - } } private void startMapFilePicker() { @@ -291,7 +285,7 @@ public class TileMap extends MapActivity { if (requestCode == SELECT_MAP_FILE) { if (resultCode == RESULT_OK) { - disableSnapToLocation(true); + mLocation.disableSnapToLocation(true); if (intent != null) { if (intent.getStringExtra(FilePicker.SELECTED_FILE) != null) { @@ -301,9 +295,6 @@ public class TileMap extends MapActivity { } } else if (resultCode == RESULT_CANCELED) { startActivity(new Intent(this, EditPreferences.class)); - // && !mapView.getMapGenerator().requiresInternetConnection() - // && mapView.getMapFile() == null) { - // finish(); } } else if (requestCode == SELECT_RENDER_THEME_FILE && resultCode == RESULT_OK && intent != null @@ -334,41 +325,30 @@ public class TileMap extends MapActivity { } // set up the layout views - setContentView(R.layout.activity_advanced_map_viewer); + setContentView(R.layout.activity_tilemap); // getActionBar().setDisplayOptions(ActionBar.NAVIGATION_MODE_TABS); mMapView = (MapView) findViewById(R.id.mapView); + configureMapView(); - // mSnapToLocationView = (ToggleButton) findViewById(R.id.snapToLocationView); - // - // mSnapToLocationView.setOnClickListener(new OnClickListener() { - // @Override - // public void onClick(View view) { - // if (isSnapToLocationEnabled()) { - // disableSnapToLocation(true); - // } else { - // enableSnapToLocation(true); - // } - // } - // }); + mLocation = new LocationHandler(this); // get the pointers to different system services - mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); - mMyLocationListener = new MyLocationListener(this); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); + mWakeLock = powerManager .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "AMV"); if (savedInstanceState != null) { if (savedInstanceState.getBoolean(BUNDLE_SHOW_MY_LOCATION)) { - enableShowMyLocation(savedInstanceState - .getBoolean(BUNDLE_CENTER_AT_FIRST_FIX)); + // enableShowMyLocation(savedInstanceState + // .getBoolean(BUNDLE_CENTER_AT_FIRST_FIX)); if (savedInstanceState.getBoolean(BUNDLE_SNAP_TO_LOCATION)) { - enableSnapToLocation(false); + mLocation.enableSnapToLocation(false); } } } @@ -383,12 +363,13 @@ public class TileMap extends MapActivity { LayoutInflater factory = LayoutInflater.from(this); final View view = factory.inflate(R.layout.dialog_enter_coordinates, null); builder.setView(view); + builder.setPositiveButton(R.string.go_to_position, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // disable GPS follow mode if it is enabled - disableSnapToLocation(true); + mLocation.disableSnapToLocation(true); // set the map center and zoom level EditText latitudeView = (EditText) view @@ -400,11 +381,13 @@ public class TileMap extends MapActivity { double longitude = Double.parseDouble(longitudeView.getText() .toString()); GeoPoint geoPoint = new GeoPoint(latitude, longitude); - TileMap.this.mMapController.setCenter(geoPoint); + TileMap.this.mMapView.setCenter(geoPoint); SeekBar zoomLevelView = (SeekBar) view .findViewById(R.id.zoomLevel); - TileMap.this.mMapController.setZoom(zoomLevelView - .getProgress()); + + TileMap.this.mMapView.zoom((byte) (zoomLevelView + .getProgress() - mMapView.getMapPosition() + .getZoomLevel())); } }); builder.setNegativeButton(R.string.cancel, null); @@ -431,7 +414,7 @@ public class TileMap extends MapActivity { @Override protected void onDestroy() { super.onDestroy(); - disableShowMyLocation(); + mLocation.disableShowMyLocation(); } @Override @@ -587,6 +570,13 @@ public class TileMap extends MapActivity { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } + if (preferences.getBoolean("fixOrientation", true)) { + this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + // this all returns the orientation which is not currently active?! + // getWindow().getWindowManager().getDefaultDisplay().getRotation()); + // getWindow().getWindowManager().getDefaultDisplay().getOrientation()); + } + if (preferences.getBoolean("wakeLock", false) && !mWakeLock.isHeld()) { mWakeLock.acquire(); } @@ -628,83 +618,11 @@ public class TileMap extends MapActivity { @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, isShowMyLocationEnabled()); - outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX, - mMyLocationListener.isCenterAtFirstFix()); - outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation); - } + outState.putBoolean(BUNDLE_SHOW_MY_LOCATION, mLocation.isShowMyLocationEnabled()); + // outState.putBoolean(BUNDLE_CENTER_AT_FIRST_FIX, + // mMyLocationListener.isCenterAtFirstFix()); - /** - * Disables the "show my location" mode. - * - * @return ... - */ - private boolean disableShowMyLocation() { - if (mShowMyLocation) { - mShowMyLocation = false; - disableSnapToLocation(false); - mLocationManager.removeUpdates(mMyLocationListener); - // if (circleOverlay != null) { - // mapView.getOverlays().remove(circleOverlay); - // mapView.getOverlays().remove(itemizedOverlay); - // circleOverlay = null; - // itemizedOverlay = null; - // } - // mSnapToLocationView.setVisibility(View.GONE); - return true; - } - return false; - } - - /** - * Disables the "snap to location" mode. - * - * @param showToast - * defines whether a toast message is displayed or not. - */ - void disableSnapToLocation(boolean showToast) { - if (mSnapToLocation) { - mSnapToLocation = false; - // mSnapToLocationView.setChecked(false); - mMapView.setClickable(true); - if (showToast) { - showToastOnUiThread(getString(R.string.snap_to_location_disabled)); - } - } - } - - /** - * Enables the "snap to location" mode. - * - * @param showToast - * defines whether a toast message is displayed or not. - */ - void enableSnapToLocation(boolean showToast) { - if (!mSnapToLocation) { - mSnapToLocation = true; - mMapView.setClickable(false); - if (showToast) { - showToastOnUiThread(getString(R.string.snap_to_location_enabled)); - } - } - } - - /** - * Returns the status of the "show my location" mode. - * - * @return true if the "show my location" mode is enabled, false otherwise. - */ - boolean isShowMyLocationEnabled() { - return mShowMyLocation; - } - - /** - * Returns the status of the "snap to location" mode. - * - * @return true if the "snap to location" mode is enabled, false otherwise. - */ - boolean isSnapToLocationEnabled() { - return mSnapToLocation; + // outState.putBoolean(BUNDLE_SNAP_TO_LOCATION, mSnapToLocation); } /** @@ -734,4 +652,28 @@ public class TileMap extends MapActivity { // // TODO Auto-generated method stub // return false; // } + + class SeekBarChangeListener implements SeekBar.OnSeekBarChangeListener { + private final TextView textView; + + SeekBarChangeListener(TextView textView) { + this.textView = textView; + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + this.textView.setText(String.valueOf(progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + // do nothing + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + // do nothing + } + } + }