add direction to poi

git-svn-id: https://osmand.googlecode.com/svn/trunk@290 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-06 18:10:17 +00:00
parent 01662401f0
commit 24ccb2e33e
13 changed files with 392 additions and 65 deletions

View file

@ -12,7 +12,8 @@ public class ToDoConstants {
* Write activity to show something about authors / donation ....
*/
public int DESCRIBE_ABOUT_AUTHORS = 8;
// Prepare update : android description, sites, screenshots
// TODO ANDROID
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
@ -41,10 +42,10 @@ public class ToDoConstants {
// double tap to zoom [done]
// forbid rotate map to landscape [ done]
// REFACTOR Settings activity ( for check box properties!) [partially done]
// show POI choose near by or last map selection [done]
// Show poi direction (using sensor) [done]
// show POI choose near by or last map selection.
// Show poi direction (using sensor)
// hide center point (enable only when trackball using)
// hide center point (enable only when trackball using)?
// Fix bugs with test data (bug with follow turn / left time / add turn)
// Improvement : Show stops in the transport route

View file

@ -3,13 +3,13 @@
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:id="@+id/poi_icon" android:layout_width="25px"
<ImageView android:id="@+id/poi_icon" android:layout_width="26px" android:layout_height="26px"
android:paddingLeft="2px" android:paddingRight="2px"
android:paddingTop="2px" android:layout_height="fill_parent" />
android:paddingTop="2px" />
<TextView android:id="@+id/poidistance_label"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"
android:textSize="22px" android:maxWidth="75dp" android:minWidth="75dp"/>
android:textSize="22px" android:maxWidth="80dp" android:minWidth="80dp"/>
<TextView android:id="@+id/poi_label" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="22px" />

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="search_near_map">Искать возле видимой карты</string>
<string name="search_nearby">Искать рядом</string>
<string name="map_orientation_default">По умолчанию</string>
<string name="map_orientation_portrait">Портрет</string>
<string name="map_orientation_landscape">Пейзаж</string>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="search_near_map">Search near last map location</string>
<string name="search_nearby">Search nearby</string>
<string name="map_orientation_default">Default</string>
<string name="map_orientation_portrait">Portrait</string>
<string name="map_orientation_landscape">Landscape</string>

View file

@ -99,6 +99,12 @@ public class PoiFilter {
return amenityList;
}
public List<Amenity> searchAgain(double lat, double lon){
List<Amenity> amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount);
MapUtils.sortListOfMapObject(amenityList, lat, lon);
return amenityList;
}
public String getName(){
return name;
}

View file

@ -30,19 +30,21 @@ import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.osmand.OsmandSettings;
import com.osmand.PoiFilter;
import com.osmand.PoiFiltersHelper;
import com.osmand.R;
import com.osmand.PoiFiltersHelper.PoiFilterDbHelper;
import com.osmand.activities.search.SearchPOIActivity;
import com.osmand.data.AmenityType;
import com.osmand.osm.LatLon;
/**
* @author Frolov
*
*/
public class EditPOIFilterActivity extends ListActivity {
public static final String AMENITY_FILTER = "com.osmand.amenity_filter"; //$NON-NLS-1$
private Button filterLevel;
private PoiFilter filter;
private PoiFilterDbHelper helper;
@ -56,16 +58,31 @@ public class EditPOIFilterActivity extends ListActivity {
filterLevel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent newIntent = new Intent(EditPOIFilterActivity.this, SearchPOIActivity.class);
Bundle bundle = new Bundle();
bundle.putString(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
newIntent.putExtras(bundle);
startActivity(newIntent);
AlertDialog.Builder b = new AlertDialog.Builder(EditPOIFilterActivity.this);
b.setItems(new String[]{getString(R.string.search_nearby), getString(R.string.search_near_map)}, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle bundle = new Bundle();
Intent newIntent = new Intent(EditPOIFilterActivity.this, SearchPOIActivity.class);
bundle.putString(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
if(which == 1){
LatLon last = OsmandSettings.getLastKnownMapLocation(EditPOIFilterActivity.this);
if(last != null){
bundle.putDouble(SearchPOIActivity.SEARCH_LAT, last.getLatitude());
bundle.putDouble(SearchPOIActivity.SEARCH_LON, last.getLongitude());
}
}
newIntent.putExtras(bundle);
startActivity(newIntent);
}
});
b.show();
}
});
Bundle bundle = this.getIntent().getExtras();
String filterId = bundle.getString(SearchPOIActivity.AMENITY_FILTER);
String filterId = bundle.getString(AMENITY_FILTER);
filter = PoiFiltersHelper.getFilterById(this, filterId);
setListAdapter(new AmenityAdapter(AmenityType.getCategories()));

View file

@ -89,7 +89,7 @@ public class FavouritesActivity extends ListActivity {
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
final FavouritePoint point = (FavouritePoint) favouritesList.get(menuInfo.position);
if(aItem.getItemId() == NAVIGATE_TO){
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
// OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);

View file

@ -122,14 +122,16 @@ public class NavigatePointActivity extends Activity {
// TODO there is a bug in android implementation : doesn't 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());
// in case when it is dialog
if(activity != null) {
activity.setMapLocation(lat, lon);
} else {
OsmandSettings.setMapLocationToShow(this, lat, lon, MessageFormat.format(getString(R.string.search_history_navigate_to), lat, lon));
}
if(navigate){
OsmandSettings.setPointToNavigate(this, lat, lon);
} else {
// in case when it is dialog
if(activity != null) {
activity.setMapLocation(lat, lon);
} else {
OsmandSettings.setMapLocationToShow(this, lat, lon, MessageFormat.format(getString(R.string.search_history_navigate_to), lat, lon));
}
}
close();
} catch (RuntimeException e) {

View file

@ -217,9 +217,10 @@ public class SearchAddressActivity extends Activity {
if (l != null) {
if(navigateTo){
OsmandSettings.setPointToNavigate(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
}
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude(), historyName);
OsmandSettings.setLastKnownMapZoom(SearchAddressActivity.this, zoom);
} else {
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude(), historyName);
OsmandSettings.setLastKnownMapZoom(SearchAddressActivity.this, zoom);
}
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
}

View file

@ -9,7 +9,26 @@ import java.util.List;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Paint.Style;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -22,6 +41,8 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.osmand.Algoritms;
import com.osmand.LogUtil;
import com.osmand.OsmandSettings;
import com.osmand.PoiFilter;
import com.osmand.PoiFiltersHelper;
@ -37,31 +58,44 @@ import com.osmand.osm.OpeningHoursParser.OpeningHoursRule;
* @author Maxim Frolov
*
*/
public class SearchPOIActivity extends ListActivity {
public class SearchPOIActivity extends ListActivity implements LocationListener, SensorEventListener {
public static final String AMENITY_FILTER = "com.osmand.amenity_filter"; //$NON-NLS-1$
public static final String SEARCH_LAT = "com.osmand.am_search_lat"; //$NON-NLS-1$
public static final String SEARCH_LON = "com.osmand.am_search_lon"; //$NON-NLS-1$
private static final int GPS_TIMEOUT_REQUEST = 2000;
private static final int GPS_DIST_REQUEST = 5;
private Button searchPOILevel;
private Button showOnMap;
private PoiFilter filter;
private AmenityAdapter amenityAdapter;
private LatLon lastKnownMapLocation;
private TextView searchArea;
private boolean searchNearBy = false;
private Location location = null;
private Location searchedLocation = null;
private Float heading = null;
private String currentLocationProvider = null;
private boolean sensorRegistered = false;
private Handler uiHandler;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.searchpoi);
uiHandler = new Handler();
searchPOILevel = (Button) findViewById(R.id.SearchPOILevelButton);
searchArea = (TextView) findViewById(R.id.SearchAreaText);
searchPOILevel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
amenityAdapter.setNewModel(filter.searchFurther(lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
amenityAdapter.setNewModel(filter.searchFurther(location.getLatitude(), location.getLongitude()));
searchedLocation = location;
searchArea.setText(filter.getSearchArea());
searchPOILevel.setEnabled(filter.isSearchFurtherAvailable());
@ -71,6 +105,15 @@ public class SearchPOIActivity extends ListActivity {
Bundle bundle = this.getIntent().getExtras();
String filterId = bundle.getString(AMENITY_FILTER);
filter = PoiFiltersHelper.getFilterById(this, filterId);
if(bundle.containsKey(SEARCH_LAT) && bundle.containsKey(SEARCH_LON)){
location = new Location("internal"); //$NON-NLS-1$
location.setLatitude(bundle.getDouble(SEARCH_LAT));
location.setLongitude(bundle.getDouble(SEARCH_LON));
searchNearBy = false;
} else {
location = null;
searchNearBy = true;
}
showOnMap = (Button) findViewById(R.id.ShowOnMap);
showOnMap.setOnClickListener(new OnClickListener() {
@ -78,6 +121,10 @@ public class SearchPOIActivity extends ListActivity {
public void onClick(View v) {
OsmandSettings.setPoiFilterForMap(SearchPOIActivity.this, filter.getFilterId());
OsmandSettings.setShowPoiOverMap(SearchPOIActivity.this, true);
if(searchNearBy && location != null){
OsmandSettings.setMapLocationToShow(SearchPOIActivity.this, location.getLatitude(), location.getLongitude());
OsmandSettings.setLastKnownMapZoom(SearchPOIActivity.this, 15);
}
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
}
@ -106,16 +153,157 @@ public class SearchPOIActivity extends ListActivity {
});
}
public void setLocation(Location l){
registerUnregisterSensor(l);
boolean handled = false;
if (l != null && filter != null) {
if (location == null) {
searchedLocation = l;
amenityAdapter.setNewModel(filter.initializeNewSearch(l.getLatitude(), l.getLongitude(), 40));
searchPOILevel.setEnabled(filter.isSearchFurtherAvailable());
searchArea.setText(filter.getSearchArea());
handled = true;
} else if (searchedLocation != null && l.distanceTo(searchedLocation) > 80) {
amenityAdapter.setNewModel(filter.searchAgain(l.getLatitude(), l.getLongitude()));
searchPOILevel.setEnabled(filter.isSearchFurtherAvailable());
searchArea.setText(filter.getSearchArea());
handled = true;
} else if(location.distanceTo(l) > 8){
handled = true;
}
}
if(handled) {
location = l;
amenityAdapter.notifyDataSetChanged();
}
}
private boolean isRunningOnEmulator(){
if (Build.DEVICE.equals("generic")) { //$NON-NLS-1$
return true;
}
return false;
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
if (LocationManager.GPS_PROVIDER.equals(provider)) {
if (LocationProvider.OUT_OF_SERVICE == status || LocationProvider.TEMPORARILY_UNAVAILABLE == status) {
if (LocationProvider.OUT_OF_SERVICE == status) {
setLocation(null);
}
if (!isRunningOnEmulator() && service.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
if (!Algoritms.objectEquals(currentLocationProvider, LocationManager.NETWORK_PROVIDER)) {
currentLocationProvider = LocationManager.NETWORK_PROVIDER;
service.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this);
}
}
} else if (LocationProvider.AVAILABLE == status) {
if (!Algoritms.objectEquals(currentLocationProvider, LocationManager.GPS_PROVIDER)) {
currentLocationProvider = LocationManager.GPS_PROVIDER;
service.removeUpdates(this);
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this);
}
}
}
}
@Override
public void onLocationChanged(Location location) {
setLocation(location);
}
@Override
public void onProviderDisabled(String provider) {
setLocation(null);
}
@Override
public void onSensorChanged(SensorEvent event) {
// Attention : sensor produces a lot of events & can hang the system
if(heading != null && heading - event.values[0] < 4){
// this is very small variation
return;
}
heading = event.values[0];
if(!uiHandler.hasMessages(5)){
Message msg = Message.obtain(uiHandler, new Runnable(){
@Override
public void run() {
amenityAdapter.notifyDataSetChanged();
}
});
msg.what = 5;
uiHandler.sendMessageDelayed(msg, 100);
}
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
protected void onResume() {
super.onResume();
// TODO think where this code should be placed (onCreate() - save last search results or onResume() - search time)
lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(this);
if (filter != null) {
amenityAdapter.setNewModel(filter.initializeNewSearch(lastKnownMapLocation.getLatitude(),
lastKnownMapLocation.getLongitude(), 40));
if (filter != null && location != null) {
searchedLocation = location;
amenityAdapter.setNewModel(filter.initializeNewSearch(location.getLatitude(), location.getLongitude(), 40));
searchPOILevel.setEnabled(filter.isSearchFurtherAvailable());
searchArea.setText(filter.getSearchArea());
} else {
searchPOILevel.setEnabled(false);
}
showOnMap.setEnabled(filter != null);
if (searchNearBy) {
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this);
if (!service.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
service.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, this);
}
}
}
private void registerUnregisterSensor(Location location){
// show point view only if gps enabled
if(location == null){
if(sensorRegistered) {
Log.d(LogUtil.TAG, "Disable sensor"); //$NON-NLS-1$
((SensorManager) getSystemService(SENSOR_SERVICE)).unregisterListener(this);
sensorRegistered = false;
heading = null;
}
} else {
if(!sensorRegistered){
Log.d(LogUtil.TAG, "Enable sensor"); //$NON-NLS-1$
SensorManager sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor s = sensorMgr.getDefaultSensor(Sensor.TYPE_ORIENTATION);
if (s != null) {
sensorMgr.registerListener(this, s, SensorManager.SENSOR_DELAY_UI);
}
sensorRegistered = true;
}
}
}
@Override
protected void onPause() {
super.onPause();
if (searchNearBy) {
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
service.removeUpdates(this);
SensorManager sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
sensorMgr.unregisterListener(this);
sensorRegistered = false;
}
}
@ -125,10 +313,81 @@ public class SearchPOIActivity extends ListActivity {
OsmandSettings.setShowPoiOverMap(SearchPOIActivity.this, true);
}
Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
OsmandSettings.setMapLocationToShow(this, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), getString(R.string.poi)+" : " + amenity.getSimpleFormat(OsmandSettings.usingEnglishNames(this))); //$NON-NLS-1$
OsmandSettings.setMapLocationToShow(this, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
getString(R.string.poi)+" : " + amenity.getSimpleFormat(OsmandSettings.usingEnglishNames(this))); //$NON-NLS-1$
OsmandSettings.setLastKnownMapZoom(this, 16);
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
}
class DirectionDrawable extends Drawable {
Paint paintRouteDirection;
Path path = new Path();
private float angle;
private final int width = 24;
private final int height = 24;
public DirectionDrawable(){
paintRouteDirection = new Paint();
paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
paintRouteDirection.setColor(Color.rgb(100, 0, 255));
paintRouteDirection.setAntiAlias(true);
int h = 15;
int w = 4;
float sarrowL = 8; // side of arrow
float harrowL = (float) Math.sqrt(2) * sarrowL; // hypotenuse of arrow
float hpartArrowL = (float) (harrowL - w) / 2;
path.moveTo(width / 2, height - (height - h) / 3);
path.rMoveTo(w / 2, 0);
path.rLineTo(0, -h);
path.rLineTo(hpartArrowL, 0);
path.rLineTo(-harrowL / 2, -harrowL / 2); // center
path.rLineTo(-harrowL / 2, harrowL / 2);
path.rLineTo(hpartArrowL, 0);
path.rLineTo(0, h);
}
public void setOpenedColor(int opened){
if(opened == 0){
paintRouteDirection.setColor(Color.rgb(100, 0, 255));
} else if(opened == -1){
paintRouteDirection.setColor(Color.rgb(150, 150, 150));
} else {
paintRouteDirection.setColor(Color.rgb(220, 100, 80));
}
}
public void setAngle(float angle){
this.angle = angle;
}
@Override
public void draw(Canvas canvas) {
canvas.rotate(angle, width/2, height/2);
canvas.drawPath(path, paintRouteDirection);
}
@Override
public int getOpacity() {
return 0;
}
@Override
public void setAlpha(int alpha) {
paintRouteDirection.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter cf) {
paintRouteDirection.setColorFilter(cf);
}
}
class AmenityAdapter extends ArrayAdapter<Amenity> {
AmenityAdapter(List<Amenity> list) {
@ -152,43 +411,62 @@ public class SearchPOIActivity extends ListActivity {
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.searchpoi_list, parent, false);
}
float[] mes = null;
TextView label = (TextView) row.findViewById(R.id.poi_label);
TextView distanceLabel = (TextView) row.findViewById(R.id.poidistance_label);
ImageView icon = (ImageView) row.findViewById(R.id.poi_icon);
Amenity amenity = getItem(position);
LatLon lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(SearchPOIActivity.this);
int dist = (int) (MapUtils.getDistance(amenity.getLocation(), lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude()));
if(location != null){
mes = new float[2];
LatLon l = amenity.getLocation();
Location.distanceBetween(l.getLatitude(), l.getLongitude(), location.getLatitude(), location.getLongitude(), mes);
}
String str = amenity.getStringWithoutType(OsmandSettings.usingEnglishNames(SearchPOIActivity.this));
label.setText(str);
int opened = -1;
if (amenity.getOpeningHours() != null) {
List<OpeningHoursRule> rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
if(rs == null){
icon.setImageResource(R.drawable.poi);
} else {
if (rs != null) {
Calendar inst = Calendar.getInstance();
inst.setTimeInMillis(System.currentTimeMillis());
boolean work = false;
for(OpeningHoursRule p : rs){
if(p.isOpenedForTime(inst)){
for (OpeningHoursRule p : rs) {
if (p.isOpenedForTime(inst)) {
work = true;
break;
}
}
if(work){
icon.setImageResource(R.drawable.opened_poi);
if (work) {
opened = 0;
} else {
icon.setImageResource(R.drawable.closed_poi);
opened = 1;
}
}
} else {
icon.setImageResource(R.drawable.poi);
}
distanceLabel.setText(" " + MapUtils.getFormattedDistance(dist)); //$NON-NLS-1$
if(heading != null && location != null){
DirectionDrawable draw = new DirectionDrawable();
draw.setAngle(mes[1] - heading + 180);
draw.setOpenedColor(opened);
icon.setImageDrawable(draw);
} else {
if(opened == -1){
icon.setImageResource(R.drawable.poi);
} else if(opened == 0){
icon.setImageResource(R.drawable.opened_poi);
} else {
icon.setImageResource(R.drawable.closed_poi);
}
}
if(mes == null){
distanceLabel.setText(""); //$NON-NLS-1$
} else {
distanceLabel.setText(" " + MapUtils.getFormattedDistance((int) mes[0])); //$NON-NLS-1$
}
return (row);
}
}
}

View file

@ -6,7 +6,9 @@ package com.osmand.activities.search;
import java.util.ArrayList;
import java.util.List;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
@ -19,10 +21,12 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.osmand.OsmandSettings;
import com.osmand.PoiFilter;
import com.osmand.PoiFiltersHelper;
import com.osmand.R;
import com.osmand.activities.EditPOIFilterActivity;
import com.osmand.osm.LatLon;
/**
* @author Maxim Frolov
@ -30,7 +34,6 @@ import com.osmand.activities.EditPOIFilterActivity;
*/
public class SearchPoiFilterActivity extends ListActivity {
private Typeface typeFace;
@ -68,22 +71,37 @@ public class SearchPoiFilterActivity extends ListActivity {
Bundle bundle = new Bundle();
Intent newIntent = new Intent(SearchPoiFilterActivity.this, EditPOIFilterActivity.class);
// folder selected
bundle.putString(SearchPOIActivity.AMENITY_FILTER, poi.getFilterId());
bundle.putString(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
}
public void onListItemClick(ListView parent, View v, int position, long id) {
PoiFilter filter = ((AmenityAdapter) getListAdapter()).getItem(position);
final PoiFilter filter = ((AmenityAdapter) getListAdapter()).getItem(position);
if(filter.getFilterId().equals(PoiFilter.CUSTOM_FILTER_ID)){
showEditActivity(filter);
return;
}
Bundle bundle = new Bundle();
Intent newIntent = new Intent(SearchPoiFilterActivity.this, SearchPOIActivity.class);
bundle.putString(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setItems(new String[]{getString(R.string.search_nearby), getString(R.string.search_near_map)}, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle bundle = new Bundle();
Intent newIntent = new Intent(SearchPoiFilterActivity.this, SearchPOIActivity.class);
bundle.putString(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
if(which == 1){
LatLon last = OsmandSettings.getLastKnownMapLocation(SearchPoiFilterActivity.this);
if(last != null){
bundle.putDouble(SearchPOIActivity.SEARCH_LAT, last.getLatitude());
bundle.putDouble(SearchPOIActivity.SEARCH_LON, last.getLongitude());
}
}
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
b.show();
}

View file

@ -62,9 +62,13 @@ public class AnimateDraggingMapThread implements Runnable {
*/
public void stopDraggingSync(){
// wait until current thread != null
// TODO implement better method for waintg
stopped = true;
while(currentThread != null){}
while(currentThread != null){
try {
currentThread.join();
} catch (InterruptedException e) {
}
}
}
public void startDragging(float dTime, float startX, float startY, float endX, float endY){

View file

@ -103,9 +103,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
Paint paintBitmap;
public OsmandMapTileView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
@ -163,7 +160,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO clear cache ?
}
public void addLayer(OsmandMapLayer layer, OsmandMapLayer afterIt){