Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-07-01 15:38:07 +02:00
commit e4a5524ce9
7 changed files with 186 additions and 2 deletions

View file

@ -3,6 +3,9 @@ package net.osmand.aidl;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.map.SetMapLocationParams;
import net.osmand.aidl.favorite.AFavorite;
import net.osmand.aidl.favorite.AddFavoriteParams;
import net.osmand.aidl.mapmarker.AMapMarker;
import net.osmand.aidl.mapmarker.AddMapMarkerParams;
import net.osmand.aidl.mapmarker.RemoveMapMarkerParams;
@ -31,6 +34,8 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams;
interface IOsmAndAidlInterface {
boolean addFavorite(in AddFavoriteParams params);
boolean addMapMarker(in AddMapMarkerParams params);
boolean removeMapMarker(in RemoveMapMarkerParams params);
boolean updateMapMarker(in UpdateMapMarkerParams params);

View file

@ -9,13 +9,16 @@ import android.os.ParcelFileDescriptor;
import android.view.View;
import net.osmand.IndexConstants;
import net.osmand.aidl.favorite.AFavorite;
import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.maplayer.AMapLayer;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.mapmarker.AMapMarker;
import net.osmand.aidl.mapwidget.AMapWidget;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
@ -23,6 +26,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.views.AidlMapLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer;
@ -345,6 +349,24 @@ public class OsmandAidlApi {
return control;
}
boolean addFavorite(AFavorite favorite) {
if (favorite != null) {
FavouritesDbHelper favoritesHelper = app.getFavorites();
FavouritePoint point = new FavouritePoint(favorite.getLat(), favorite.getLon(), favorite.getName(), favorite.getCategory());
point.setDescription(favorite.getDescription());
int color = 0;
if (!Algorithms.isEmpty(favorite.getColor())) {
color = ColorDialogs.getColorByTag(favorite.getColor());
}
point.setColor(color);
point.setVisible(favorite.isVisible());
favoritesHelper.addFavourite(point);
return true;
} else {
return false;
}
}
boolean addMapMarker(AMapMarker marker) {
if (marker != null) {
PointDescription pd = new PointDescription(

View file

@ -2,12 +2,11 @@ package net.osmand.aidl;
import android.app.Service;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import net.osmand.aidl.calculateroute.CalculateRouteParams;
import net.osmand.aidl.favorite.AddFavoriteParams;
import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.gpx.HideGpxParams;
import net.osmand.aidl.gpx.ImportGpxParams;
@ -48,6 +47,15 @@ public class OsmandAidlService extends Service {
private final IOsmAndAidlInterface.Stub mBinder = new IOsmAndAidlInterface.Stub() {
@Override
public boolean addFavorite(AddFavoriteParams params) throws RemoteException {
try {
return params != null && getApi().addFavorite(params.getFavorite());
} catch (Exception e) {
return false;
}
}
@Override
public boolean addMapMarker(AddMapMarkerParams params) throws RemoteException {
try {

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.favorite;
parcelable AFavorite;

View file

@ -0,0 +1,96 @@
package net.osmand.aidl.favorite;
import android.os.Parcel;
import android.os.Parcelable;
public class AFavorite implements Parcelable {
private double lat;
private double lon;
private String name;
private String description;
private String category;
private String color;
private boolean visible;
public AFavorite(double lat, double lon, String name, String description,
String category, String color, boolean visible) {
this.lat = lat;
this.lon = lon;
this.name = name;
this.description = description;
this.category = category;
this.color = color;
this.visible = visible;
}
public AFavorite(Parcel in) {
readFromParcel(in);
}
public static final Creator<AFavorite> CREATOR = new Creator<AFavorite>() {
@Override
public AFavorite createFromParcel(Parcel in) {
return new AFavorite(in);
}
@Override
public AFavorite[] newArray(int size) {
return new AFavorite[size];
}
};
public double getLat() {
return lat;
}
public double getLon() {
return lon;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public String getCategory() {
return category;
}
public String getColor() {
return color;
}
public boolean isVisible() {
return visible;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(lat);
out.writeDouble(lon);
out.writeString(name);
out.writeString(description);
out.writeString(category);
out.writeString(color);
out.writeByte((byte) (visible ? 1 : 0));
}
private void readFromParcel(Parcel in) {
lat = in.readDouble();
lon = in.readDouble();
name = in.readString();
description = in.readString();
category = in.readString();
color = in.readString();
visible = in.readByte() != 0;
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.favorite;
parcelable AddFavoriteParams;

View file

@ -0,0 +1,47 @@
package net.osmand.aidl.favorite;
import android.os.Parcel;
import android.os.Parcelable;
public class AddFavoriteParams implements Parcelable {
private AFavorite favorite;
public AddFavoriteParams(AFavorite favorite) {
this.favorite = favorite;
}
public AddFavoriteParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<AddFavoriteParams> CREATOR = new Creator<AddFavoriteParams>() {
@Override
public AddFavoriteParams createFromParcel(Parcel in) {
return new AddFavoriteParams(in);
}
@Override
public AddFavoriteParams[] newArray(int size) {
return new AddFavoriteParams[size];
}
};
public AFavorite getFavorite() {
return favorite;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(favorite, flags);
}
private void readFromParcel(Parcel in) {
favorite = in.readParcelable(AFavorite.class.getClassLoader());
}
@Override
public int describeContents() {
return 0;
}
}