Add method for opening OsmAnd at given AMapPoint to the AIDL-API
This commit is contained in:
parent
a94dbfe947
commit
fbfdadfc87
5 changed files with 95 additions and 8 deletions
|
@ -51,6 +51,8 @@ import net.osmand.aidl.note.StopRecordingParams;
|
||||||
|
|
||||||
import net.osmand.aidl.gpx.RemoveGpxParams;
|
import net.osmand.aidl.gpx.RemoveGpxParams;
|
||||||
|
|
||||||
|
import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams;
|
||||||
|
|
||||||
// NOTE: Add new methods at the end of file!!!
|
// NOTE: Add new methods at the end of file!!!
|
||||||
|
|
||||||
interface IOsmAndAidlInterface {
|
interface IOsmAndAidlInterface {
|
||||||
|
@ -101,4 +103,6 @@ interface IOsmAndAidlInterface {
|
||||||
boolean navigateGpx(in NavigateGpxParams params);
|
boolean navigateGpx(in NavigateGpxParams params);
|
||||||
|
|
||||||
boolean removeGpx(in RemoveGpxParams params);
|
boolean removeGpx(in RemoveGpxParams params);
|
||||||
|
|
||||||
|
boolean showLayerPointOnMap(in ShowLayerPointOnMapParams params);
|
||||||
}
|
}
|
|
@ -9,8 +9,8 @@ import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -155,10 +155,6 @@ public class OsmandAidlApi {
|
||||||
receivers = new TreeMap<String, BroadcastReceiver>();
|
receivers = new TreeMap<String, BroadcastReceiver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandMapLayer getMapLayer(@NonNull String id) {
|
|
||||||
return mapLayers.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerRefreshMapReceiver(final MapActivity mapActivity) {
|
private void registerRefreshMapReceiver(final MapActivity mapActivity) {
|
||||||
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
|
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -835,6 +831,27 @@ 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(),
|
||||||
|
15,
|
||||||
|
new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName()),
|
||||||
|
false,
|
||||||
|
point
|
||||||
|
);
|
||||||
|
MapActivity.launchMapActivityMoveToTop(app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean putMapPoint(String layerId, AMapPoint point) {
|
boolean putMapPoint(String layerId, AMapPoint point) {
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
AMapLayer layer = layers.get(layerId);
|
AMapLayer layer = layers.get(layerId);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.aidl.calculateroute.CalculateRouteParams;
|
import net.osmand.aidl.calculateroute.CalculateRouteParams;
|
||||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||||
|
@ -22,6 +23,7 @@ import net.osmand.aidl.gpx.StopGpxRecordingParams;
|
||||||
import net.osmand.aidl.map.SetMapLocationParams;
|
import net.osmand.aidl.map.SetMapLocationParams;
|
||||||
import net.osmand.aidl.maplayer.AddMapLayerParams;
|
import net.osmand.aidl.maplayer.AddMapLayerParams;
|
||||||
import net.osmand.aidl.maplayer.RemoveMapLayerParams;
|
import net.osmand.aidl.maplayer.RemoveMapLayerParams;
|
||||||
|
import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams;
|
||||||
import net.osmand.aidl.maplayer.UpdateMapLayerParams;
|
import net.osmand.aidl.maplayer.UpdateMapLayerParams;
|
||||||
import net.osmand.aidl.maplayer.point.AddMapPointParams;
|
import net.osmand.aidl.maplayer.point.AddMapPointParams;
|
||||||
import net.osmand.aidl.maplayer.point.RemoveMapPointParams;
|
import net.osmand.aidl.maplayer.point.RemoveMapPointParams;
|
||||||
|
@ -35,16 +37,16 @@ import net.osmand.aidl.mapwidget.UpdateMapWidgetParams;
|
||||||
import net.osmand.aidl.navigation.NavigateGpxParams;
|
import net.osmand.aidl.navigation.NavigateGpxParams;
|
||||||
import net.osmand.aidl.navigation.NavigateParams;
|
import net.osmand.aidl.navigation.NavigateParams;
|
||||||
import net.osmand.aidl.note.StartAudioRecordingParams;
|
import net.osmand.aidl.note.StartAudioRecordingParams;
|
||||||
|
import net.osmand.aidl.note.StartVideoRecordingParams;
|
||||||
import net.osmand.aidl.note.StopRecordingParams;
|
import net.osmand.aidl.note.StopRecordingParams;
|
||||||
import net.osmand.aidl.note.TakePhotoNoteParams;
|
import net.osmand.aidl.note.TakePhotoNoteParams;
|
||||||
import net.osmand.aidl.note.StartVideoRecordingParams;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class OsmandAidlService extends Service {
|
public class OsmandAidlService extends Service {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
||||||
|
@ -200,6 +202,16 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showLayerPointOnMap(ShowLayerPointOnMapParams params) throws RemoteException {
|
||||||
|
try {
|
||||||
|
return params != null && getApi("showLayerPointOnMap").showLayerPointOnMap(params.getLayerId(), params.getPointId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addMapPoint(AddMapPointParams params) throws RemoteException {
|
public boolean addMapPoint(AddMapPointParams params) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidl.maplayer;
|
||||||
|
|
||||||
|
parcelable ShowLayerPointOnMapParams;
|
|
@ -0,0 +1,51 @@
|
||||||
|
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<ShowLayerPointOnMapParams> CREATOR = new Creator<ShowLayerPointOnMapParams>() {
|
||||||
|
@Override
|
||||||
|
public ShowLayerPointOnMapParams createFromParcel(Parcel in) {
|
||||||
|
return new ShowLayerPointOnMapParams(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShowLayerPointOnMapParams[] newArray(int size) {
|
||||||
|
return new ShowLayerPointOnMapParams[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue