From fc1c6eee8b082d2c2997e4536303abdfc0aed866 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 13 Jun 2011 02:12:56 +0200 Subject: [PATCH] Version 0.6.5. Fix first location after onResume.Fix exit functionality. --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 10 ---------- .../src/net/osmand/plus/activities/MapActivity.java | 12 +++++++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b4d74196f2..30eae054bb 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -689,7 +689,6 @@ public class OsmandSettings { // This value is a key for saving last known location shown on the map public static final String LAST_KNOWN_MAP_LAT = "last_known_map_lat"; //$NON-NLS-1$ public static final String LAST_KNOWN_MAP_LON = "last_known_map_lon"; //$NON-NLS-1$ - public static final String IS_MAP_SYNC_TO_GPS_LOCATION = "is_map_sync_to_gps_location"; //$NON-NLS-1$ public static final String LAST_KNOWN_MAP_ZOOM = "last_known_map_zoom"; //$NON-NLS-1$ public static final String MAP_LAT_TO_SHOW = "map_lat_to_show"; //$NON-NLS-1$ @@ -733,7 +732,6 @@ public class OsmandSettings { edit.putFloat(MAP_LAT_TO_SHOW, (float) latitude); edit.putFloat(MAP_LON_TO_SHOW, (float) longitude); edit.putInt(MAP_ZOOM_TO_SHOW, zoom); - edit.putBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, false); edit.commit(); if(historyDescription != null){ SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx); @@ -752,14 +750,6 @@ public class OsmandSettings { edit.commit(); } - public boolean setSyncMapToGpsLocation(boolean value) { - return globalPreferences.edit().putBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, value).commit(); - } - - public boolean isMapSyncToGpsLocation() { - return globalPreferences.getBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, true); - } - public int getLastKnownMapZoom() { return globalPreferences.getInt(LAST_KNOWN_MAP_ZOOM, 5); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 06c09075e1..42a095e8a6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -126,9 +126,10 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso // Store previous map rotation settings for rotate button private Integer previousMapRotate = null; + private boolean isMapLinkedToLocation = false; private boolean isMapLinkedToLocation(){ - return settings.isMapSyncToGpsLocation(); + return isMapLinkedToLocation; } private Notification getNotification(){ @@ -446,7 +447,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso backToLocation.setVisibility(View.INVISIBLE); PointLocationLayer locationLayer = mapLayers.getLocationLayer(); if(!isMapLinkedToLocation()){ - settings.setSyncMapToGpsLocation(true); + isMapLinkedToLocation = true; if(locationLayer.getLastKnownLocation() != null){ Location lastKnownLocation = locationLayer.getLastKnownLocation(); AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread(); @@ -756,10 +757,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso mapLayers.getPoiMapLayer().setFilter(settings.getPoiFilterForMap((OsmandApplication) getApplication())); backToLocation.setVisibility(View.INVISIBLE); - if(isMapLinkedToLocation() && !routingHelper.isFollowingMode()){ + isMapLinkedToLocation = false; + if(routingHelper.isFollowingMode()){ // by default turn off causing unexpected movements due to network establishing // best to show previous location - settings.setSyncMapToGpsLocation(false); + isMapLinkedToLocation = true; } routingHelper.setUiActivity(this); @@ -868,7 +870,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso // when user start dragging if(mapLayers.getLocationLayer().getLastKnownLocation() != null){ if(isMapLinkedToLocation()){ - settings.setSyncMapToGpsLocation(false); + isMapLinkedToLocation = false; } if (backToLocation.getVisibility() != View.VISIBLE) { runOnUiThread(new Runnable() {