Merge pull request #7187 from fsbugreporter/AIDL_update_markers
AIDL updates updateMapMarker, removeMapMarker, removeAllMarkers
This commit is contained in:
commit
ab9167122e
5 changed files with 90 additions and 20 deletions
|
@ -105,16 +105,23 @@ interface IOsmAndAidlInterface {
|
||||||
boolean addMapMarker(in AddMapMarkerParams params);
|
boolean addMapMarker(in AddMapMarkerParams params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add map marker at given location.
|
* Remove map marker.
|
||||||
|
*
|
||||||
|
* If ignoreCoordinates is false the marker is only removed if lat/lon match the currently set values of the marker.
|
||||||
|
* If ignoreCoordinates is true the marker is removed if the name matches, the values of lat/lon are ignored.
|
||||||
*
|
*
|
||||||
* @param lat (double) - latitude.
|
* @param lat (double) - latitude.
|
||||||
* @param lon (double) - longitude.
|
* @param lon (double) - longitude.
|
||||||
* @param name (String)- name of marker.
|
* @param name (String)- name of marker.
|
||||||
|
* @param ignoreCoordinates (boolean) - flag to determine whether lat/lon shall be ignored
|
||||||
*/
|
*/
|
||||||
boolean removeMapMarker(in RemoveMapMarkerParams params);
|
boolean removeMapMarker(in RemoveMapMarkerParams params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update map marker at given location with name.
|
* Update map marker.
|
||||||
|
*
|
||||||
|
* If ignoreCoordinates is false the marker gets updated only if latPrev/lonPrev match the currently set values of the marker.
|
||||||
|
* If ignoreCoordinates is true the marker gets updated if the name matches, the values of latPrev/lonPrev are ignored.
|
||||||
*
|
*
|
||||||
* @param latPrev (double) - latitude (current marker).
|
* @param latPrev (double) - latitude (current marker).
|
||||||
* @param lonPrev (double) - longitude (current marker).
|
* @param lonPrev (double) - longitude (current marker).
|
||||||
|
@ -122,6 +129,7 @@ interface IOsmAndAidlInterface {
|
||||||
* @param latNew (double) - latitude (new marker).
|
* @param latNew (double) - latitude (new marker).
|
||||||
* @param lonNew (double) - longitude (new marker).
|
* @param lonNew (double) - longitude (new marker).
|
||||||
* @param nameNew (String) - name (new marker).
|
* @param nameNew (String) - name (new marker).
|
||||||
|
* @param ignoreCoordinates (boolean) - flag to determine whether latPrev/lonPrev shall be ignored
|
||||||
*/
|
*/
|
||||||
boolean updateMapMarker(in UpdateMapMarkerParams params);
|
boolean updateMapMarker(in UpdateMapMarkerParams params);
|
||||||
|
|
||||||
|
@ -816,4 +824,9 @@ interface IOsmAndAidlInterface {
|
||||||
* @params callback (IOsmAndAidlCallback) - callback to notify user on voice message
|
* @params callback (IOsmAndAidlCallback) - callback to notify user on voice message
|
||||||
*/
|
*/
|
||||||
long registerForVoiceRouterMessages(in ANavigationVoiceRouterMessageParams params, IOsmAndAidlCallback callback);
|
long registerForVoiceRouterMessages(in ANavigationVoiceRouterMessageParams params, IOsmAndAidlCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all map markers.
|
||||||
|
*/
|
||||||
|
boolean removeAllMapMarkers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1037,32 +1037,50 @@ public class OsmandAidlApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean removeMapMarker(AMapMarker marker) {
|
boolean removeMapMarker(AMapMarker marker, boolean ignoreCoordinates) {
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
LatLon latLon = new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude());
|
LatLon latLon = new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude());
|
||||||
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||||
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
||||||
for (MapMarker m : mapMarkers) {
|
for (MapMarker m : mapMarkers) {
|
||||||
if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
|
if (m.getOnlyName().equals(marker.getName())) {
|
||||||
|
if (ignoreCoordinates || latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
|
||||||
markersHelper.moveMapMarkerToHistory(m);
|
markersHelper.moveMapMarkerToHistory(m);
|
||||||
refreshMap();
|
refreshMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew) {
|
boolean removeAllMapMarkers() {
|
||||||
|
boolean refreshNeeded = false;
|
||||||
|
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||||
|
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
||||||
|
for (MapMarker m : mapMarkers) {
|
||||||
|
markersHelper.moveMapMarkerToHistory(m);
|
||||||
|
refreshNeeded = true;
|
||||||
|
}
|
||||||
|
if (refreshNeeded) {
|
||||||
|
refreshMap();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew, boolean ignoreCoordinates) {
|
||||||
if (markerPrev != null && markerNew != null) {
|
if (markerPrev != null && markerNew != null) {
|
||||||
LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude());
|
LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude());
|
||||||
LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude());
|
LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude());
|
||||||
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||||
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
||||||
for (MapMarker m : mapMarkers) {
|
for (MapMarker m : mapMarkers) {
|
||||||
if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
|
if (m.getOnlyName().equals(markerPrev.getName())) {
|
||||||
|
if (ignoreCoordinates || latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
|
||||||
PointDescription pd = new PointDescription(
|
PointDescription pd = new PointDescription(
|
||||||
PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
|
PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
|
||||||
MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
|
MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
|
||||||
|
@ -1074,6 +1092,7 @@ public class OsmandAidlApi {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -282,7 +282,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
|
||||||
public boolean removeMapMarker(RemoveMapMarkerParams params) {
|
public boolean removeMapMarker(RemoveMapMarkerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("removeMapMarker");
|
OsmandAidlApi api = getApi("removeMapMarker");
|
||||||
return params != null && api != null && api.removeMapMarker(params.getMarker());
|
return params != null && api != null && api.removeMapMarker(params.getMarker(), params.getIgnoreCoordinates());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
|
@ -293,7 +293,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
|
||||||
public boolean updateMapMarker(UpdateMapMarkerParams params) {
|
public boolean updateMapMarker(UpdateMapMarkerParams params) {
|
||||||
try {
|
try {
|
||||||
OsmandAidlApi api = getApi("updateMapMarker");
|
OsmandAidlApi api = getApi("updateMapMarker");
|
||||||
return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew());
|
return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew(), params.getIgnoreCoordinates());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1163,6 +1163,17 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
|
||||||
return UNKNOWN_API_ERROR;
|
return UNKNOWN_API_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAllMapMarkers() {
|
||||||
|
try {
|
||||||
|
OsmandAidlApi api = getApi("removeAllMapMarkers");
|
||||||
|
return api != null && api.removeAllMapMarkers();
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static class AidlCallbackParams {
|
public static class AidlCallbackParams {
|
||||||
|
|
|
@ -6,9 +6,16 @@ import android.os.Parcelable;
|
||||||
public class RemoveMapMarkerParams implements Parcelable {
|
public class RemoveMapMarkerParams implements Parcelable {
|
||||||
|
|
||||||
private AMapMarker marker;
|
private AMapMarker marker;
|
||||||
|
private boolean ignoreCoordinates;
|
||||||
|
|
||||||
public RemoveMapMarkerParams(AMapMarker marker) {
|
public RemoveMapMarkerParams(AMapMarker marker) {
|
||||||
this.marker = marker;
|
this.marker = marker;
|
||||||
|
this.ignoreCoordinates = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemoveMapMarkerParams(AMapMarker marker, boolean ignoreCoordinates) {
|
||||||
|
this.marker = marker;
|
||||||
|
this.ignoreCoordinates = ignoreCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoveMapMarkerParams(Parcel in) {
|
public RemoveMapMarkerParams(Parcel in) {
|
||||||
|
@ -30,12 +37,18 @@ public class RemoveMapMarkerParams implements Parcelable {
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIgnoreCoordinates() {
|
||||||
|
return ignoreCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeParcelable(marker, flags);
|
out.writeParcelable(marker, flags);
|
||||||
|
out.writeInt(ignoreCoordinates ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFromParcel(Parcel in) {
|
private void readFromParcel(Parcel in) {
|
||||||
marker = in.readParcelable(AMapMarker.class.getClassLoader());
|
marker = in.readParcelable(AMapMarker.class.getClassLoader());
|
||||||
|
ignoreCoordinates = in.readInt() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
|
|
|
@ -7,10 +7,18 @@ public class UpdateMapMarkerParams implements Parcelable {
|
||||||
|
|
||||||
private AMapMarker markerPrev;
|
private AMapMarker markerPrev;
|
||||||
private AMapMarker markerNew;
|
private AMapMarker markerNew;
|
||||||
|
private boolean ignoreCoordinates;
|
||||||
|
|
||||||
public UpdateMapMarkerParams(AMapMarker markerPrev, AMapMarker markerNew) {
|
public UpdateMapMarkerParams(AMapMarker markerPrev, AMapMarker markerNew) {
|
||||||
this.markerPrev = markerPrev;
|
this.markerPrev = markerPrev;
|
||||||
this.markerNew = markerNew;
|
this.markerNew = markerNew;
|
||||||
|
this.ignoreCoordinates = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateMapMarkerParams(AMapMarker markerPrev, AMapMarker markerNew, boolean ignoreCoordinates) {
|
||||||
|
this.markerPrev = markerPrev;
|
||||||
|
this.markerNew = markerNew;
|
||||||
|
this.ignoreCoordinates = ignoreCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateMapMarkerParams(Parcel in) {
|
public UpdateMapMarkerParams(Parcel in) {
|
||||||
|
@ -36,14 +44,20 @@ public class UpdateMapMarkerParams implements Parcelable {
|
||||||
return markerNew;
|
return markerNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIgnoreCoordinates() {
|
||||||
|
return ignoreCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeParcelable(markerPrev, flags);
|
out.writeParcelable(markerPrev, flags);
|
||||||
out.writeParcelable(markerNew, flags);
|
out.writeParcelable(markerNew, flags);
|
||||||
|
out.writeInt(ignoreCoordinates ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFromParcel(Parcel in) {
|
private void readFromParcel(Parcel in) {
|
||||||
markerPrev = in.readParcelable(AMapMarker.class.getClassLoader());
|
markerPrev = in.readParcelable(AMapMarker.class.getClassLoader());
|
||||||
markerNew = in.readParcelable(AMapMarker.class.getClassLoader());
|
markerNew = in.readParcelable(AMapMarker.class.getClassLoader());
|
||||||
|
ignoreCoordinates = in.readInt() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
|
|
Loading…
Reference in a new issue