Version 0.6.5. Fix first location after onResume.Fix exit functionality.

This commit is contained in:
Victor Shcherb 2011-06-13 02:12:56 +02:00
parent 2f1d7cf6c5
commit fc1c6eee8b
2 changed files with 7 additions and 15 deletions

View file

@ -689,7 +689,6 @@ public class OsmandSettings {
// This value is a key for saving last known location shown on the map // 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_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 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 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$ 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_LAT_TO_SHOW, (float) latitude);
edit.putFloat(MAP_LON_TO_SHOW, (float) longitude); edit.putFloat(MAP_LON_TO_SHOW, (float) longitude);
edit.putInt(MAP_ZOOM_TO_SHOW, zoom); edit.putInt(MAP_ZOOM_TO_SHOW, zoom);
edit.putBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, false);
edit.commit(); edit.commit();
if(historyDescription != null){ if(historyDescription != null){
SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx); SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx);
@ -752,14 +750,6 @@ public class OsmandSettings {
edit.commit(); 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() { public int getLastKnownMapZoom() {
return globalPreferences.getInt(LAST_KNOWN_MAP_ZOOM, 5); return globalPreferences.getInt(LAST_KNOWN_MAP_ZOOM, 5);
} }

View file

@ -126,9 +126,10 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
// Store previous map rotation settings for rotate button // Store previous map rotation settings for rotate button
private Integer previousMapRotate = null; private Integer previousMapRotate = null;
private boolean isMapLinkedToLocation = false;
private boolean isMapLinkedToLocation(){ private boolean isMapLinkedToLocation(){
return settings.isMapSyncToGpsLocation(); return isMapLinkedToLocation;
} }
private Notification getNotification(){ private Notification getNotification(){
@ -446,7 +447,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
backToLocation.setVisibility(View.INVISIBLE); backToLocation.setVisibility(View.INVISIBLE);
PointLocationLayer locationLayer = mapLayers.getLocationLayer(); PointLocationLayer locationLayer = mapLayers.getLocationLayer();
if(!isMapLinkedToLocation()){ if(!isMapLinkedToLocation()){
settings.setSyncMapToGpsLocation(true); isMapLinkedToLocation = true;
if(locationLayer.getLastKnownLocation() != null){ if(locationLayer.getLastKnownLocation() != null){
Location lastKnownLocation = locationLayer.getLastKnownLocation(); Location lastKnownLocation = locationLayer.getLastKnownLocation();
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread(); AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
@ -756,10 +757,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
mapLayers.getPoiMapLayer().setFilter(settings.getPoiFilterForMap((OsmandApplication) getApplication())); mapLayers.getPoiMapLayer().setFilter(settings.getPoiFilterForMap((OsmandApplication) getApplication()));
backToLocation.setVisibility(View.INVISIBLE); backToLocation.setVisibility(View.INVISIBLE);
if(isMapLinkedToLocation() && !routingHelper.isFollowingMode()){ isMapLinkedToLocation = false;
if(routingHelper.isFollowingMode()){
// by default turn off causing unexpected movements due to network establishing // by default turn off causing unexpected movements due to network establishing
// best to show previous location // best to show previous location
settings.setSyncMapToGpsLocation(false); isMapLinkedToLocation = true;
} }
routingHelper.setUiActivity(this); routingHelper.setUiActivity(this);
@ -868,7 +870,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
// when user start dragging // when user start dragging
if(mapLayers.getLocationLayer().getLastKnownLocation() != null){ if(mapLayers.getLocationLayer().getLastKnownLocation() != null){
if(isMapLinkedToLocation()){ if(isMapLinkedToLocation()){
settings.setSyncMapToGpsLocation(false); isMapLinkedToLocation = false;
} }
if (backToLocation.getVisibility() != View.VISIBLE) { if (backToLocation.getVisibility() != View.VISIBLE) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {