Implement new Graphics. Introduce base class for layer instead of interface
This commit is contained in:
parent
55ec5d50da
commit
75646d55b8
25 changed files with 108 additions and 103 deletions
BIN
OsmAnd/res/drawable-hdpi/box_free_pressed.9.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/box_free_pressed.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
OsmAnd/res/drawable-hdpi/box_free_simple.9.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/box_free_simple.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
OsmAnd/res/drawable-large/box_free_pressed.9.png
Normal file
BIN
OsmAnd/res/drawable-large/box_free_pressed.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
OsmAnd/res/drawable-large/box_free_simple.9.png
Normal file
BIN
OsmAnd/res/drawable-large/box_free_simple.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
6
OsmAnd/res/drawable/box_free.xml
Normal file
6
OsmAnd/res/drawable/box_free.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" android:drawable="@drawable/box_free_pressed" />
|
||||||
|
<item android:state_focused="true" android:drawable="@drawable/box_free_pressed" />
|
||||||
|
<item android:drawable="@drawable/box_free_simple" />
|
||||||
|
</selector>
|
BIN
OsmAnd/res/drawable/box_free_pressed.9.png
Normal file
BIN
OsmAnd/res/drawable/box_free_pressed.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable/box_free_simple.9.png
Normal file
BIN
OsmAnd/res/drawable/box_free_simple.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -161,7 +161,7 @@ public class MapVectorLayer extends BaseMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
public abstract class BaseMapLayer implements OsmandMapLayer {
|
public abstract class BaseMapLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private int alpha = 255;
|
private int alpha = 255;
|
||||||
protected int warningToSwitchMapShown = 0;
|
protected int warningToSwitchMapShown = 0;
|
||||||
|
|
|
@ -14,15 +14,19 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.FrameLayout.LayoutParams;
|
import android.widget.FrameLayout.LayoutParams;
|
||||||
|
|
||||||
public class ContextMenuLayer implements OsmandMapLayer {
|
public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface IContextMenuProvider {
|
public interface IContextMenuProvider {
|
||||||
|
|
||||||
|
@ -44,14 +48,14 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
private DisplayMetrics dm;
|
private DisplayMetrics dm;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private static final int BASE_TEXT_SIZE = 170;
|
private static final int BASE_TEXT_SIZE = 170;
|
||||||
|
private static final int MARGIN_Y_TO_BOX = 12;
|
||||||
private int textSize = BASE_TEXT_SIZE;
|
private int textSize = BASE_TEXT_SIZE;
|
||||||
|
|
||||||
private Paint paintLightBorder;
|
private Paint paintLightBorder;
|
||||||
private Paint paintBlack;
|
private Paint paintBlack;
|
||||||
private RectF textBorder;
|
|
||||||
private Paint paintBorder;
|
private Paint paintBorder;
|
||||||
private final MapActivity activity;
|
private final MapActivity activity;
|
||||||
|
private Rect padding = new Rect();
|
||||||
|
|
||||||
public ContextMenuLayer(MapActivity activity){
|
public ContextMenuLayer(MapActivity activity){
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
@ -88,38 +92,43 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
textView.setMinLines(1);
|
textView.setMinLines(1);
|
||||||
// textView.setMaxLines(15);
|
// textView.setMaxLines(15);
|
||||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
textBorder = new RectF(-2, -1, textSize + 2, 0);
|
|
||||||
|
|
||||||
|
textView.setClickable(true);
|
||||||
|
textView.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, boolean nightMode) {
|
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, boolean nightMode) {
|
||||||
if(latLon != null){
|
if(latLon != null){
|
||||||
int x = view.getMapXForPoint(latLon.getLongitude());
|
int x = view.getRotatedMapXForPoint(latLon.getLatitude(), latLon.getLongitude());
|
||||||
int y = view.getMapYForPoint(latLon.getLatitude());
|
int y = view.getRotatedMapYForPoint(latLon.getLatitude(), latLon.getLongitude());
|
||||||
canvas.drawCircle(x, y, 5 * dm.density, paintBorder);
|
canvas.drawCircle(x, y, 5 * dm.density, paintBorder);
|
||||||
canvas.drawCircle(x, y, 5 * dm.density, paintBlack);
|
canvas.drawCircle(x, y, 5 * dm.density, paintBlack);
|
||||||
|
|
||||||
|
|
||||||
if (textView.getText().length() > 0) {
|
if (textView.getText().length() > 0) {
|
||||||
x = view.getRotatedMapXForPoint(latLon.getLatitude(), latLon.getLongitude());
|
canvas.translate(x - textView.getWidth() / 2, y - textView.getHeight() - MARGIN_Y_TO_BOX);
|
||||||
y = view.getRotatedMapYForPoint(latLon.getLatitude(), latLon.getLongitude());
|
|
||||||
canvas.rotate(-view.getRotate(), view.getCenterPointX(), view.getCenterPointY());
|
|
||||||
canvas.translate(x - textView.getWidth() / 2, y - textView.getHeight() - 12);
|
|
||||||
int c = textView.getLineCount();
|
int c = textView.getLineCount();
|
||||||
textBorder.bottom = textView.getHeight() + 2;
|
|
||||||
canvas.drawRect(textBorder, paintLightBorder);
|
|
||||||
canvas.drawRect(textBorder, paintBlack);
|
|
||||||
textView.draw(canvas);
|
textView.draw(canvas);
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
// special case relayout after on draw method
|
// special case relayout after on draw method
|
||||||
textView.layout(0, 0, textSize, (int) ((textView.getPaint().getTextSize() + 4) * textView.getLineCount()));
|
layoutText();
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void layoutText() {
|
||||||
|
if(textView.getLineCount() > 0) {
|
||||||
|
textView.getBackground().getPadding(padding);
|
||||||
|
}
|
||||||
|
int w = textSize;
|
||||||
|
int h = (int) ((textView.getPaint().getTextSize() +4) * textView.getLineCount()) +
|
||||||
|
padding.bottom + padding.top;
|
||||||
|
textView.layout(0, 0, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLocation(LatLon loc, String description){
|
public void setLocation(LatLon loc, String description){
|
||||||
latLon = loc;
|
latLon = loc;
|
||||||
if(latLon != null){
|
if(latLon != null){
|
||||||
|
@ -131,12 +140,13 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
} else {
|
} else {
|
||||||
textView.setText(""); //$NON-NLS-1$
|
textView.setText(""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
textView.layout(0, 0, textSize, (int) ((textView.getPaint().getTextSize()+4) * textView.getLineCount()));
|
layoutText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongPressEvent(PointF point) {
|
public boolean onLongPressEvent(PointF point) {
|
||||||
if(pressedInTextView(point)){
|
if(pressedInTextView(point.x, point.y)){
|
||||||
setLocation(null, ""); //$NON-NLS-1$
|
setLocation(null, ""); //$NON-NLS-1$
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
|
@ -171,14 +181,17 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawInScreenPixels() {
|
public boolean drawInScreenPixels() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean pressedInTextView(PointF point){
|
public boolean pressedInTextView(float px, float py) {
|
||||||
if(latLon != null){
|
if (latLon != null) {
|
||||||
int x = view.getRotatedMapXForPoint(latLon.getLatitude(), latLon.getLongitude());
|
Rect bs = textView.getBackground().getBounds();
|
||||||
int y = view.getRotatedMapYForPoint(latLon.getLatitude(), latLon.getLongitude());
|
int x = (int) (px - view.getRotatedMapXForPoint(latLon.getLatitude(), latLon.getLongitude()));
|
||||||
if (textBorder.contains(point.x - x + textView.getWidth() / 2, point.y - y + textView.getHeight() + 8)) {
|
int y = (int) (py - view.getRotatedMapYForPoint(latLon.getLatitude(), latLon.getLongitude()));
|
||||||
|
x += bs.width() / 2;
|
||||||
|
y += bs.height() + MARGIN_Y_TO_BOX;
|
||||||
|
if (bs.contains(x, y)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,8 +199,8 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
if (pressedInTextView(point)) {
|
if (pressedInTextView(point.x, point.y)) {
|
||||||
if (selectedObject != null) {
|
if (selectedObject != null) {
|
||||||
ArrayList<String> l = new ArrayList<String>();
|
ArrayList<String> l = new ArrayList<String>();
|
||||||
OnClickListener listener = selectedContextProvider.getActionListener(l, selectedObject);
|
OnClickListener listener = selectedContextProvider.getActionListener(l, selectedObject);
|
||||||
|
@ -200,4 +213,23 @@ public class ContextMenuLayer implements OsmandMapLayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouchEvent(MotionEvent event) {
|
||||||
|
if (latLon != null) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
if(pressedInTextView(event.getX(), event.getY())){
|
||||||
|
textView.setPressed(true);
|
||||||
|
view.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
|
if(textView.isPressed()) {
|
||||||
|
textView.setPressed(false);
|
||||||
|
view.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.util.FloatMath;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class FavoritesLayer implements OsmandMapLayer, ContextMenuLayer.IContextMenuProvider {
|
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
|
|
||||||
private static final int startZoom = 6;
|
private static final int startZoom = 6;
|
||||||
private static final int radius = 15;
|
private static final int radius = 15;
|
||||||
|
@ -127,7 +127,7 @@ public class FavoritesLayer implements OsmandMapLayer, ContextMenuLayer.IContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
FavouritePoint fav = getFavoriteFromPoint(point);
|
FavouritePoint fav = getFavoriteFromPoint(point);
|
||||||
if(fav != null){
|
if(fav != null){
|
||||||
String format = view.getContext().getString(R.string.favorite) + " : " + fav.getName(); //$NON-NLS-1$
|
String format = view.getContext().getString(R.string.favorite) + " : " + fav.getName(); //$NON-NLS-1$
|
||||||
|
|
|
@ -17,7 +17,7 @@ import android.graphics.Paint.Cap;
|
||||||
import android.graphics.Paint.Join;
|
import android.graphics.Paint.Join;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
|
|
||||||
public class GPXLayer implements OsmandMapLayer {
|
public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
@ -143,7 +143,7 @@ public class GPXLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
public class MapControlsLayer implements OsmandMapLayer {
|
public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private static final int SHOW_SEEKBAR_MSG_ID = 2;
|
private static final int SHOW_SEEKBAR_MSG_ID = 2;
|
||||||
private static final int SHOW_SEEKBAR_DELAY = 7000;
|
private static final int SHOW_SEEKBAR_DELAY = 7000;
|
||||||
|
@ -215,13 +215,9 @@ public class MapControlsLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
if (modeShadow.getBounds().contains((int) point.x, (int) point.y)) {
|
if (modeShadow.getBounds().contains((int) point.x, (int) point.y)) {
|
||||||
onApplicationModePress();
|
onApplicationModePress();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.util.FloatMath;
|
import android.util.FloatMath;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class MapInfoLayer implements OsmandMapLayer {
|
public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
@ -349,13 +349,9 @@ public class MapInfoLayer implements OsmandMapLayer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
||||||
if (boundsForMiniRoute.contains(point.x, point.y) && routeLayer.getHelper().isFollowingMode()) {
|
if (boundsForMiniRoute.contains(point.x, point.y) && routeLayer.getHelper().isFollowingMode()) {
|
||||||
showMiniMap = !showMiniMap;
|
showMiniMap = !showMiniMap;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import net.osmand.plus.ResourceManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.util.FloatMath;
|
import android.util.FloatMath;
|
||||||
|
@ -257,15 +256,4 @@ public class MapTileLayer extends BaseMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ import android.view.WindowManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class OsmBugsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMenuProvider, DialogProvider {
|
public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider, DialogProvider {
|
||||||
|
|
||||||
private static final Log log = LogUtil.getLog(OsmBugsLayer.class);
|
private static final Log log = LogUtil.getLog(OsmBugsLayer.class);
|
||||||
private final static int startZoom = 8;
|
private final static int startZoom = 8;
|
||||||
|
@ -222,7 +222,7 @@ public class OsmBugsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
OpenStreetBug bug = getBugFromPoint(point);
|
OpenStreetBug bug = getBugFromPoint(point);
|
||||||
if(bug != null){
|
if(bug != null){
|
||||||
String format = activity.getString(R.string.osb_bug_name)+ " : " + bug.getName(); //$NON-NLS-1$
|
String format = activity.getString(R.string.osb_bug_name)+ " : " + bug.getName(); //$NON-NLS-1$
|
||||||
|
|
|
@ -3,19 +3,26 @@ package net.osmand.plus.views;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
public interface OsmandMapLayer {
|
public abstract class OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
public void initLayer(OsmandMapTileView view);
|
public abstract void initLayer(OsmandMapTileView view);
|
||||||
|
|
||||||
public void onDraw(Canvas canvas, RectF latlonRect, RectF tilesRect, boolean nightMode);
|
public abstract void onDraw(Canvas canvas, RectF latlonRect, RectF tilesRect, boolean nightMode);
|
||||||
|
|
||||||
public void destroyLayer();
|
public abstract void destroyLayer();
|
||||||
|
|
||||||
public boolean onTouchEvent(PointF point);
|
public boolean onSingleTap(PointF point) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onLongPressEvent(PointF point);
|
public boolean onLongPressEvent(PointF point) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTouchEvent(MotionEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns whether canvas should be rotated as
|
* This method returns whether canvas should be rotated as
|
||||||
|
@ -23,6 +30,7 @@ public interface OsmandMapLayer {
|
||||||
* If the layer draws simply layer over screen (not over map)
|
* If the layer draws simply layer over screen (not over map)
|
||||||
* it should return true.
|
* it should return true.
|
||||||
*/
|
*/
|
||||||
public boolean drawInScreenPixels();
|
public abstract boolean drawInScreenPixels();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -672,6 +672,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
animatedDraggingThread.stopAnimating();
|
animatedDraggingThread.stopAnimating();
|
||||||
}
|
}
|
||||||
|
for(int i=layers.size() - 1; i >= 0; i--) {
|
||||||
|
layers.get(i).onTouchEvent(event);
|
||||||
|
}
|
||||||
if (!multiTouchSupport.onTouchEvent(event)) {
|
if (!multiTouchSupport.onTouchEvent(event)) {
|
||||||
/* return */gestureDetector.onTouchEvent(event);
|
/* return */gestureDetector.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -765,19 +768,13 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
private class MapTileViewOnGestureListener implements OnGestureListener {
|
private class MapTileViewOnGestureListener implements OnGestureListener {
|
||||||
@Override
|
@Override
|
||||||
public boolean onDown(MotionEvent e) {
|
public boolean onDown(MotionEvent e) {
|
||||||
// enable double tap animation
|
|
||||||
// animatedDraggingThread.stopAnimating();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||||
// if (Math.abs(e1.getX() - e2.getX()) + Math.abs(e1.getY() - e2.getY()) > 50 * dm.density) {
|
|
||||||
animatedDraggingThread.startDragging(velocityX, velocityY,
|
animatedDraggingThread.startDragging(velocityX, velocityY,
|
||||||
e1.getX(), e1.getY(), e2.getX(), e2.getY(), true);
|
e1.getX(), e1.getY(), e2.getX(), e2.getY(), true);
|
||||||
// } else {
|
|
||||||
// onScroll(e1, e2, e1.getX() - e2.getX(), e1.getY() - e2.getY());
|
|
||||||
// }
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +814,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
log.debug("On click event " + point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$
|
log.debug("On click event " + point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
for (int i = layers.size() - 1; i >= 0; i--) {
|
for (int i = layers.size() - 1; i >= 0; i--) {
|
||||||
if (layers.get(i).onTouchEvent(point)) {
|
if (layers.get(i).onSingleTap(point)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMenuProvider {
|
public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
private static final int startZoom = 10;
|
private static final int startZoom = 10;
|
||||||
public static final int TEXT_WRAP = 15;
|
public static final int TEXT_WRAP = 15;
|
||||||
public static final int TEXT_LINES = 3;
|
public static final int TEXT_LINES = 3;
|
||||||
|
@ -55,10 +55,6 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PoiFilter getFilter() {
|
public PoiFilter getFilter() {
|
||||||
return filter;
|
return filter;
|
||||||
|
@ -93,7 +89,7 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
Amenity n = getAmenityFromPoint(point);
|
Amenity n = getAmenityFromPoint(point);
|
||||||
if(n != null){
|
if(n != null){
|
||||||
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(),
|
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(),
|
||||||
|
|
|
@ -16,7 +16,7 @@ import android.location.Location;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class PointLocationLayer implements OsmandMapLayer {
|
public class PointLocationLayer extends OsmandMapLayer {
|
||||||
protected final static int RADIUS = 7;
|
protected final static int RADIUS = 7;
|
||||||
protected final static float HEADING_ANGLE = 60;
|
protected final static float HEADING_ANGLE = 60;
|
||||||
|
|
||||||
|
@ -172,15 +172,5 @@ public class PointLocationLayer implements OsmandMapLayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import android.location.Location;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class PointNavigationLayer implements OsmandMapLayer {
|
public class PointNavigationLayer extends OsmandMapLayer {
|
||||||
protected final static int DIST_TO_SHOW = 80;
|
protected final static int DIST_TO_SHOW = 80;
|
||||||
|
|
||||||
private Paint point;
|
private Paint point;
|
||||||
|
@ -116,7 +116,7 @@ public class PointNavigationLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import android.widget.TextView;
|
||||||
import android.widget.FrameLayout.LayoutParams;
|
import android.widget.FrameLayout.LayoutParams;
|
||||||
|
|
||||||
|
|
||||||
public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener {
|
public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationListener {
|
||||||
|
|
||||||
private static final int BASE_TEXT_SIZE = 150;
|
private static final int BASE_TEXT_SIZE = 150;
|
||||||
private int textSize = BASE_TEXT_SIZE;
|
private int textSize = BASE_TEXT_SIZE;
|
||||||
|
@ -208,7 +208,7 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import android.graphics.Paint.Style;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class RouteLayer implements OsmandMapLayer {
|
public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class RouteLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class TransportInfoLayer implements OsmandMapLayer {
|
public class TransportInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private final TransportRouteHelper routeHelper;
|
private final TransportRouteHelper routeHelper;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
@ -109,13 +109,9 @@ public class TransportInfoLayer implements OsmandMapLayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongPressEvent(PointF point) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
int ex = (int) point.x;
|
int ex = (int) point.x;
|
||||||
int ey = (int) point.y;
|
int ey = (int) point.y;
|
||||||
if (visible && !routeHelper.getRoute().isEmpty()) {
|
if (visible && !routeHelper.getRoute().isEmpty()) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class TransportStopsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMenuProvider {
|
public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
private static final int startZoom = 12;
|
private static final int startZoom = 12;
|
||||||
|
|
||||||
private Paint pointAltUI;
|
private Paint pointAltUI;
|
||||||
|
@ -68,7 +68,7 @@ public class TransportStopsLayer implements OsmandMapLayer, ContextMenuLayer.ICo
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
TransportStop n = getFromPoint(point);
|
TransportStop n = getFromPoint(point);
|
||||||
if(n != null){
|
if(n != null){
|
||||||
Toast.makeText(view.getContext(), getStopDescription(n, true), Toast.LENGTH_LONG).show();
|
Toast.makeText(view.getContext(), getStopDescription(n, true), Toast.LENGTH_LONG).show();
|
||||||
|
|
Loading…
Reference in a new issue