From a32be27bb99f06c581ad1177497b51ff20f3e6c3 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 5 Jul 2017 11:20:42 +0300 Subject: [PATCH 1/5] Add favorite group with aidl --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 7 ++- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 15 +++++ .../net/osmand/aidl/OsmandAidlService.java | 10 +++ .../aidl/favorite/group/AFavoriteGroup.aidl | 3 + .../aidl/favorite/group/AFavoriteGroup.java | 63 +++++++++++++++++++ .../group/AddFavoriteGroupParams.aidl | 3 + .../group/AddFavoriteGroupParams.java | 47 ++++++++++++++ .../net/osmand/plus/FavouritesDbHelper.java | 10 +-- 8 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.java create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.java diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 0a199f58a7..700122e5fd 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -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.group.AFavoriteGroup; +import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; + import net.osmand.aidl.favorite.AFavorite; import net.osmand.aidl.favorite.AddFavoriteParams; import net.osmand.aidl.favorite.RemoveFavoriteParams; @@ -36,6 +39,8 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams; interface IOsmAndAidlInterface { + boolean addFavoriteGroup(in AddFavoriteGroupParams params); + boolean addFavorite(in AddFavoriteParams params); boolean removeFavorite(in RemoveFavoriteParams params); boolean updateFavorite(in UpdateFavoriteParams params); @@ -63,4 +68,4 @@ interface IOsmAndAidlInterface { boolean setMapLocation(in SetMapLocationParams params); boolean calculateRoute(in CalculateRouteParams 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 6d9712f4b9..f14cfa64b0 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -10,6 +10,7 @@ import android.view.View; import net.osmand.IndexConstants; import net.osmand.aidl.favorite.AFavorite; +import net.osmand.aidl.favorite.group.AFavoriteGroup; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.maplayer.AMapLayer; import net.osmand.aidl.maplayer.point.AMapPoint; @@ -349,6 +350,20 @@ public class OsmandAidlApi { return control; } + boolean addFavoriteGroup(AFavoriteGroup favoriteGroup) { + if (favoriteGroup != null) { + FavouritesDbHelper favoritesHelper = app.getFavorites(); + int color = 0; + if (!Algorithms.isEmpty(favoriteGroup.getColor())) { + color = ColorDialogs.getColorByTag(favoriteGroup.getColor()); + } + favoritesHelper.addEmptyCategory(favoriteGroup.getName(), color, favoriteGroup.isVisible()); + return true; + } else { + return false; + } + } + boolean addFavorite(AFavorite favorite) { if (favorite != null) { FavouritesDbHelper favoritesHelper = app.getFavorites(); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 1602c663f3..ffb1f02d15 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -9,6 +9,7 @@ import net.osmand.aidl.calculateroute.CalculateRouteParams; import net.osmand.aidl.favorite.AddFavoriteParams; import net.osmand.aidl.favorite.RemoveFavoriteParams; import net.osmand.aidl.favorite.UpdateFavoriteParams; +import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.gpx.HideGpxParams; import net.osmand.aidl.gpx.ImportGpxParams; @@ -49,6 +50,15 @@ public class OsmandAidlService extends Service { private final IOsmAndAidlInterface.Stub mBinder = new IOsmAndAidlInterface.Stub() { + @Override + public boolean addFavoriteGroup(AddFavoriteGroupParams params) throws RemoteException { + try { + return params != null && getApi().addFavoriteGroup(params.getFavoriteGroup()); + } catch (Exception e) { + return false; + } + } + @Override public boolean addFavorite(AddFavoriteParams params) throws RemoteException { try { diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.aidl b/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.aidl new file mode 100644 index 0000000000..baec925474 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.favorite.group; + +parcelable AFavoriteGroup; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.java b/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.java new file mode 100644 index 0000000000..e9b6348468 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/AFavoriteGroup.java @@ -0,0 +1,63 @@ +package net.osmand.aidl.favorite.group; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AFavoriteGroup implements Parcelable { + + private String name; + private String color; + private boolean visible; + + public AFavoriteGroup(String name, String color, boolean visible) { + this.name = name; + this.color = color; + this.visible = visible; + } + + public AFavoriteGroup(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public AFavoriteGroup createFromParcel(Parcel in) { + return new AFavoriteGroup(in); + } + + @Override + public AFavoriteGroup[] newArray(int size) { + return new AFavoriteGroup[size]; + } + }; + + public String getName() { + return name; + } + + public String getColor() { + return color; + } + + public boolean isVisible() { + return visible; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeString(name); + out.writeString(color); + out.writeByte((byte) (visible ? 1 : 0)); + } + + private void readFromParcel(Parcel in) { + name = in.readString(); + color = in.readString(); + visible = in.readByte() != 0; + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.aidl b/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.aidl new file mode 100644 index 0000000000..5850b5cd34 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.favorite.group; + +parcelable AddFavoriteGroupParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.java b/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.java new file mode 100644 index 0000000000..7cb3228572 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/AddFavoriteGroupParams.java @@ -0,0 +1,47 @@ +package net.osmand.aidl.favorite.group; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AddFavoriteGroupParams implements Parcelable { + + private AFavoriteGroup favoriteGroup; + + public AddFavoriteGroupParams(AFavoriteGroup favoriteGroup) { + this.favoriteGroup = favoriteGroup; + } + + public AddFavoriteGroupParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public AddFavoriteGroupParams createFromParcel(Parcel in) { + return new AddFavoriteGroupParams(in); + } + + @Override + public AddFavoriteGroupParams[] newArray(int size) { + return new AddFavoriteGroupParams[size]; + } + }; + + public AFavoriteGroup getFavoriteGroup() { + return favoriteGroup; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(favoriteGroup, flags); + } + + private void readFromParcel(Parcel in) { + favoriteGroup = in.readParcelable(AFavoriteGroup.class.getClassLoader()); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 2f66e4e478..cc5fdc0c96 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -415,16 +415,18 @@ public class FavouritesDbHelper { public void addEmptyCategory(String name) { - FavoriteGroup group = new FavoriteGroup(); - group.name = name; - favoriteGroups.add(group); - flatGroups.put(name, group); + addEmptyCategory(name, 0, true); } public void addEmptyCategory(String name, int color) { + addEmptyCategory(name, color, true); + } + + public void addEmptyCategory(String name, int color, boolean visible) { FavoriteGroup group = new FavoriteGroup(); group.name = name; group.color = color; + group.visible = visible; favoriteGroups.add(group); flatGroups.put(name, group); } From a89946290b4bad3e5fdbcbf48388a62da2de2cdb Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 5 Jul 2017 12:01:46 +0300 Subject: [PATCH 2/5] Remove favorite group with aidl --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 2 + OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 16 +++++++ .../net/osmand/aidl/OsmandAidlService.java | 10 ++++ .../group/RemoveFavoriteGroupParams.aidl | 3 ++ .../group/RemoveFavoriteGroupParams.java | 47 +++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.java diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 700122e5fd..8d72b17565 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -5,6 +5,7 @@ import net.osmand.aidl.map.SetMapLocationParams; import net.osmand.aidl.favorite.group.AFavoriteGroup; import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; +import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams; import net.osmand.aidl.favorite.AFavorite; import net.osmand.aidl.favorite.AddFavoriteParams; @@ -40,6 +41,7 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams; interface IOsmAndAidlInterface { boolean addFavoriteGroup(in AddFavoriteGroupParams params); + boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params); boolean addFavorite(in AddFavoriteParams params); boolean removeFavorite(in RemoveFavoriteParams params); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index f14cfa64b0..13b192a418 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -364,6 +364,22 @@ public class OsmandAidlApi { } } + boolean removeFavoriteGroup(AFavoriteGroup favoriteGroup) { + if (favoriteGroup != null) { + FavouritesDbHelper favoritesHelper = app.getFavorites(); + List groups = favoritesHelper.getFavoriteGroups(); + for (FavouritesDbHelper.FavoriteGroup g : groups) { + if (g.name.equals(favoriteGroup.getName())) { + favoritesHelper.deleteGroup(g); + return true; + } + } + return false; + } else { + return false; + } + } + boolean addFavorite(AFavorite favorite) { if (favorite != null) { FavouritesDbHelper favoritesHelper = app.getFavorites(); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index ffb1f02d15..2f9db6c7b2 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -10,6 +10,7 @@ import net.osmand.aidl.favorite.AddFavoriteParams; import net.osmand.aidl.favorite.RemoveFavoriteParams; import net.osmand.aidl.favorite.UpdateFavoriteParams; import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; +import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.gpx.HideGpxParams; import net.osmand.aidl.gpx.ImportGpxParams; @@ -59,6 +60,15 @@ public class OsmandAidlService extends Service { } } + @Override + public boolean removeFavoriteGroup(RemoveFavoriteGroupParams params) throws RemoteException { + try { + return params != null && getApi().removeFavoriteGroup(params.getFavoriteGroup()); + } catch (Exception e) { + return false; + } + } + @Override public boolean addFavorite(AddFavoriteParams params) throws RemoteException { try { diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.aidl b/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.aidl new file mode 100644 index 0000000000..e8b0710a01 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.favorite.group; + +parcelable RemoveFavoriteGroupParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.java b/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.java new file mode 100644 index 0000000000..0b17274440 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/RemoveFavoriteGroupParams.java @@ -0,0 +1,47 @@ +package net.osmand.aidl.favorite.group; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveFavoriteGroupParams implements Parcelable { + + private AFavoriteGroup favoriteGroup; + + public RemoveFavoriteGroupParams(AFavoriteGroup favoriteGroup) { + this.favoriteGroup = favoriteGroup; + } + + public RemoveFavoriteGroupParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public RemoveFavoriteGroupParams createFromParcel(Parcel in) { + return new RemoveFavoriteGroupParams(in); + } + + @Override + public RemoveFavoriteGroupParams[] newArray(int size) { + return new RemoveFavoriteGroupParams[size]; + } + }; + + public AFavoriteGroup getFavoriteGroup() { + return favoriteGroup; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(favoriteGroup, flags); + } + + private void readFromParcel(Parcel in) { + favoriteGroup = in.readParcelable(AFavoriteGroup.class.getClassLoader()); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file From 760e218475c8487b097faf36231e2658e70c7e7e Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 5 Jul 2017 12:47:09 +0300 Subject: [PATCH 3/5] Update favorite group with aidl --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 2 + OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 20 +++++++ .../net/osmand/aidl/OsmandAidlService.java | 10 ++++ .../group/UpdateFavoriteGroupParams.aidl | 3 + .../group/UpdateFavoriteGroupParams.java | 55 +++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.java diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 8d72b17565..9529a1933b 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -6,6 +6,7 @@ import net.osmand.aidl.map.SetMapLocationParams; import net.osmand.aidl.favorite.group.AFavoriteGroup; import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams; +import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams; import net.osmand.aidl.favorite.AFavorite; import net.osmand.aidl.favorite.AddFavoriteParams; @@ -42,6 +43,7 @@ interface IOsmAndAidlInterface { boolean addFavoriteGroup(in AddFavoriteGroupParams params); boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params); + boolean updateFavoriteGroup(in UpdateFavoriteGroupParams params); boolean addFavorite(in AddFavoriteParams params); boolean removeFavorite(in RemoveFavoriteParams params); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 13b192a418..3e9f04c328 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -380,6 +380,26 @@ public class OsmandAidlApi { } } + boolean updateFavoriteGroup(AFavoriteGroup gPrev, AFavoriteGroup gNew) { + if (gPrev != null && gNew != null) { + FavouritesDbHelper favoritesHelper = app.getFavorites(); + List groups = favoritesHelper.getFavoriteGroups(); + for (FavouritesDbHelper.FavoriteGroup g : groups) { + if (g.name.equals(gPrev.getName())) { + int color = 0; + if (!Algorithms.isEmpty(gNew.getColor())) { + color = ColorDialogs.getColorByTag(gNew.getColor()); + } + favoritesHelper.editFavouriteGroup(g, gNew.getName(), color, gNew.isVisible()); + return true; + } + } + return false; + } else { + return false; + } + } + boolean addFavorite(AFavorite favorite) { if (favorite != null) { FavouritesDbHelper favoritesHelper = app.getFavorites(); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 2f9db6c7b2..512e9165f3 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -11,6 +11,7 @@ import net.osmand.aidl.favorite.RemoveFavoriteParams; import net.osmand.aidl.favorite.UpdateFavoriteParams; import net.osmand.aidl.favorite.group.AddFavoriteGroupParams; import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams; +import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.gpx.HideGpxParams; import net.osmand.aidl.gpx.ImportGpxParams; @@ -69,6 +70,15 @@ public class OsmandAidlService extends Service { } } + @Override + public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) throws RemoteException { + try { + return params != null && getApi().updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew()); + } catch (Exception e) { + return false; + } + } + @Override public boolean addFavorite(AddFavoriteParams params) throws RemoteException { try { diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.aidl b/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.aidl new file mode 100644 index 0000000000..e9001a8c5e --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.favorite.group; + +parcelable UpdateFavoriteGroupParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.java b/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.java new file mode 100644 index 0000000000..0ea52e1fda --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/favorite/group/UpdateFavoriteGroupParams.java @@ -0,0 +1,55 @@ +package net.osmand.aidl.favorite.group; + +import android.os.Parcel; +import android.os.Parcelable; + +public class UpdateFavoriteGroupParams implements Parcelable { + + private AFavoriteGroup favoriteGroupPrev; + private AFavoriteGroup favoriteGroupNew; + + public UpdateFavoriteGroupParams(AFavoriteGroup favoriteGroup, AFavoriteGroup favoriteGroupNew) { + this.favoriteGroupPrev = favoriteGroup; + this.favoriteGroupNew = favoriteGroupNew; + } + + public UpdateFavoriteGroupParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public UpdateFavoriteGroupParams createFromParcel(Parcel in) { + return new UpdateFavoriteGroupParams(in); + } + + @Override + public UpdateFavoriteGroupParams[] newArray(int size) { + return new UpdateFavoriteGroupParams[size]; + } + }; + + public AFavoriteGroup getFavoriteGroupPrev() { + return favoriteGroupPrev; + } + + public AFavoriteGroup getFavoriteGroupNew() { + return favoriteGroupNew; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(favoriteGroupPrev, flags); + out.writeParcelable(favoriteGroupNew, flags); + } + + private void readFromParcel(Parcel in) { + favoriteGroupPrev = in.readParcelable(AFavoriteGroup.class.getClassLoader()); + favoriteGroupNew = in.readParcelable(AFavoriteGroup.class.getClassLoader()); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file From 6cd6e7ea63ecf2420a3257544da894173ef762da Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 5 Jul 2017 15:46:53 +0300 Subject: [PATCH 4/5] Refresh map with aidl --- OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl | 2 ++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 5 +++++ OsmAnd/src/net/osmand/aidl/OsmandAidlService.java | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 9529a1933b..adfccdbdf1 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -41,6 +41,8 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams; interface IOsmAndAidlInterface { + boolean refreshMap(); + boolean addFavoriteGroup(in AddFavoriteGroupParams params); boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params); boolean updateFavoriteGroup(in UpdateFavoriteGroupParams params); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 3e9f04c328..02b1e1e30b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -350,6 +350,11 @@ public class OsmandAidlApi { return control; } + boolean reloadMap() { + refreshMap(); + return true; + } + boolean addFavoriteGroup(AFavoriteGroup favoriteGroup) { if (favoriteGroup != null) { FavouritesDbHelper favoritesHelper = app.getFavorites(); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 512e9165f3..2a40acb86a 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -52,6 +52,15 @@ public class OsmandAidlService extends Service { private final IOsmAndAidlInterface.Stub mBinder = new IOsmAndAidlInterface.Stub() { + @Override + public boolean refreshMap() throws RemoteException { + try { + return getApi().reloadMap(); + } catch (Exception e) { + return false; + } + } + @Override public boolean addFavoriteGroup(AddFavoriteGroupParams params) throws RemoteException { try { From f6aeaed8d15658e880876b972b0163d635ba43b3 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 5 Jul 2017 18:55:15 +0300 Subject: [PATCH 5/5] Remove the ability to add groups with the same name --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 02b1e1e30b..351e511ea5 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -358,6 +358,12 @@ public class OsmandAidlApi { boolean addFavoriteGroup(AFavoriteGroup favoriteGroup) { if (favoriteGroup != null) { FavouritesDbHelper favoritesHelper = app.getFavorites(); + List groups = favoritesHelper.getFavoriteGroups(); + for (FavouritesDbHelper.FavoriteGroup g : groups) { + if (g.name.equals(favoriteGroup.getName())) { + return false; + } + } int color = 0; if (!Algorithms.isEmpty(favoriteGroup.getColor())) { color = ColorDialogs.getColorByTag(favoriteGroup.getColor());