fix some problems

git-svn-id: https://osmand.googlecode.com/svn/trunk@145 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-09 08:54:24 +00:00
parent f338898513
commit 88b46f6489
15 changed files with 188 additions and 112 deletions

View file

@ -16,6 +16,16 @@ public class ToDoConstants {
// }
// }
// PREPARE RELEASE OPTIONS LIST :
// 1. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
// 2. Translation (support russian)
// 3. POI Search ( 1) predefined filters, 2) choose subtype's, 3) filter by name, 4) opening hours (filter))
// 4. Support old-versionned resources (1) odb indexes, 2) favourites table, 3) atomic settings (?))
// 5. Swing refactoring MapPanel (support layers)
// 6. Support vector road rendering (new index file)
// 7. Suppport navigation for calculated route.
// 8. Editing POI on map
/**
@ -34,15 +44,21 @@ public class ToDoConstants {
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
// 33. Build transport locations (investigate)
// 34. Investigate routing (bicycle, car)
// 35. Enable trackball navigation in android
// 36. Postcode search
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
// 38. Add Button in search navigate to.
// BUGS Android
// 1. Fix bug with navigation layout (less zoom controls) (fixed).
// 4. Fix layout problems with add comment (fixed)
// 3. Implement clear existing area with tiles (update map)
// 2. Include to amenity index : historic, sport, ....
// 4. Fix layout problems with add comment
// 5. Implement caching files existing on FS, implement specific method in RM
// 7. Fix set location (clear sync with gps)
// Improvements
// 6. Implement context menu for long press & trackball press
// TODO swing
@ -60,6 +76,7 @@ public class ToDoConstants {
// 29. Show opened/closed amenities (in search poi).
// 3. Revise osmand UI. Preparing new icons (revise UI 18, 2, ). Main application icon, back to location icon.
// 14. Show zoom level on map
// 35. Enable trackball navigation in android
// DONE SWING
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry excluding="**/MapPanel*|com/osmand/LogUtil.java|com/osmand/osm/io/OSMStorageWriter.java|com/osmand/DataExtraction.java|com/osmand/swing/|com/osmand/data/preparation/DataExtraction.java|com/osmand/data/preparation/DataIndexBuilder.java|com/osmand/osm/io/OsmStorageWriter.java|test/|com/osmand/ExceptionHandler.java" kind="src" path="use"/>
<classpathentry excluding="**/MapPanel*|com/osmand/LogUtil.java|com/osmand/osm/io/OSMStorageWriter.java|com/osmand/DataExtraction.java|com/osmand/swing/|com/osmand/data/preparation/DataExtraction.java|com/osmand/data/preparation/DataIndexBuilder.java|com/osmand/osm/io/OsmStorageWriter.java|test/|com/osmand/ExceptionHandler.java|com/osmand/osm/util/" kind="src" path="use"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/bzip2-20090327.jar"/>

View file

@ -4,18 +4,18 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TextView android:id="@+id/TextView03" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="Input latitude &amp; longitude in the selected format (D - degrees, M - minutes, S - seconds)" android:layout_marginTop="10dp" android:layout_marginBottom="10dp"></TextView>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/TextView01" android:layout_width="130dp" android:layout_height="wrap_content" android:text="Latitude" android:layout_marginLeft="5dp"></TextView>
<TextView android:id="@+id/TextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="Input latitude &amp; longitude in the selected format (D - degrees, M - minutes, S - seconds)" android:layout_marginTop="10dp" android:layout_marginBottom="10dp"></TextView>
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/TextView" android:layout_width="130dp" android:layout_height="wrap_content" android:text="Latitude" android:layout_marginLeft="5dp"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/LatitudeEdit" android:layout_marginRight="5dp" android:inputType="number|time"></EditText>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:text="Longitude" android:id="@+id/TextView02" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp"></TextView>
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:text="Longitude" android:id="@+id/TextView" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/LongitudeEdit" android:layout_marginRight="5dp" android:inputType="number|time"></EditText>
</LinearLayout>
<RadioGroup android:id="@+id/RadioGroup01" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<RadioGroup android:id="@+id/RadioGroup" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="DDD.DDD" android:id="@+id/Format1" ></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Format2" android:text="DDD:MM.MMM" ></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Format3" android:text="DDD:MM:SS.SSS"></RadioButton>
@ -23,7 +23,7 @@
<TextView android:id="@+id/ValidateTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:gravity="center" android:textColor="@color/color_red"></TextView>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"
android:gravity="bottom|center">
<Button android:layout_width="125dp" android:layout_height="wrap_content" android:text="Show on map" android:id="@+id/ShowOnMap"></Button>
<Button android:layout_width="125dp" android:layout_height="wrap_content" android:text="Cancel" android:id="@+id/Cancel"></Button>

View file

@ -4,18 +4,19 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TextView android:id="@+id/TextView03" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="Input latitude &amp; longitude in the selected format (D - degrees, M - minutes, S - seconds)" android:layout_marginTop="10dp" android:layout_marginBottom="10dp"></TextView>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/TextView01" android:layout_width="130dp" android:layout_height="wrap_content" android:text="Latitude" android:layout_marginLeft="5dp"></TextView>
<TextView android:id="@+id/TextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="Input latitude &amp; longitude in the selected format (D - degrees, M - minutes, S - seconds)" android:layout_marginTop="10dp" android:layout_marginBottom="10dp"></TextView>
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/TextView" android:layout_width="130dp" android:layout_height="wrap_content" android:text="Latitude" android:layout_marginLeft="5dp"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/LatitudeEdit" android:layout_marginRight="5dp" android:inputType="number|time"></EditText>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:text="Longitude" android:id="@+id/TextView02" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/LongitudeEdit" android:layout_marginRight="5dp" android:inputType="number|time"></EditText>
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:text="Longitude" android:id="@+id/TextView" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/LongitudeEdit" android:layout_marginRight="5dp" android:inputType="number|time">
</EditText>
</LinearLayout>
<RadioGroup android:id="@+id/RadioGroup01" android:layout_marginLeft="70dp" android:layout_marginTop="5dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<RadioGroup android:id="@+id/RadioGroup" android:layout_marginLeft="70dp" android:layout_marginTop="5dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="DDD.DDDDD" android:id="@+id/Format1" ></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Format2" android:text="DDD:MM.MMMMM" ></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Format3" android:text="DDD:MM:SS.SSSSS"></RadioButton>
@ -24,7 +25,7 @@
<TextView android:id="@+id/ValidateTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:gravity="center" android:textColor="@color/color_red"></TextView>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"
android:gravity="bottom|center">
<Button android:layout_width="125dp" android:layout_height="wrap_content" android:text="Show on map" android:id="@+id/ShowOnMap"></Button>
<Button android:layout_width="125dp" android:layout_height="wrap_content" android:text="Cancel" android:id="@+id/Cancel"></Button>

View file

@ -2,19 +2,20 @@
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:stretchColumns="1">
<TableRow >
android:layout_height="fill_parent">
<TableRow>
<TextView android:id="@+id/TextView" android:layout_marginLeft="5dp"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Message"></TextView>
android:layout_height="wrap_content" android:text="Message"></TextView>
<EditText android:text="" android:id="@+id/BugMessage" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
android:layout_height="wrap_content" android:layout_weight="1"></EditText>
</TableRow>
<TableRow >
<TableRow>
<TextView android:text="Author name" android:id="@+id/TextView" android:layout_marginLeft="5dp"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
android:layout_height="wrap_content"></TextView>
<EditText android:text="NoName" android:id="@+id/AuthorName" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
android:layout_height="wrap_content" android:layout_weight="1"></EditText>
</TableRow>
</TableLayout>

View file

@ -122,6 +122,7 @@ 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";
public static final String LAST_KNOWN_MAP_LON = "last_known_map_lon";
public static final String IS_MAP_SYNC_TO_GPS_LOCATION = "is_map_sync_to_gps_location";
public static final String LAST_KNOWN_MAP_ZOOM = "last_known_map_zoom";
public static LatLon getLastKnownMapLocation(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
@ -130,6 +131,16 @@ public class OsmandSettings {
return new LatLon(lat, lon);
}
public static void setMapLocationToShow(Context ctx, double latitude, double longitude){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
Editor edit = prefs.edit();
edit.putFloat(LAST_KNOWN_MAP_LAT, (float) latitude);
edit.putFloat(LAST_KNOWN_MAP_LON, (float) longitude);
edit.putBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, false);
edit.commit();
}
// Do not use that method if you want to show point on map. Use setMapLocationToShow
public static void setLastKnownMapLocation(Context ctx, double latitude, double longitude){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
Editor edit = prefs.edit();
@ -138,6 +149,15 @@ public class OsmandSettings {
edit.commit();
}
public static boolean setSyncMapToGpsLocation(Context ctx, boolean value){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().putBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, value).commit();
}
public static boolean isMapSyncToGpsLocation(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getBoolean(IS_MAP_SYNC_TO_GPS_LOCATION, true);
}
public static int getLastKnownMapZoom(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getInt(LAST_KNOWN_MAP_ZOOM, 3);
@ -150,6 +170,30 @@ public class OsmandSettings {
edit.commit();
}
public final static String POINT_NAVIGATE_LAT = "point_navigate_lat";
public final static String POINT_NAVIGATE_LON = "point_navigate_lon";
public static LatLon getPointToNavigate(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
float lat = prefs.getFloat(POINT_NAVIGATE_LAT, 0);
float lon = prefs.getFloat(POINT_NAVIGATE_LON, 0);
if(lat == 0 && lon == 0){
return null;
}
return new LatLon(lat, lon);
}
public static boolean clearPointToNavigate(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().remove(POINT_NAVIGATE_LAT).remove(POINT_NAVIGATE_LON).commit();
}
public static boolean setPointToNavigate(Context ctx, double latitude, double longitude){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().putFloat(POINT_NAVIGATE_LAT, (float) latitude).putFloat(POINT_NAVIGATE_LON, (float) longitude).commit();
}
public static final String LAST_SEARCHED_REGION = "last_searched_region";
public static final String LAST_SEARCHED_CITY = "last_searched_city";
public static final String LAST_SEARCHED_STREET = "last_searched_street";

View file

@ -94,6 +94,11 @@ public class ResourceManager {
return getTileImageForMap(map, x, y, zoom, loadFromInternetIfNeeded, true, true);
}
public boolean tileExistOnFileSystem(ITileSource map, int x, int y, int zoom){
// TODO implement
return false;
}
// introduce cache in order save memory
protected StringBuilder builder = new StringBuilder(40);
protected synchronized Bitmap getTileImageForMap(ITileSource map, int x, int y, int zoom,

View file

@ -78,7 +78,7 @@ public class FavouritesActivity extends ListActivity {
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if (prefs != null) {
FavouritePoint point = favouritesList.get(position);
OsmandSettings.setLastKnownMapLocation(this, point.getLatitude(), point.getLongitude());
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
}

View file

@ -15,8 +15,6 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
@ -24,6 +22,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
@ -42,6 +41,7 @@ import com.osmand.activities.search.SearchActivity;
import com.osmand.data.preparation.MapTileDownloader;
import com.osmand.map.IMapLocationListener;
import com.osmand.osm.LatLon;
import com.osmand.osm.MapUtils;
import com.osmand.views.MapInfoLayer;
import com.osmand.views.OsmBugsLayer;
import com.osmand.views.OsmandMapTileView;
@ -66,17 +66,9 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
private WakeLock wakeLock;
private boolean sensorRegistered = false;
private Handler sensorHandler = new Handler();
private final static String BACK_TO_LOCATION = "BACK_TO_LOCATION";
private final static String POINT_NAVIGATE_LAT = "POINT_NAVIGATE_LAT";
private final static String POINT_NAVIGATE_LON = "POINT_NAVIGATE_LON";
private boolean isMapLinkedToLocation(){
return getPreferences(MODE_WORLD_READABLE).getBoolean(BACK_TO_LOCATION, true);
return OsmandSettings.isMapSyncToGpsLocation(this);
}
@Override
@ -102,12 +94,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
osmBugsLayer = new OsmBugsLayer(this);
SharedPreferences lprefs = getPreferences(MODE_WORLD_READABLE);
if(lprefs.contains(POINT_NAVIGATE_LAT)){
navigationLayer.setPointToNavigate(new LatLon(lprefs.getFloat(POINT_NAVIGATE_LAT, 0),
lprefs.getFloat(POINT_NAVIGATE_LON, 0)));
}
LatLon pointToNavigate = OsmandSettings.getPointToNavigate(this);
navigationLayer.setPointToNavigate(pointToNavigate);
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if(prefs == null || !prefs.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){
@ -140,7 +128,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
public void onClick(View v) {
backToLocation.setVisibility(View.INVISIBLE);
if(!isMapLinkedToLocation()){
getPreferences(MODE_WORLD_READABLE).edit().putBoolean(BACK_TO_LOCATION, true).commit();
OsmandSettings.setSyncMapToGpsLocation(MapActivity.this, true);
if(locationLayer.getLastKnownLocation() != null){
Location lastKnownLocation = locationLayer.getLastKnownLocation();
mapView.setLatLon(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
@ -166,14 +154,27 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH
&& event.getRepeatCount() == 0) {
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
Intent newIntent = new Intent(MapActivity.this, SearchActivity.class);
startActivity(newIntent);
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
float x = event.getX();
float y = event.getY();
x = (float) (MapUtils.getTileNumberX(mapView.getZoom() , mapView.getLongitude()) + x / 3);
y = (float) (MapUtils.getTileNumberY(mapView.getZoom(), mapView.getLatitude()) + y / 3);
double lat = MapUtils.getLatitudeFromTile(mapView.getZoom(), y);
double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x);
setMapLocation(lat, lon);
return true;
}
return super.onTrackballEvent(event);
}
@Override
protected void onDestroy() {
@ -190,7 +191,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
Log.d(LogUtil.TAG, "Disable sensor");
((SensorManager) getSystemService(SENSOR_SERVICE)).unregisterListener(this);
sensorRegistered = false;
locationLayer.setHeading(null, true);
locationLayer.setHeading(null);
}
} else {
if(!sensorRegistered && OsmandSettings.isShowingViewAngle(this)){
@ -204,16 +205,14 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}
}
Log.d(LogUtil.TAG, "Location changed");
locationLayer.setLastKnownLocation(location, true);
locationLayer.setLastKnownLocation(location);
if (location != null) {
if (isMapLinkedToLocation()) {
if (location.hasBearing() && OsmandSettings.isRotateMapToBearing(this)) {
mapView.setRotateWithLocation(-location.getBearing(), location.getLatitude(), location.getLongitude());
} else {
mapView.setLatLon(location.getLatitude(), location.getLongitude());
mapView.setRotate(-location.getBearing());
}
mapView.setLatLon(location.getLatitude(), location.getLongitude());
} else {
mapView.refreshMap();
if(backToLocation.getVisibility() != View.VISIBLE){
backToLocation.setVisibility(View.VISIBLE);
}
@ -226,12 +225,11 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}
public void navigateToPoint(LatLon point){
if(point != null){
getPreferences(MODE_WORLD_READABLE).edit().
putFloat(POINT_NAVIGATE_LAT, (float) mapView.getLatitude()).
putFloat(POINT_NAVIGATE_LON, (float) mapView.getLongitude()).commit();
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
} else {
getPreferences(MODE_WORLD_READABLE).edit().remove(POINT_NAVIGATE_LAT).remove(POINT_NAVIGATE_LON).commit();
OsmandSettings.clearPointToNavigate(this);
}
navigationLayer.setPointToNavigate(point);
}
@ -240,6 +238,10 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
return locationLayer.getLastKnownLocation();
}
public LatLon getMapLocation(){
return new LatLon(mapView.getLatitude(), mapView.getLongitude());
}
public LatLon getPointToNavigate(){
return navigationLayer.getPointToNavigate();
}
@ -295,7 +297,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
mapView.setRotate(0);
}
if(!OsmandSettings.isShowingViewAngle(this)){
locationLayer.setHeading(null, true);
locationLayer.setHeading(null);
}
mapView.setMapPosition(OsmandSettings.getPositionOnMap(this));
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
@ -304,11 +306,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setZoom(OsmandSettings.getLastKnownMapZoom(this));
}
if(getLastKnownLocation() != null && !isMapLinkedToLocation()){
backToLocation.setVisibility(View.VISIBLE);
} else {
backToLocation.setVisibility(View.INVISIBLE);
}
backToLocation.setVisibility(View.INVISIBLE);
if(mapView.getLayers().contains(poiMapLayer) != OsmandSettings.isShowingPoiOverMap(this)){
@ -351,7 +349,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
// when user start dragging
if(locationLayer.getLastKnownLocation() != null){
if(isMapLinkedToLocation()){
getPreferences(MODE_WORLD_READABLE).edit().putBoolean(BACK_TO_LOCATION, false).commit();
OsmandSettings.setSyncMapToGpsLocation(MapActivity.this, false);
}
if (backToLocation.getVisibility() != View.VISIBLE) {
runOnUiThread(new Runnable() {
@ -361,24 +359,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}
});
}
}
}
public void setMapLocation(double lat, double lon){
mapView.setLatLon(lat, lon);
locationChanged(lat, lon, this);
}
@Override
public void onSensorChanged(SensorEvent event) {
// using that strange technique because sensor produces a lot of events & hangs the system
locationLayer.setHeading(event.values[0], true);
if(!sensorHandler.hasMessages(1) && locationLayer.isLocationVisible(locationLayer.getLastKnownLocation())){
Message m = Message.obtain(sensorHandler, new Runnable(){
@Override
public void run() {
mapView.refreshMap();
}
});
m.what = 1;
sensorHandler.sendMessage(m);
}
// Attention : sensor produces a lot of events & can hang the system
locationLayer.setHeading(event.values[0]);
}
@ -387,7 +379,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
inflater.inflate(R.menu.map_menu, menu);
MenuItem item = menu.findItem(R.id.map_navigate_to_point);
if (item != null) {
if (getPreferences(MODE_WORLD_READABLE).contains(POINT_NAVIGATE_LAT)) {
if (OsmandSettings.getPointToNavigate(this) != null) {
item.setTitle(R.string.stop_navigation);
} else {
item.setTitle(R.string.navigate_to_point);
@ -465,7 +457,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}
private void openChangeLocationDialog() {
NavigatePointActivity dlg = new NavigatePointActivity(this, mapView);
NavigatePointActivity dlg = new NavigatePointActivity(this);
dlg.showDialog();
}

View file

@ -6,7 +6,6 @@ import java.util.Locale;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
@ -21,26 +20,26 @@ import com.osmand.LogUtil;
import com.osmand.OsmandSettings;
import com.osmand.R;
import com.osmand.osm.LatLon;
import com.osmand.views.OsmandMapTileView;
public class NavigatePointActivity extends Activity {
Dialog dlg;
OsmandMapTileView view;
MapActivity activity;
int currentFormat = Location.FORMAT_DEGREES;
// dialog constructor
public NavigatePointActivity(Context ctx, OsmandMapTileView view){
this.view = view;
dlg = new Dialog(ctx);
public NavigatePointActivity(MapActivity activity){
this.activity = activity;
dlg = new Dialog(activity);
}
// activity constructor
public NavigatePointActivity() {
}
public void showDialog(){
dlg.setContentView(R.layout.navigate_point);
dlg.setTitle("Navigate to point");
initUI(view.getLatitude(), view.getLongitude());
LatLon loc = activity.getMapLocation();
initUI(loc.getLatitude(), loc.getLongitude());
dlg.show();
}
@ -75,7 +74,7 @@ public class NavigatePointActivity extends Activity {
((TextView)findViewById(R.id.LatitudeEdit)).setText(convert(latitude, Location.FORMAT_DEGREES));
((TextView)findViewById(R.id.LongitudeEdit)).setText(convert(longitude, Location.FORMAT_DEGREES));
((RadioButton)findViewById(R.id.Format1)).setChecked(true);
((RadioGroup)findViewById(R.id.RadioGroup01)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
((RadioGroup)findViewById(R.id.RadioGroup)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@ -112,10 +111,11 @@ public class NavigatePointActivity extends Activity {
// TODO there is a bug in that convert if min = 59.23 or sec = 59.32 or deg=179.3
double lat = Location.convert(((TextView) findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
if(view != null) {
view.setLatLon(lat, lon);
// in case when it is dialog
if(activity != null) {
activity.setMapLocation(lat, lon);
} else {
OsmandSettings.setLastKnownMapLocation(NavigatePointActivity.this, lat, lon);
OsmandSettings.setMapLocationToShow(NavigatePointActivity.this, lat, lon);
}
close();
} catch (RuntimeException e) {

View file

@ -120,7 +120,7 @@ public class SearchAddressActivity extends Activity {
zoom = 12;
}
if (l != null) {
OsmandSettings.setLastKnownMapLocation(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
OsmandSettings.setLastKnownMapZoom(SearchAddressActivity.this, zoom);
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
}

View file

@ -123,7 +123,7 @@ public class SearchPOIActivity extends ListActivity {
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if (prefs != null) {
Amenity amenity = amenityList.get(position);
OsmandSettings.setLastKnownMapLocation(this, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude());
OsmandSettings.setMapLocationToShow(this, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude());
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
}

View file

@ -50,7 +50,7 @@ public class MapInfoLayer implements OsmandMapLayer {
paintBlack = new Paint();
paintBlack.setStyle(Style.STROKE);
paintBlack.setColor(Color.BLACK);
paintBlack.setTextSize(18);
paintBlack.setTextSize(23);
paintBlack.setAntiAlias(true);
paintAlphaGray = new Paint();

View file

@ -15,6 +15,8 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.view.MotionEvent;
@ -66,6 +68,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>();
// UI Part
// handler to refresh map (in ui thread - not necessary in ui thread, but msg queue is desirable).
protected Handler handler = new Handler();
private AnimateDraggingMapThread animatedDraggingThread;
private PointF startDragging = null;
@ -189,15 +194,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
refreshMap();
}
}
public void setRotateWithLocation(float rotate, double latitude, double longitude){
animatedDraggingThread.stopDragging();
this.rotate = rotate;
this.latitude = latitude;
this.longitude = longitude;
refreshMap();
}
public float getRotate() {
return rotate;
}
@ -335,7 +332,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
protected RectF bitmapToDraw = new RectF();
protected Rect bitmapToZoom = new Rect();
public void refreshMap() {
private void refreshMapInternal(){
if(handler.hasMessages(1)){
return;
}
if (OsmandSettings.isUsingInternetToDownloadTiles(getContext())) {
MapTileDownloader.getInstance().refuseAllPreviousRequests();
}
@ -370,7 +371,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// asking if there is small version of the map (in cache)
if(useInternet){
bmp = mgr.getTileImageFromCache(map, (left + i) / 2, (top + j) / 2, zoom - 1);
} else {
} else if(!mgr.tileExistOnFileSystem(map, left + i, top + j, zoom)){
bmp = mgr.getTileImageForMapAsync(map, (left + i) / 2, (top + j) / 2, zoom - 1, false);
}
if(bmp == null){
@ -393,6 +394,23 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
}
}
}
public boolean mapIsRefreshing(){
return handler.hasMessages(1);
}
public void refreshMap() {
if(!handler.hasMessages(1)){
Message msg = Message.obtain(handler, new Runnable(){
@Override
public void run() {
refreshMapInternal();
}
});
msg.what = 1;
handler.sendMessageDelayed(msg, 20);
}
}

View file

@ -125,9 +125,9 @@ public class PointLocationLayer implements OsmandMapLayer {
return lastKnownLocation;
}
public void setHeading(Float heading, boolean doNotRedraw){
public void setHeading(Float heading){
this.heading = heading;
if(!doNotRedraw && isLocationVisible(this.lastKnownLocation)){
if(!view.mapIsRefreshing() && isLocationVisible(this.lastKnownLocation)){
view.refreshMap();
}
}
@ -136,13 +136,11 @@ public class PointLocationLayer implements OsmandMapLayer {
return heading;
}
public void setLastKnownLocation(Location lastKnownLocation, boolean doNotRedraw) {
public void setLastKnownLocation(Location lastKnownLocation) {
this.lastKnownLocation = lastKnownLocation;
if (!doNotRedraw) {
boolean redraw = isLocationVisible(this.lastKnownLocation) || isLocationVisible(lastKnownLocation);
if (redraw) {
view.refreshMap();
}
boolean redraw = isLocationVisible(this.lastKnownLocation) || isLocationVisible(lastKnownLocation);
if (redraw) {
view.refreshMap();
}
}