diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index ea79b255bf..9b0606c0ac 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -51,7 +51,7 @@ import net.osmand.aidl.note.StopRecordingParams; import net.osmand.aidl.gpx.RemoveGpxParams; -import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams; +import net.osmand.aidl.maplayer.point.ShowMapPointParams; // NOTE: Add new methods at the end of file!!! @@ -104,5 +104,5 @@ interface IOsmAndAidlInterface { boolean removeGpx(in RemoveGpxParams params); - boolean showLayerPointOnMap(in ShowLayerPointOnMapParams params); + boolean showMapPoint(in ShowMapPointParams params); } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 61703a30dc..5b36792d1e 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -833,23 +833,28 @@ public class OsmandAidlApi { } } - boolean showLayerPointOnMap(String layerId, String pointId) { - if (!TextUtils.isEmpty(layerId) && !TextUtils.isEmpty(pointId)) { - AMapLayer layer = layers.get(layerId); - if (layer != null) { - AMapPoint point = layer.getPoint(pointId); - if (point != null) { - app.getSettings().setMapLocationToShow( - point.getLocation().getLatitude(), - point.getLocation().getLongitude(), - DEFAULT_ZOOM, - new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName()), - false, - point - ); - MapActivity.launchMapActivityMoveToTop(app); + boolean showMapPoint(String layerId, AMapPoint point) { + if (point != null) { + if (!TextUtils.isEmpty(layerId)) { + AMapLayer layer = layers.get(layerId); + if (layer != null) { + AMapPoint p = layer.getPoint(point.getId()); + if (p != null) { + point = p; + } } } + app.getSettings().setMapLocationToShow( + point.getLocation().getLatitude(), + point.getLocation().getLongitude(), + DEFAULT_ZOOM, + new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName()), + false, + point + ); + MapActivity.launchMapActivityMoveToTop(app); + + return true; } return false; } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index e115275ab6..8da6e91a2a 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -23,10 +23,10 @@ import net.osmand.aidl.gpx.StopGpxRecordingParams; import net.osmand.aidl.map.SetMapLocationParams; import net.osmand.aidl.maplayer.AddMapLayerParams; import net.osmand.aidl.maplayer.RemoveMapLayerParams; -import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams; import net.osmand.aidl.maplayer.UpdateMapLayerParams; import net.osmand.aidl.maplayer.point.AddMapPointParams; import net.osmand.aidl.maplayer.point.RemoveMapPointParams; +import net.osmand.aidl.maplayer.point.ShowMapPointParams; import net.osmand.aidl.maplayer.point.UpdateMapPointParams; import net.osmand.aidl.mapmarker.AddMapMarkerParams; import net.osmand.aidl.mapmarker.RemoveMapMarkerParams; @@ -203,9 +203,9 @@ public class OsmandAidlService extends Service { } @Override - public boolean showLayerPointOnMap(ShowLayerPointOnMapParams params) throws RemoteException { + public boolean showMapPoint(ShowMapPointParams params) throws RemoteException { try { - return params != null && getApi("showLayerPointOnMap").showLayerPointOnMap(params.getLayerId(), params.getPointId()); + return params != null && getApi("showMapPoint").showMapPoint(params.getLayerId(), params.getPoint()); } catch (Exception e) { handleException(e); return false; diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.aidl deleted file mode 100644 index 7bb973b2ce..0000000000 --- a/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package net.osmand.aidl.maplayer; - -parcelable ShowLayerPointOnMapParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.java deleted file mode 100644 index f8be2f55dc..0000000000 --- a/OsmAnd/src/net/osmand/aidl/maplayer/ShowLayerPointOnMapParams.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.osmand.aidl.maplayer; - -import android.os.Parcel; -import android.os.Parcelable; - -public class ShowLayerPointOnMapParams implements Parcelable { - - private String layerId; - private String pointId; - - public ShowLayerPointOnMapParams(String layerId, String pointId) { - this.layerId = layerId; - this.pointId = pointId; - } - - public ShowLayerPointOnMapParams(Parcel in) { - layerId = in.readString(); - pointId = in.readString(); - } - - public String getLayerId() { - return layerId; - } - - public String getPointId() { - return pointId; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(layerId); - dest.writeString(pointId); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public ShowLayerPointOnMapParams createFromParcel(Parcel in) { - return new ShowLayerPointOnMapParams(in); - } - - @Override - public ShowLayerPointOnMapParams[] newArray(int size) { - return new ShowLayerPointOnMapParams[size]; - } - }; -} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.aidl new file mode 100644 index 0000000000..54ff9b2075 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer.point; + +parcelable ShowMapPointParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.java new file mode 100644 index 0000000000..5b6e0c17c9 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/ShowMapPointParams.java @@ -0,0 +1,56 @@ +package net.osmand.aidl.maplayer.point; + +import android.os.Parcel; +import android.os.Parcelable; + +public class ShowMapPointParams implements Parcelable { + + private String layerId; + private AMapPoint point; + + public ShowMapPointParams(String layerId, AMapPoint point) { + this.layerId = layerId; + this.point = point; + } + + public ShowMapPointParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new + Creator() { + @Override + public ShowMapPointParams createFromParcel(Parcel in) { + return new ShowMapPointParams(in); + } + + @Override + public ShowMapPointParams[] newArray(int size) { + return new ShowMapPointParams[size]; + } + }; + + public String getLayerId() { + return layerId; + } + + public AMapPoint getPoint() { + return point; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeString(layerId); + out.writeParcelable(point, flags); + } + + private void readFromParcel(Parcel in) { + layerId = in.readString(); + point = in.readParcelable(AMapPoint.class.getClassLoader()); + } + + @Override + public int describeContents() { + return 0; + } +}