Try to save favorite point
This commit is contained in:
parent
a2b45ca89b
commit
6c5a940c06
21 changed files with 154 additions and 123 deletions
|
@ -110,6 +110,9 @@ public class MapActivityLayers {
|
|||
mapTextLayer = new MapTextLayer();
|
||||
// 5.95 all labels
|
||||
mapView.addLayer(mapTextLayer, 5.95f);
|
||||
// 8. context menu layer
|
||||
contextMenuLayer = new ContextMenuLayer(activity);
|
||||
mapView.addLayer(contextMenuLayer, 8);
|
||||
// mapView.addLayer(underlayLayer, -0.5f);
|
||||
mapTileLayer = new MapTileLayer(true);
|
||||
mapView.addLayer(mapTileLayer, 0.0f);
|
||||
|
@ -156,8 +159,6 @@ public class MapActivityLayers {
|
|||
impassableRoadsLayer = new ImpassableRoadsLayer(activity);
|
||||
mapView.addLayer(impassableRoadsLayer, 7.5f);
|
||||
// 8. context menu layer
|
||||
contextMenuLayer = new ContextMenuLayer(activity);
|
||||
mapView.addLayer(contextMenuLayer, 8);
|
||||
// 9. map info layer
|
||||
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
|
||||
mapView.addLayer(mapInfoLayer, 9);
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.DataTileManager;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -202,4 +201,5 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -24,7 +24,6 @@ import android.widget.EditText;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -718,6 +717,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -626,4 +625,5 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -184,4 +183,5 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.graphics.PointF;
|
|||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
|
|
@ -188,4 +188,5 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.routepointsnavigation;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -142,5 +141,4 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.view.MotionEvent;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -60,10 +59,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
|
||||
private boolean mInChangeMarkerPositionMode;
|
||||
|
||||
private int previousMarkerX;
|
||||
private int previousMarkerY;
|
||||
private Object selectedObj;
|
||||
|
||||
public ContextMenuLayer(MapActivity activity) {
|
||||
this.activity = activity;
|
||||
menu = activity.getContextMenu();
|
||||
|
@ -112,16 +107,15 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
int x = previousMarkerX;
|
||||
int y = previousMarkerY;
|
||||
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
// TODO draw marker if selection was only marker?
|
||||
// int x = previousMarkerX;
|
||||
// int y = previousMarkerY;
|
||||
// canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
|
||||
// contextMarker.draw(canvas);
|
||||
} else if (menu.isActive()) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
previousMarkerX = x;
|
||||
previousMarkerY = y;
|
||||
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
}
|
||||
|
@ -157,16 +151,24 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return false;
|
||||
}
|
||||
if (pressedContextMarker(tileBox, point.x, point.y)) {
|
||||
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(VIBRATE_SHORT);
|
||||
|
||||
mInChangeMarkerPositionMode = true;
|
||||
activity.getContextMenu().hide();
|
||||
LatLon latLon = tileBox.getCenterLatLon();
|
||||
mMoveMarkerBottomSheetHelper.show(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
||||
view.tryMovingObject(selectedObj);
|
||||
return true;
|
||||
Object obj = menu.getObject() ;
|
||||
if (obj != null && isObjectMoveable(obj)) {
|
||||
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(VIBRATE_SHORT);
|
||||
mInChangeMarkerPositionMode = true;
|
||||
activity.getContextMenu().hide();
|
||||
LatLon ll = menu.getLatLon();
|
||||
RotatedTileBox rb = new RotatedTileBox(tileBox);
|
||||
PointF pf = getMoveableCenterPoint(rb);
|
||||
rb.setCenterLocation(pf.x, pf.y);
|
||||
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
|
||||
double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
view.setLatLon(lat, lon);
|
||||
mMoveMarkerBottomSheetHelper.show(menu.getLeftIcon());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
showContextMenu(point, tileBox, true);
|
||||
|
@ -174,15 +176,48 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return true;
|
||||
}
|
||||
|
||||
public PointF getMoveableCenterPoint(RotatedTileBox tb) {
|
||||
return new PointF(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
|
||||
}
|
||||
|
||||
public Object getMoveableObject() {
|
||||
return mInChangeMarkerPositionMode ? menu.getObject() : null;
|
||||
}
|
||||
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
for (OsmandMapLayer lt : view.getLayers()) {
|
||||
if (lt instanceof ContextMenuLayer.IContextMenuProvider) {
|
||||
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) lt;
|
||||
if(l.isObjectMoveable(o)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void applyMovedObject(Object o, LatLon position) {
|
||||
for (OsmandMapLayer lt : view.getLayers()) {
|
||||
if (lt instanceof ContextMenuLayer.IContextMenuProvider) {
|
||||
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) lt;
|
||||
if(l.isObjectMoveable(o)) {
|
||||
l.applyNewObjectPosition(o, position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyNewMarkerPosition() {
|
||||
if (!mInChangeMarkerPositionMode) {
|
||||
throw new IllegalStateException("Not in change marker position mode");
|
||||
}
|
||||
mInChangeMarkerPositionMode = false;
|
||||
|
||||
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
|
||||
int newMarkerX = previousMarkerX;
|
||||
int newMarkerY = previousMarkerY;
|
||||
PointF newMarkerPosition = new PointF(newMarkerX, newMarkerY);
|
||||
PointF newMarkerPosition = new PointF(tileBox.getPixWidth() / 2,
|
||||
tileBox.getPixHeight() / 2);
|
||||
// TODO pass object properly
|
||||
showContextMenu(newMarkerPosition, tileBox, true);
|
||||
view.refreshMap();
|
||||
}
|
||||
|
@ -202,7 +237,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private boolean showContextMenu(PointF point, RotatedTileBox tileBox, boolean showUnknownLocation) {
|
||||
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false);
|
||||
if (selectedObjects.size() == 1) {
|
||||
selectedObj = selectedObjects.keySet().iterator().next();
|
||||
Object selectedObj = selectedObjects.keySet().iterator().next();
|
||||
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
|
||||
LatLon latLon = null;
|
||||
PointDescription pointDescription = null;
|
||||
|
@ -405,8 +440,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
LatLon getObjectLocation(Object o);
|
||||
|
||||
String getObjectDescription(Object o);
|
||||
|
||||
PointDescription getObjectName(Object o);
|
||||
|
||||
boolean disableSingleTap();
|
||||
|
@ -414,8 +447,18 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
boolean disableLongPressOnMap();
|
||||
|
||||
boolean isObjectClickable(Object o);
|
||||
|
||||
}
|
||||
|
||||
public interface IMoveObjectProvider {
|
||||
|
||||
boolean isObjectMoveable(Object o);
|
||||
|
||||
boolean applyNewObjectPosition(Object o, LatLon position);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public interface IContextMenuProviderSelection {
|
||||
|
||||
int getOrder(Object o);
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.graphics.PointF;
|
|||
import android.text.TextPaint;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -547,4 +546,5 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
public void clearSelectedObject() {
|
||||
selectedObjects = new LinkedList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -10,50 +24,30 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider, MapTextProvider<LocationPoint> {
|
||||
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
|
||||
ContextMenuLayer.IMoveObjectProvider, MapTextProvider<FavouritePoint> {
|
||||
|
||||
protected int startZoom = 6;
|
||||
|
||||
protected OsmandMapTileView view;
|
||||
private Paint paint;
|
||||
private FavouritesDbHelper favorites;
|
||||
protected List<LocationPoint> cache = new ArrayList<LocationPoint>();
|
||||
protected List<FavouritePoint> cache = new ArrayList<FavouritePoint>();
|
||||
private MapTextLayer textLayer;
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
private int defaultColor;
|
||||
|
||||
private OsmandSettings settings;
|
||||
|
||||
private LocationPoint objectInMotion;
|
||||
private int objectInMotionX;
|
||||
private int objectInMotionY;
|
||||
|
||||
protected Class<? extends LocationPoint> getFavoriteClass() {
|
||||
return (Class<? extends LocationPoint>) FavouritePoint.class;
|
||||
}
|
||||
|
||||
protected String getObjName() {
|
||||
return view.getContext().getString(R.string.favorite);
|
||||
}
|
||||
|
||||
protected List<? extends LocationPoint> getPoints() {
|
||||
protected List<? extends FavouritePoint> getPoints() {
|
||||
return favorites.getFavouritePoints();
|
||||
}
|
||||
|
||||
|
@ -67,6 +61,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
settings = view.getApplication().getSettings();
|
||||
favorites = view.getApplication().getFavorites();
|
||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
defaultColor = view.getResources().getColor(R.color.color_favorite);
|
||||
|
@ -92,9 +87,11 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (objectInMotion != null) {
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), objectInMotion.getColor(), true);
|
||||
fid.drawBitmapInCenter(canvas, objectInMotionX, objectInMotionY);
|
||||
if (contextMenuLayer.getMoveableObject() instanceof FavouritePoint) {
|
||||
FavouritePoint fp = (FavouritePoint) contextMenuLayer.getMoveableObject();
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), fp.getColor(), true);
|
||||
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
|
||||
fid.drawBitmapInCenter(canvas, pf.x, pf.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +106,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
// request to load
|
||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<LocationPoint> fullObjects = new ArrayList<>();
|
||||
List<FavouritePoint> fullObjects = new ArrayList<>();
|
||||
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
||||
List<LatLon> smallObjectsLatLon = new ArrayList<>();
|
||||
for (LocationPoint o : getPoints()) {
|
||||
for (FavouritePoint o : getPoints()) {
|
||||
if (!o.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -130,8 +127,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
|
||||
}
|
||||
}
|
||||
for (LocationPoint o : fullObjects) {
|
||||
if (o != objectInMotion) {
|
||||
for (FavouritePoint o : fullObjects) {
|
||||
if (o != contextMenuLayer.getMoveableObject()) {
|
||||
drawPoint(canvas, tileBox, latLonBounds, o);
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +143,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
}
|
||||
|
||||
|
||||
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, LocationPoint o) {
|
||||
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, FavouritePoint o) {
|
||||
if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
|
||||
&& o.getLongitude() <= latLonBounds.right ) {
|
||||
cache.add(o);
|
||||
|
@ -163,17 +160,17 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
return false;
|
||||
}
|
||||
|
||||
public void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super LocationPoint> res) {
|
||||
public void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super FavouritePoint> res) {
|
||||
int r = (int) (15 * tb.getDensity());
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
for (LocationPoint n : getPoints()) {
|
||||
for (FavouritePoint n : getPoints()) {
|
||||
getFavFromPoint(tb, res, r, ex, ey, n);
|
||||
}
|
||||
}
|
||||
|
||||
private void getFavFromPoint(RotatedTileBox tb, List<? super LocationPoint> res, int r, int ex, int ey,
|
||||
LocationPoint n) {
|
||||
private void getFavFromPoint(RotatedTileBox tb, List<? super FavouritePoint> res, int r, int ex, int ey,
|
||||
FavouritePoint n) {
|
||||
if (n.isVisible()) {
|
||||
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
|
@ -183,21 +180,11 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
Class<? extends LocationPoint> fcl = getFavoriteClass();
|
||||
if(o!= null && fcl.isInstance(o)) {
|
||||
return PointDescription.getSimpleName((LocationPoint) o, view.getContext()) ;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if(o instanceof LocationPoint){
|
||||
return ((LocationPoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$
|
||||
if(o instanceof FavouritePoint){
|
||||
return ((FavouritePoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -214,7 +201,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
public boolean isObjectClickable(Object o) {
|
||||
return o instanceof LocationPoint && o != objectInMotion;
|
||||
return o instanceof FavouritePoint && o != contextMenuLayer.getMoveableObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,36 +213,40 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
if(o instanceof LocationPoint){
|
||||
return new LatLon(((LocationPoint)o).getLatitude(), ((LocationPoint)o).getLongitude());
|
||||
if(o instanceof FavouritePoint){
|
||||
return new LatLon(((FavouritePoint)o).getLatitude(), ((FavouritePoint)o).getLongitude());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLon getTextLocation(LocationPoint o) {
|
||||
public LatLon getTextLocation(FavouritePoint o) {
|
||||
return new LatLon(o.getLatitude(), o.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextShift(LocationPoint o, RotatedTileBox rb) {
|
||||
public int getTextShift(FavouritePoint o, RotatedTileBox rb) {
|
||||
return (int) (16 * rb.getDensity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LocationPoint o) {
|
||||
public String getText(FavouritePoint o) {
|
||||
return PointDescription.getSimpleName(o, view.getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTryMovingObject(Object selectedObject, RotatedTileBox tileBox) {
|
||||
if (selectedObject instanceof LocationPoint) {
|
||||
objectInMotion = (LocationPoint) selectedObject;
|
||||
objectInMotionX = (int) tileBox.getPixXFromLatLon(objectInMotion.getLatitude(), objectInMotion.getLongitude());
|
||||
objectInMotionY = (int) tileBox.getPixYFromLatLon(objectInMotion.getLatitude(), objectInMotion.getLongitude());
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
return o instanceof FavouritePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyNewObjectPosition(Object o, LatLon position) {
|
||||
if(o instanceof FavouritePoint) {
|
||||
favorites.editFavourite((FavouritePoint) o, position.getLatitude(), position.getLongitude());
|
||||
return true;
|
||||
}
|
||||
return super.onTryMovingObject(selectedObject, tileBox);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.graphics.PointF;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -473,6 +472,4 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.os.Handler;
|
|||
import android.os.Message;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -489,4 +488,5 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Override
|
||||
public void clearSelectedObject() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -40,11 +41,21 @@ public class MoveMarkerBottomSheetHelper {
|
|||
});
|
||||
}
|
||||
|
||||
public void show(double lat, double lon) {
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
public void onDraw(RotatedTileBox rt) {
|
||||
double lat = rt.getLatFromPixel(rt.getPixWidth() / 2, rt.getPixHeight() / 2);
|
||||
double lon = rt.getLonFromPixel(rt.getPixWidth() / 2, rt.getPixHeight() / 2);
|
||||
mDescription.setText(mContext.getString(R.string.lat_lon_pattern, lat, lon));
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mView.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void show(Drawable drawable) {
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
((ImageView) mView.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -53,9 +53,6 @@ public abstract class OsmandMapLayer {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean onTryMovingObject(Object selectedObject, RotatedTileBox tileBox) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params) {
|
||||
task.execute(params);
|
||||
|
|
|
@ -604,14 +604,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean tryMovingObject(Object selectedObject) {
|
||||
for (OsmandMapLayer layer : layers) {
|
||||
if (layer.onTryMovingObject(selectedObject, getCurrentRotatedTileBox())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void drawMapPosition(Canvas canvas, float x, float y) {
|
||||
canvas.drawCircle(x, y, 3 * dm.density, paintCenter);
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.ValueHolder;
|
||||
|
@ -558,4 +557,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -223,4 +222,5 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
|
@ -242,4 +241,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.PointF;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -217,4 +216,5 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue