diff --git a/OsmAnd/src/com/osmand/AmenityIndexRepository.java b/OsmAnd/src/com/osmand/AmenityIndexRepository.java index fdf29b90b3..cd4fb8b95a 100644 --- a/OsmAnd/src/com/osmand/AmenityIndexRepository.java +++ b/OsmAnd/src/com/osmand/AmenityIndexRepository.java @@ -224,8 +224,8 @@ public class AmenityIndexRepository { String latCol = IndexPoiTable.LATITUDE.name(); String lonCol = IndexPoiTable.LONGITUDE.name(); db.execSQL("DELETE FROM " + IndexPoiTable.getTable() + " WHERE " + //$NON-NLS-1$ //$NON-NLS-2$ - lonCol + ">= ? AND ? <=" + lonCol + " AND " + //$NON-NLS-1$//$NON-NLS-2$ - latCol + ">= ? AND ? <=" + latCol, new Double[] { leftLon, rightLon, bottomLat, topLat }); //$NON-NLS-1$ + lonCol + ">= ? AND ? >=" + lonCol + " AND " + //$NON-NLS-1$//$NON-NLS-2$ + latCol + ">= ? AND ? >=" + latCol, new Double[] { leftLon, rightLon, bottomLat, topLat }); //$NON-NLS-1$ SQLiteStatement stat = db.compileStatement(IndexConstants.generatePrepareStatementToInsert(IndexPoiTable.getTable(), 8)); for (Amenity a : amenities) { diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index 202be191ac..c392b85a6d 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -139,6 +139,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat setContentView(R.layout.main); mapView = (OsmandMapTileView) findViewById(R.id.MapView); + mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener(){ + @Override + public boolean onTrackBallEvent(MotionEvent e) { + return MapActivity.this.onTrackballEvent(e); + } + + @Override + public boolean onTrackBallPressed() { + contextMenuPoint(mapView.getLatitude(), mapView.getLongitude(), true); + return true; + } + }); MapTileDownloader.getInstance().addDownloaderCallback(new IMapDownloaderCallback(){ @Override public void tileDownloaded(DownloadRequest request) { @@ -236,6 +248,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat }); + backToMenu = (ImageButton)findViewById(R.id.BackToMenu); backToMenu.setOnClickListener(new OnClickListener() { @Override @@ -285,11 +298,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x); setMapLocation(lat, lon); return true; - // that doesn't work for now -// } else if(event.getAction() == MotionEvent.ACTION_UP){ -// contextMenuPoint(mapView.getLatitude(), mapView.getLongitude()); -// return true; - } + } return super.onTrackballEvent(event); } diff --git a/OsmAnd/src/com/osmand/activities/search/SearchHistoryActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchHistoryActivity.java index 475ed91c3d..3404b2453c 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchHistoryActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchHistoryActivity.java @@ -24,6 +24,7 @@ import com.osmand.osm.MapUtils; public class SearchHistoryActivity extends ListActivity { private LatLon location; private SearchHistoryHelper helper; + private Button clearButton; @Override protected void onCreate(Bundle savedInstanceState) { @@ -36,23 +37,23 @@ public class SearchHistoryActivity extends ListActivity { helper = SearchHistoryHelper.getInstance(); - + clearButton = new Button(this); + clearButton.setText(R.string.clear_all); + clearButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + helper.removeAll(SearchHistoryActivity.this); + setListAdapter(new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this))); + } + }); } @Override protected void onResume() { super.onResume(); List historyEntries = helper.getHistoryEntries(this); + getListView().removeFooterView(clearButton); if (!historyEntries.isEmpty()) { - Button clearButton = new Button(this); - clearButton.setText(R.string.clear_all); - clearButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - helper.removeAll(SearchHistoryActivity.this); - setListAdapter(new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this))); - } - }); getListView().addFooterView(clearButton); } setListAdapter(new HistoryAdapter(historyEntries)); diff --git a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java index 264c720754..021e042d97 100644 --- a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java @@ -19,6 +19,7 @@ import android.os.Handler; import android.os.Message; import android.util.AttributeSet; import android.util.FloatMath; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -45,6 +46,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall protected final int timeForDraggingAnimation = 300; protected final int minimumDistanceForDraggingAnimation = 40; + public interface OnTrackBallListener{ + public boolean onTrackBallEvent(MotionEvent e); + public boolean onTrackBallPressed(); + } + public interface OnLongClickListener { public boolean onLongPressEvent(PointF point); } @@ -76,6 +82,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall private OnClickListener onClickListener; + private OnTrackBallListener trackBallDelegate; + private List layers = new ArrayList(); // UI Part @@ -131,6 +139,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall setClickable(true); setLongClickable(true); + setFocusable(true); super.setOnLongClickListener(this); super.setOnClickListener(this); @@ -142,8 +151,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall - - @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { refreshMap(); @@ -660,6 +667,26 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall return true; } + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if(trackBallDelegate != null && keyCode == KeyEvent.KEYCODE_DPAD_CENTER){ + return trackBallDelegate.onTrackBallPressed(); + } + return super.onKeyUp(keyCode, event); + } + + @Override + public boolean onTrackballEvent(MotionEvent event) { + if(trackBallDelegate != null){ + trackBallDelegate.onTrackBallEvent(event); + } + return super.onTrackballEvent(event); + } + + public void setTrackBallDelegate(OnTrackBallListener trackBallDelegate) { + this.trackBallDelegate = trackBallDelegate; + } + @Override public boolean onLongClick(View v) { PointF point = startDragging;