Add aidl service for support v2 api

This commit is contained in:
Chumva 2019-10-10 12:50:44 +03:00
parent 4b59c038f7
commit 63eca2c6a2
19 changed files with 2540 additions and 552 deletions

View file

@ -867,6 +867,13 @@
</intent-filter>
</service>
<service android:name="net.osmand.aidl.OsmandAidlServiceV2" android:exported="true" >
<intent-filter>
<action android:name="net.osmand.aidl.OsmandAidlServiceV2"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
<service
android:name="net.osmand.plus.download.DownloadService"
android:label="@string/process_downloading_service"

View file

@ -0,0 +1,36 @@
package net.osmand.aidl;
import net.osmand.aidl2.IOsmAndAidlCallback;
import java.util.Map;
public interface AidlCallbackListenerV2 {
/**
* Add AidlCallbackListener to OsmandAidlService's map of listeners. Key is unique to each AIDL
* method that wants to register callback and used to access only "own" callbacks.
*
* @param callback
* @param key - every AIDL method which uses that register callbacks in service need to use its own bit key
* 1 - key for registerForUpdates(...)
* 2 - key for registerForNavigationUpdates(...)
* 4 - key for onContextMenuButtonClicked(...)
* 8 - key for... future use
* 16 - key for... future use
* @return long - unique id of callback. Could be used for unregistering callback
*/
long addAidlCallback(IOsmAndAidlCallback callback, int key);
/**
* Unregister AidlCallbackListener from OsmandAidlService's map
*
* @param id - unique id of callback
* @return - true if callback successfully unregistered
*/
boolean removeAidlCallback(long id);
/**
* @return map of all callbacks. AidlCallbackParams contains method key and callback.
*/
Map<Long, OsmandAidlServiceV2.AidlCallbackParams> getAidlCallbacks();
}

View file

@ -0,0 +1,64 @@
package net.osmand.aidl;
import net.osmand.aidl.contextmenu.AContextMenuButton;
public class AidlContextMenuButtonWrapper {
private int buttonId;
private String leftTextCaption;
private String rightTextCaption;
private String leftIconName;
private String rightIconName;
private boolean needColorizeIcon;
private boolean enabled;
public AidlContextMenuButtonWrapper(AContextMenuButton aContextMenuButton) {
buttonId = aContextMenuButton.getButtonId();
leftTextCaption = aContextMenuButton.getLeftTextCaption();
rightTextCaption = aContextMenuButton.getRightTextCaption();
leftIconName = aContextMenuButton.getLeftIconName();
rightIconName = aContextMenuButton.getRightIconName();
needColorizeIcon = aContextMenuButton.isTintIcon();
enabled = aContextMenuButton.isEnabled();
}
public AidlContextMenuButtonWrapper(net.osmand.aidl2.contextmenu.AContextMenuButton aContextMenuButton) {
buttonId = aContextMenuButton.getButtonId();
leftTextCaption = aContextMenuButton.getLeftTextCaption();
rightTextCaption = aContextMenuButton.getRightTextCaption();
leftIconName = aContextMenuButton.getLeftIconName();
rightIconName = aContextMenuButton.getRightIconName();
needColorizeIcon = aContextMenuButton.isTintIcon();
enabled = aContextMenuButton.isEnabled();
}
public int getButtonId() {
return buttonId;
}
public String getLeftTextCaption() {
return leftTextCaption;
}
public String getRightTextCaption() {
return rightTextCaption;
}
public String getLeftIconName() {
return leftIconName;
}
public String getRightIconName() {
return rightIconName;
}
public boolean isTintIcon() {
return needColorizeIcon;
}
public boolean isEnabled() {
return enabled;
}
}

View file

@ -0,0 +1,86 @@
package net.osmand.aidl;
import net.osmand.aidl.contextmenu.AContextMenuButton;
import net.osmand.aidl.contextmenu.ContextMenuButtonsParams;
import java.util.List;
public class AidlContextMenuButtonsWrapper {
private AidlContextMenuButtonWrapper leftButton;
private AidlContextMenuButtonWrapper rightButton;
private String id;
private String appPackage;
private String layerId;
private long callbackId;
private List<String> pointsIds;
public AidlContextMenuButtonsWrapper(ContextMenuButtonsParams params) {
id = params.getId();
appPackage = params.getAppPackage();
layerId = params.getLayerId();
callbackId = params.getCallbackId();
pointsIds = params.getPointsIds();
AContextMenuButton leftButton = params.getLeftButton();
AContextMenuButton rightButton = params.getRightButton();
if (leftButton != null) {
this.leftButton = new AidlContextMenuButtonWrapper(leftButton);
}
if (rightButton != null) {
this.rightButton = new AidlContextMenuButtonWrapper(rightButton);
}
}
public AidlContextMenuButtonsWrapper(net.osmand.aidl2.contextmenu.ContextMenuButtonsParams params) {
id = params.getId();
appPackage = params.getAppPackage();
layerId = params.getLayerId();
callbackId = params.getCallbackId();
pointsIds = params.getPointsIds();
net.osmand.aidl2.contextmenu.AContextMenuButton leftButton = params.getLeftButton();
net.osmand.aidl2.contextmenu.AContextMenuButton rightButton = params.getRightButton();
if (leftButton != null) {
this.leftButton = new AidlContextMenuButtonWrapper(leftButton);
}
if (rightButton != null) {
this.leftButton = new AidlContextMenuButtonWrapper(rightButton);
}
}
public AidlContextMenuButtonWrapper getLeftButton() {
return leftButton;
}
public AidlContextMenuButtonWrapper getRightButton() {
return rightButton;
}
public String getId() {
return id;
}
public String getAppPackage() {
return appPackage;
}
public String getLayerId() {
return layerId;
}
public long getCallbackId() {
return callbackId;
}
public void setCallbackId(long callbackId) {
this.callbackId = callbackId;
}
public List<String> getPointsIds() {
return pointsIds;
}
}

View file

@ -0,0 +1,153 @@
package net.osmand.aidl;
import net.osmand.aidl.maplayer.AMapLayer;
import net.osmand.aidl.maplayer.point.AMapPoint;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class AidlMapLayerWrapper {
private String id;
private String name;
private float zOrder;
private Map<String, AidlMapPointWrapper> points = new ConcurrentHashMap<>();
private boolean imagePoints;
private int circlePointMinZoom;
private int circlePointMaxZoom;
private int smallPointMinZoom;
private int smallPointMaxZoom;
private int bigPointMinZoom;
private int bigPointMaxZoom;
public AidlMapLayerWrapper(AMapLayer aMapLayer) {
id = aMapLayer.getId();
name = aMapLayer.getName();
zOrder = aMapLayer.getZOrder();
imagePoints = aMapLayer.isImagePoints();
circlePointMinZoom = aMapLayer.getCirclePointMinZoom();
circlePointMaxZoom = aMapLayer.getCirclePointMaxZoom();
smallPointMinZoom = aMapLayer.getSmallPointMinZoom();
smallPointMaxZoom = aMapLayer.getSmallPointMaxZoom();
bigPointMinZoom = aMapLayer.getBigPointMinZoom();
bigPointMaxZoom = aMapLayer.getBigPointMaxZoom();
List<AMapPoint> pointList = aMapLayer.getPoints();
if (pointList != null) {
for (AMapPoint p : pointList) {
this.points.put(p.getId(), new AidlMapPointWrapper(p));
}
}
}
public AidlMapLayerWrapper(net.osmand.aidl2.maplayer.AMapLayer aMapLayer) {
id = aMapLayer.getId();
name = aMapLayer.getName();
zOrder = aMapLayer.getZOrder();
imagePoints = aMapLayer.isImagePoints();
circlePointMinZoom = aMapLayer.getCirclePointMinZoom();
circlePointMaxZoom = aMapLayer.getCirclePointMaxZoom();
smallPointMinZoom = aMapLayer.getSmallPointMinZoom();
smallPointMaxZoom = aMapLayer.getSmallPointMaxZoom();
bigPointMinZoom = aMapLayer.getBigPointMinZoom();
bigPointMaxZoom = aMapLayer.getBigPointMaxZoom();
List<net.osmand.aidl2.maplayer.point.AMapPoint> pointList = aMapLayer.getPoints();
if (pointList != null) {
for (net.osmand.aidl2.maplayer.point.AMapPoint p : pointList) {
this.points.put(p.getId(), new AidlMapPointWrapper(p));
}
}
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public float getZOrder() {
return zOrder;
}
public List<AidlMapPointWrapper> getPoints() {
return new ArrayList<>(points.values());
}
public AidlMapPointWrapper getPoint(String pointId) {
return points.get(pointId);
}
public boolean hasPoint(String pointId) {
return points.containsKey(pointId);
}
public void putPoint(AidlMapPointWrapper point) {
points.put(point.getId(), point);
}
public void removePoint(String pointId) {
points.remove(pointId);
}
public boolean isImagePoints() {
return imagePoints;
}
public void setImagePoints(boolean imagePoints) {
this.imagePoints = imagePoints;
}
public void copyZoomBounds(AidlMapLayerWrapper layer) {
circlePointMinZoom = layer.circlePointMinZoom;
circlePointMaxZoom = layer.circlePointMaxZoom;
smallPointMinZoom = layer.smallPointMinZoom;
smallPointMaxZoom = layer.smallPointMaxZoom;
bigPointMinZoom = layer.bigPointMinZoom;
bigPointMaxZoom = layer.bigPointMaxZoom;
}
public void setCirclePointZoomBounds(int min, int max) {
circlePointMinZoom = min;
circlePointMaxZoom = max;
}
public void setSmallPointZoomBounds(int min, int max) {
smallPointMinZoom = min;
smallPointMaxZoom = max;
}
public void setBigPointZoomBounds(int min, int max) {
bigPointMinZoom = min;
bigPointMaxZoom = max;
}
public int getCirclePointMinZoom() {
return circlePointMinZoom;
}
public int getCirclePointMaxZoom() {
return circlePointMaxZoom;
}
public int getSmallPointMinZoom() {
return smallPointMinZoom;
}
public int getSmallPointMaxZoom() {
return smallPointMaxZoom;
}
public int getBigPointMinZoom() {
return bigPointMinZoom;
}
public int getBigPointMaxZoom() {
return bigPointMaxZoom;
}
}

View file

@ -0,0 +1,85 @@
package net.osmand.aidl;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.data.LatLon;
import java.util.List;
import java.util.Map;
public class AidlMapPointWrapper {
private String id;
private String shortName;
private String fullName;
private String typeName;
private String layerId;
private int color;
private LatLon location;
private List<String> details;
private Map<String, String> params;
public AidlMapPointWrapper(AMapPoint aMapPoint) {
id = aMapPoint.getId();
shortName = aMapPoint.getShortName();
fullName = aMapPoint.getFullName();
typeName = aMapPoint.getTypeName();
layerId = aMapPoint.getLayerId();
color = aMapPoint.getColor();
ALatLon aLatLon = aMapPoint.getLocation();
location = new LatLon(aLatLon.getLatitude(), aLatLon.getLongitude());
details = aMapPoint.getDetails();
params = aMapPoint.getParams();
}
public AidlMapPointWrapper(net.osmand.aidl2.maplayer.point.AMapPoint aMapPoint) {
id = aMapPoint.getId();
shortName = aMapPoint.getShortName();
fullName = aMapPoint.getFullName();
typeName = aMapPoint.getTypeName();
layerId = aMapPoint.getLayerId();
color = aMapPoint.getColor();
net.osmand.aidl2.map.ALatLon aLatLon = aMapPoint.getLocation();
location = new LatLon(aLatLon.getLatitude(), aLatLon.getLongitude());
details = aMapPoint.getDetails();
params = aMapPoint.getParams();
}
public String getId() {
return id;
}
public String getShortName() {
return shortName;
}
public String getFullName() {
return fullName;
}
public String getTypeName() {
return typeName;
}
public String getLayerId() {
return layerId;
}
public int getColor() {
return color;
}
public LatLon getLocation() {
return location;
}
public List<String> getDetails() {
return details;
}
public Map<String, String> getParams() {
return params;
}
}

View file

@ -0,0 +1,78 @@
package net.osmand.aidl;
import android.content.Intent;
import net.osmand.aidl.mapwidget.AMapWidget;
public class AidlMapWidgetWrapper {
private String id;
private String menuIconName;
private String menuTitle;
private String lightIconName;
private String darkIconName;
private String text;
private String description;
private int order;
private Intent intentOnClick;
public AidlMapWidgetWrapper(AMapWidget aMapWidget) {
this.id = aMapWidget.getId();
this.menuIconName = aMapWidget.getMenuIconName();
this.menuTitle = aMapWidget.getMenuTitle();
this.lightIconName = aMapWidget.getLightIconName();
this.darkIconName = aMapWidget.getDarkIconName();
this.text = aMapWidget.getText();
this.description = aMapWidget.getDescription();
this.order = aMapWidget.getOrder();
this.intentOnClick = aMapWidget.getIntentOnClick();
}
public AidlMapWidgetWrapper(net.osmand.aidl2.mapwidget.AMapWidget aMapWidget) {
this.id = aMapWidget.getId();
this.menuIconName = aMapWidget.getMenuIconName();
this.menuTitle = aMapWidget.getMenuTitle();
this.lightIconName = aMapWidget.getLightIconName();
this.darkIconName = aMapWidget.getDarkIconName();
this.text = aMapWidget.getText();
this.description = aMapWidget.getDescription();
this.order = aMapWidget.getOrder();
this.intentOnClick = aMapWidget.getIntentOnClick();
}
public String getId() {
return id;
}
public String getMenuIconName() {
return menuIconName;
}
public String getMenuTitle() {
return menuTitle;
}
public String getLightIconName() {
return lightIconName;
}
public String getDarkIconName() {
return darkIconName;
}
public String getText() {
return text;
}
public String getDescription() {
return description;
}
public int getOrder() {
return order;
}
public Intent getIntentOnClick() {
return intentOnClick;
}
}

View file

@ -0,0 +1,52 @@
package net.osmand.aidl;
import java.util.ArrayList;
import java.util.List;
public class AidlSearchResultWrapper {
private double latitude;
private double longitude;
private String localName;
private String localTypeName;
private String alternateName;
private List<String> otherNames = new ArrayList<>();
public AidlSearchResultWrapper(double latitude, double longitude, String localName, String localTypeName,
String alternateName, List<String> otherNames) {
this.latitude = latitude;
this.longitude = longitude;
this.localName = localName;
this.localTypeName = localTypeName;
this.alternateName = alternateName;
if (otherNames != null) {
this.otherNames.addAll(otherNames);
}
}
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public String getLocalName() {
return localName;
}
public String getLocalTypeName() {
return localTypeName;
}
public String getAlternateName() {
return alternateName;
}
public List<String> getOtherNames() {
return otherNames;
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,8 +2,8 @@ package net.osmand.aidl;
import android.app.Service;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@ -23,9 +23,11 @@ import net.osmand.aidl.customization.CustomizationInfoParams;
import net.osmand.aidl.customization.OsmandSettingsInfoParams;
import net.osmand.aidl.customization.OsmandSettingsParams;
import net.osmand.aidl.customization.SetWidgetsParams;
import net.osmand.aidl.favorite.AFavorite;
import net.osmand.aidl.favorite.AddFavoriteParams;
import net.osmand.aidl.favorite.RemoveFavoriteParams;
import net.osmand.aidl.favorite.UpdateFavoriteParams;
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;
@ -40,6 +42,7 @@ import net.osmand.aidl.gpx.RemoveGpxParams;
import net.osmand.aidl.gpx.ShowGpxParams;
import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.map.SetMapLocationParams;
import net.osmand.aidl.maplayer.AddMapLayerParams;
import net.osmand.aidl.maplayer.RemoveMapLayerParams;
@ -48,6 +51,7 @@ 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.AMapMarker;
import net.osmand.aidl.mapmarker.AddMapMarkerParams;
import net.osmand.aidl.mapmarker.RemoveMapMarkerParams;
import net.osmand.aidl.mapmarker.RemoveMapMarkersParams;
@ -57,6 +61,7 @@ import net.osmand.aidl.mapwidget.RemoveMapWidgetParams;
import net.osmand.aidl.mapwidget.UpdateMapWidgetParams;
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
import net.osmand.aidl.navdrawer.NavDrawerHeaderParams;
import net.osmand.aidl.navdrawer.NavDrawerItem;
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
import net.osmand.aidl.navigation.ANavigationUpdateParams;
import net.osmand.aidl.navigation.ANavigationVoiceRouterMessageParams;
@ -76,6 +81,8 @@ import net.osmand.aidl.plugins.PluginParams;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.aidl.tiles.ASqliteDbFile;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.util.Algorithms;
@ -96,8 +103,6 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
private static final String DATA_KEY_RESULT_SET = "resultSet";
public static final int KEY_ON_UPDATE = 1;
public static final int KEY_ON_NAV_DATA_UPDATE = 2;
public static final int KEY_ON_CONTEXT_MENU_BUTTONS_CLICK = 4;
@ -207,7 +212,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addFavoriteGroup(AddFavoriteGroupParams params) {
try {
OsmandAidlApi api = getApi("addFavoriteGroup");
return params != null && api != null && api.addFavoriteGroup(params.getFavoriteGroup());
if (params != null && api != null) {
AFavoriteGroup favoriteGroup = params.getFavoriteGroup();
if (favoriteGroup != null) {
return api.addFavoriteGroup(favoriteGroup.getName(), favoriteGroup.getColor(), favoriteGroup.isVisible());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -218,7 +229,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean removeFavoriteGroup(RemoveFavoriteGroupParams params) {
try {
OsmandAidlApi api = getApi("removeFavoriteGroup");
return params != null && api != null && api.removeFavoriteGroup(params.getFavoriteGroup());
if (params != null && api != null) {
AFavoriteGroup favoriteGroup = params.getFavoriteGroup();
if (favoriteGroup != null) {
return api.removeFavoriteGroup(favoriteGroup.getName());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -229,7 +246,14 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) {
try {
OsmandAidlApi api = getApi("updateFavoriteGroup");
return params != null && api != null && api.updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew());
if (params != null && api != null) {
AFavoriteGroup prevGroup = params.getFavoriteGroupPrev();
AFavoriteGroup newGroup = params.getFavoriteGroupNew();
if (prevGroup != null && newGroup != null) {
return api.updateFavoriteGroup(prevGroup.getName(), newGroup.getName(), newGroup.getColor(), newGroup.isVisible());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -240,7 +264,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addFavorite(AddFavoriteParams params) {
try {
OsmandAidlApi api = getApi("addFavorite");
return params != null && api != null && api.addFavorite(params.getFavorite());
if (params != null && api != null) {
AFavorite fav = params.getFavorite();
if (fav != null) {
return api.addFavorite(fav.getLat(), fav.getLon(), fav.getName(), fav.getCategory(), fav.getDescription(), fav.getColor(), fav.isVisible());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -251,7 +281,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean removeFavorite(RemoveFavoriteParams params) {
try {
OsmandAidlApi api = getApi("removeFavorite");
return params != null && api != null && api.removeFavorite(params.getFavorite());
if (params != null && api != null) {
AFavorite fav = params.getFavorite();
if (fav != null) {
return api.removeFavorite(fav.getName(), fav.getCategory(), fav.getLat(), fav.getLon());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -262,7 +298,15 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateFavorite(UpdateFavoriteParams params) {
try {
OsmandAidlApi api = getApi("updateFavorite");
return params != null && api != null && api.updateFavorite(params.getFavoritePrev(), params.getFavoriteNew());
if (params != null && api != null) {
AFavorite prevFav = params.getFavoritePrev();
AFavorite newFav = params.getFavoriteNew();
if (prevFav != null && newFav != null) {
return api.updateFavorite(prevFav.getName(), prevFav.getCategory(), prevFav.getLat(), prevFav.getLon(),
newFav.getName(), newFav.getCategory(), newFav.getDescription(), newFav.getLat(), newFav.getLon());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -273,7 +317,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addMapMarker(AddMapMarkerParams params) {
try {
OsmandAidlApi api = getApi("addMapMarker");
return params != null && api != null && api.addMapMarker(params.getMarker());
if (params != null && api != null) {
AMapMarker mapMarker = params.getMarker();
if (mapMarker != null) {
return api.addMapMarker(mapMarker.getName(), mapMarker.getLatLon().getLatitude(), mapMarker.getLatLon().getLongitude());
}
}
return false;
} catch (Exception e) {
return false;
}
@ -283,7 +333,14 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean removeMapMarker(RemoveMapMarkerParams params) {
try {
OsmandAidlApi api = getApi("removeMapMarker");
return params != null && api != null && api.removeMapMarker(params.getMarker(), params.getIgnoreCoordinates());
if (params != null && api != null) {
AMapMarker mapMarker = params.getMarker();
if (mapMarker != null) {
ALatLon aLatLon = mapMarker.getLatLon();
return api.removeMapMarker(mapMarker.getName(), aLatLon.getLatitude(), aLatLon.getLongitude(), params.getIgnoreCoordinates());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -294,7 +351,19 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateMapMarker(UpdateMapMarkerParams params) {
try {
OsmandAidlApi api = getApi("updateMapMarker");
return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew(), params.getIgnoreCoordinates());
if (params != null && api != null) {
AMapMarker markerPrev = params.getMarkerPrev();
AMapMarker markerNew = params.getMarkerNew();
if (markerPrev != null && markerNew != null) {
ALatLon aLatLonPrev = markerPrev.getLatLon();
ALatLon aLatLonNew = markerNew.getLatLon();
LatLon prevLatLon = new LatLon(aLatLonPrev.getLatitude(), aLatLonPrev.getLongitude());
LatLon newLatLon = new LatLon(aLatLonNew.getLatitude(), aLatLonNew.getLongitude());
return api.updateMapMarker(markerPrev.getName(), prevLatLon, markerNew.getName(), newLatLon, params.getIgnoreCoordinates());
}
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -305,7 +374,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addMapWidget(AddMapWidgetParams params) {
try {
OsmandAidlApi api = getApi("addMapWidget");
return params != null && api != null && api.addMapWidget(params.getWidget());
return params != null && api != null && api.addMapWidget(new AidlMapWidgetWrapper(params.getWidget()));
} catch (Exception e) {
handleException(e);
return false;
@ -326,7 +395,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateMapWidget(UpdateMapWidgetParams params) {
try {
OsmandAidlApi api = getApi("updateMapWidget");
return params != null && api != null && api.updateMapWidget(params.getWidget());
return params != null && api != null && api.updateMapWidget(new AidlMapWidgetWrapper(params.getWidget()));
} catch (Exception e) {
handleException(e);
return false;
@ -337,7 +406,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean showMapPoint(ShowMapPointParams params) {
try {
OsmandAidlApi api = getApi("showMapPoint");
return params != null && api != null && api.showMapPoint(params.getLayerId(), params.getPoint());
return params != null && api != null && api.showMapPoint(params.getLayerId(), new AidlMapPointWrapper(params.getPoint()));
} catch (Exception e) {
handleException(e);
return false;
@ -348,7 +417,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addMapPoint(AddMapPointParams params) {
try {
OsmandAidlApi api = getApi("addMapPoint");
return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint());
return params != null && api != null && api.putMapPoint(params.getLayerId(), new AidlMapPointWrapper(params.getPoint()));
} catch (Exception e) {
handleException(e);
return false;
@ -370,7 +439,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateMapPoint(UpdateMapPointParams params) {
try {
OsmandAidlApi api = getApi("updateMapPoint");
return params != null && api != null && api.updateMapPoint(params.getLayerId(), params.getPoint(), params.isUpdateOpenedMenuAndMap());
return params != null && api != null && api.updateMapPoint(params.getLayerId(), new AidlMapPointWrapper(params.getPoint()), params.isUpdateOpenedMenuAndMap());
} catch (Exception e) {
handleException(e);
return false;
@ -381,7 +450,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean addMapLayer(AddMapLayerParams params) {
try {
OsmandAidlApi api = getApi("addMapLayer");
return params != null && api != null && api.addMapLayer(params.getLayer());
return params != null && api != null && api.addMapLayer(new AidlMapLayerWrapper(params.getLayer()));
} catch (Exception e) {
handleException(e);
return false;
@ -403,7 +472,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean updateMapLayer(UpdateMapLayerParams params) {
try {
OsmandAidlApi api = getApi("updateMapLayer");
return params != null && api != null && api.updateMapLayer(params.getLayer());
return params != null && api != null && api.updateMapLayer(new AidlMapLayerWrapper(params.getLayer()));
} catch (Exception e) {
handleException(e);
return false;
@ -467,7 +536,10 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean getActiveGpx(List<ASelectedGpxFile> files) {
try {
OsmandAidlApi api = getApi("getActiveGpx");
return api != null && api.getActiveGpx(files);
if (api != null && files != null) {
return api.getActiveGpx(files);
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -478,7 +550,10 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean getImportedGpx(List<AGpxFile> files) {
try {
OsmandAidlApi api = getApi("getImportedGpx");
return api != null && api.getImportedGpx(files);
if (api != null && files != null) {
return api.getImportedGpx(files);
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -574,7 +649,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean startGpxRecording(StartGpxRecordingParams params) {
try {
OsmandAidlApi api = getApi("startGpxRecording");
return api != null && api.startGpxRecording(params);
return api != null && api.startGpxRecording();
} catch (Exception e) {
handleException(e);
return false;
@ -585,7 +660,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean stopGpxRecording(StopGpxRecordingParams params) {
try {
OsmandAidlApi api = getApi("stopGpxRecording");
return api != null && api.stopGpxRecording(params);
return api != null && api.stopGpxRecording();
} catch (Exception e) {
handleException(e);
return false;
@ -720,7 +795,10 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean setNavDrawerItems(SetNavDrawerItemsParams params) {
try {
OsmandAidlApi api = getApi("setNavDrawerItems");
return params != null && api != null && api.setNavDrawerItems(params.getAppPackage(), params.getItems());
if (api != null && params != null) {
return api.setNavDrawerItems(params.getAppPackage(), convertNavDrawerItems(params.getItems()));
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -734,13 +812,15 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
return params != null && api != null && api.search(params.getSearchQuery(), params.getSearchType(),
params.getLatitude(), params.getLongitude(), params.getRadiusLevel(), params.getTotalLimit(), new SearchCompleteCallback() {
@Override
public void onSearchComplete(List<SearchResult> resultSet) {
Bundle data = new Bundle();
if (resultSet.size() > 0) {
data.putParcelableArrayList(DATA_KEY_RESULT_SET, new ArrayList<>(resultSet));
}
public void onSearchComplete(List<AidlSearchResultWrapper> resultSet) {
try {
callback.onSearchComplete(resultSet);
List<SearchResult> searchResults = new ArrayList<>();
for (AidlSearchResultWrapper item : resultSet) {
SearchResult result = new SearchResult(item.getLatitude(), item.getLongitude(), item.getLocalName(),
item.getLocalTypeName(), item.getAlternateName(), item.getOtherNames());
searchResults.add(result);
}
callback.onSearchComplete(searchResults);
} catch (RemoteException e) {
handleException(e);
}
@ -963,7 +1043,8 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean setNavDrawerFooterWithParams(NavDrawerFooterParams params) {
try {
OsmandAidlApi api = getApi("setNavDrawerFooterParams");
return api != null && api.setNavDrawerFooterWithParams(params);
return api != null && api.setNavDrawerFooterWithParams(
params.getAppName(), params.getPackageName(), params.getIntent());
} catch (Exception e) {
handleException(e);
return false;
@ -985,7 +1066,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean changePluginState(PluginParams params) {
try {
OsmandAidlApi api = getApi("changePluginState");
return api != null && api.changePluginState(params);
return api != null && api.changePluginState(params.getPluginId(), params.getNewState());
} catch (Exception e) {
handleException(e);
return false;
@ -1018,9 +1099,9 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
OsmandAidlApi api = getApi("getBitmapForGpx");
return params != null && api != null && api.getBitmapForGpx(params.getGpxUri(), params.getDensity(), params.getWidthPixels(), params.getHeightPixels(), params.getColor(), new GpxBitmapCreatedCallback() {
@Override
public void onGpxBitmapCreatedComplete(AGpxBitmap aGpxBitmap) {
public void onGpxBitmapCreatedComplete(Bitmap gpxBitmap) {
try {
callback.onGpxBitmapCreated(aGpxBitmap);
callback.onGpxBitmapCreated(new AGpxBitmap(gpxBitmap));
} catch (RemoteException e) {
handleException(e);
}
@ -1033,13 +1114,13 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
}
@Override
public int copyFile(CopyFileParams copyFileParams) {
public int copyFile(CopyFileParams params) {
try {
OsmandAidlApi api = getApi("copyFile");
if (api == null) {
return CANNOT_ACCESS_API_ERROR;
}
return api.copyFile(copyFileParams);
return api.copyFile(params.getFileName(), params.getFilePartData(), params.getStartTime(), params.isDone());
} catch (Exception e) {
handleException(e);
return UNKNOWN_API_ERROR;
@ -1079,7 +1160,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
callbackId = addAidlCallback(callback, KEY_ON_CONTEXT_MENU_BUTTONS_CLICK);
params.setCallbackId(callbackId);
}
boolean buttonsAdded = api.addContextMenuButtons(params, callbackId);
boolean buttonsAdded = api.addContextMenuButtons(new AidlContextMenuButtonsWrapper(params), callbackId);
return buttonsAdded ? callbackId : -1;
} else {
return -1;
@ -1111,7 +1192,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
OsmandAidlApi api = getApi("updateContextMenuButtons");
if (params != null && api != null) {
ContextMenuButtonsParams buttonsParams = params.getContextMenuButtonsParams();
return api.updateContextMenuButtons(buttonsParams, buttonsParams.getCallbackId());
return api.updateContextMenuButtons(new AidlContextMenuButtonsWrapper(buttonsParams), buttonsParams.getCallbackId());
}
return false;
} catch (Exception e) {
@ -1135,7 +1216,11 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
public boolean setCustomization(CustomizationInfoParams params) {
try {
OsmandAidlApi api = getApi("setCustomization");
return api != null && params != null && api.setCustomization(params);
if (api != null && params != null) {
OsmandAidlService.this.setCustomization(api, params);
return true;
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -1143,10 +1228,10 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
}
@Override
public long registerForVoiceRouterMessages(ANavigationVoiceRouterMessageParams params, final IOsmAndAidlCallback callback) throws RemoteException {
public long registerForVoiceRouterMessages(ANavigationVoiceRouterMessageParams params, final IOsmAndAidlCallback callback) {
try {
OsmandAidlApi api = getApi("registerForVoiceRouterMessages");
if (api != null ) {
if (api != null) {
if (!params.isSubscribeToUpdates() && params.getCallbackId() != -1) {
api.unregisterFromVoiceRouterMessages(params.getCallbackId());
removeAidlCallback(params.getCallbackId());
@ -1177,10 +1262,14 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
}
@Override
public boolean getGpxColor(GpxColorParams params) throws RemoteException {
public boolean getGpxColor(GpxColorParams params) {
try {
OsmandAidlApi api = getApi("getGpxColor");
return api != null && api.getGpxColor(params);
if (api != null && params != null) {
String colorName = api.getGpxColor(params.getFileName());
params.setGpxColor(colorName);
}
return false;
} catch (Exception e) {
handleException(e);
return false;
@ -1188,6 +1277,79 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
}
};
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
OsmandSettingsParams settingsParams = params.getSettingsParams();
if (settingsParams != null) {
api.customizeOsmandSettings(settingsParams.getSharedPreferencesName(), settingsParams.getBundle());
}
NavDrawerHeaderParams navDrawerHeaderParams = params.getNavDrawerHeaderParams();
NavDrawerFooterParams navDrawerFooterParams = params.getNavDrawerFooterParams();
SetNavDrawerItemsParams navDrawerItemsParams = params.getNavDrawerItemsParams();
setNavDrawerParams(api, navDrawerHeaderParams, navDrawerFooterParams, navDrawerItemsParams);
ArrayList<SetWidgetsParams> visibilityWidgetsParams = params.getVisibilityWidgetsParams();
ArrayList<SetWidgetsParams> availabilityWidgetsParams = params.getAvailabilityWidgetsParams();
regWidgetsVisibility(api, visibilityWidgetsParams);
regWidgetsAvailability(api, availabilityWidgetsParams);
ArrayList<PluginParams> pluginsParams = params.getPluginsParams();
if (pluginsParams != null) {
changePluginsStatus(api, pluginsParams);
}
List<String> enabledIds = params.getFeaturesEnabledIds();
List<String> disabledIds = params.getFeaturesDisabledIds();
api.setEnabledIds(enabledIds);
api.setDisabledIds(disabledIds);
List<String> enabledPatterns = params.getFeaturesEnabledPatterns();
List<String> disabledPatterns = params.getFeaturesDisabledPatterns();
api.setEnabledPatterns(enabledPatterns);
api.setDisabledPatterns(disabledPatterns);
}
private void setNavDrawerParams(OsmandAidlApi api, NavDrawerHeaderParams navDrawerHeaderParams, NavDrawerFooterParams navDrawerFooterParams, SetNavDrawerItemsParams navDrawerItemsParams) {
if (navDrawerHeaderParams != null) {
api.setNavDrawerLogoWithParams(navDrawerHeaderParams.getImageUri(), navDrawerHeaderParams.getPackageName(), navDrawerHeaderParams.getIntent());
}
if (navDrawerFooterParams != null) {
api.setNavDrawerFooterWithParams(navDrawerFooterParams.getAppName(), navDrawerFooterParams.getPackageName(), navDrawerFooterParams.getIntent());
}
if (navDrawerItemsParams != null) {
api.setNavDrawerItems(navDrawerItemsParams.getAppPackage(), convertNavDrawerItems(navDrawerItemsParams.getItems()));
}
}
private void regWidgetsVisibility(OsmandAidlApi api, ArrayList<SetWidgetsParams> visibilityWidgetsParams) {
for (SetWidgetsParams setWidgetsParams : visibilityWidgetsParams) {
api.regWidgetVisibility(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys());
}
}
private void regWidgetsAvailability(OsmandAidlApi api, ArrayList<SetWidgetsParams> availabilityWidgetsParams) {
for (SetWidgetsParams setWidgetsParams : availabilityWidgetsParams) {
api.regWidgetAvailability(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys());
}
}
public void changePluginsStatus(OsmandAidlApi api, List<PluginParams> pluginsParams) {
for (PluginParams pluginParams : pluginsParams) {
api.changePluginState(pluginParams.getPluginId(), pluginParams.getNewState());
}
}
private List<OsmAndAppCustomization.NavDrawerItem> convertNavDrawerItems(List<NavDrawerItem> drawerItems) {
List<OsmAndAppCustomization.NavDrawerItem> customizationItems = new ArrayList<>();
for (NavDrawerItem item : drawerItems) {
customizationItems.add(new OsmAndAppCustomization.NavDrawerItem(item.getName(), item.getUri(), item.getIconName(), item.getFlags()));
}
return customizationItems;
}
public static class AidlCallbackParams {
private IOsmAndAidlCallback callback;
private long key;

File diff suppressed because it is too large Load diff

View file

@ -16,13 +16,6 @@ import android.widget.ArrayAdapter;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.aidl.customization.CustomizationInfoParams;
import net.osmand.aidl.customization.OsmandSettingsParams;
import net.osmand.aidl.customization.SetWidgetsParams;
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
import net.osmand.aidl.navdrawer.NavDrawerHeaderParams;
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
import net.osmand.aidl.plugins.PluginParams;
import net.osmand.data.LocationPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.PluginsActivity;
@ -63,7 +56,10 @@ public class OsmAndAppCustomization {
private Bitmap navDrawerLogo;
private ArrayList<String> navDrawerParams;
private NavDrawerFooterParams navDrawerFooterParams;
private String navDrawerFooterIntent;
private String navDrawerFooterAppName;
private String navDrawerFooterPackageName;
private Set<String> featuresEnabledIds = new HashSet<>();
private Set<String> featuresDisabledIds = new HashSet<>();
@ -253,13 +249,15 @@ public class OsmAndAppCustomization {
return true;
}
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params) {
navDrawerFooterParams = params;
public boolean setNavDrawerFooterParams(String uri, @Nullable String packageName, @Nullable String intent) {
navDrawerFooterAppName = uri;
navDrawerFooterIntent = intent;
navDrawerFooterPackageName = packageName;
return true;
}
public NavDrawerFooterParams getNavFooterParams() {
return navDrawerFooterParams;
public String getNavFooterAppName() {
return navDrawerFooterAppName;
}
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
@ -300,89 +298,6 @@ public class OsmAndAppCustomization {
return set;
}
public void regWidgetsVisibility(@NonNull ArrayList<SetWidgetsParams> visibilityWidgetsParams) {
for (SetWidgetsParams setWidgetsParams : visibilityWidgetsParams) {
regWidgetVisibility(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys());
}
}
public void regWidgetsAvailability(@NonNull ArrayList<SetWidgetsParams> availabilityWidgetsParams) {
for (SetWidgetsParams setWidgetsParams : availabilityWidgetsParams) {
regWidgetAvailability(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys());
}
}
public void setCustomization(CustomizationInfoParams params) {
OsmandSettingsParams settingsParams = params.getSettingsParams();
if (settingsParams != null) {
customizeOsmandSettings(settingsParams.getSharedPreferencesName(), settingsParams.getBundle());
}
NavDrawerHeaderParams navDrawerHeaderParams = params.getNavDrawerHeaderParams();
NavDrawerFooterParams navDrawerFooterParams = params.getNavDrawerFooterParams();
SetNavDrawerItemsParams navDrawerItemsParams = params.getNavDrawerItemsParams();
setNavDrawerParams(navDrawerHeaderParams, navDrawerFooterParams, navDrawerItemsParams);
ArrayList<SetWidgetsParams> visibilityWidgetsParams = params.getVisibilityWidgetsParams();
ArrayList<SetWidgetsParams> availabilityWidgetsParams = params.getAvailabilityWidgetsParams();
setWidgetsParams(visibilityWidgetsParams, availabilityWidgetsParams);
ArrayList<PluginParams> pluginsParams = params.getPluginsParams();
if (pluginsParams != null) {
changePluginsStatus(pluginsParams);
}
List<String> enabledIds = params.getFeaturesEnabledIds();
List<String> disabledIds = params.getFeaturesDisabledIds();
setFeaturesIds(enabledIds, disabledIds);
List<String> enabledPatterns = params.getFeaturesEnabledPatterns();
List<String> disabledPatterns = params.getFeaturesDisabledPatterns();
setFeaturesPatterns(enabledPatterns, disabledPatterns);
}
public void setNavDrawerParams(NavDrawerHeaderParams navDrawerHeaderParams, NavDrawerFooterParams navDrawerFooterParams, SetNavDrawerItemsParams navDrawerItemsParams) {
if (navDrawerHeaderParams != null) {
setNavDrawerLogoWithParams(navDrawerHeaderParams.getImageUri(), navDrawerHeaderParams.getPackageName(), navDrawerHeaderParams.getIntent());
}
if (navDrawerFooterParams != null) {
setNavDrawerFooterParams(navDrawerFooterParams);
}
if (navDrawerItemsParams != null) {
setNavDrawerItems(navDrawerItemsParams.getAppPackage(), navDrawerItemsParams.getItems());
}
}
public void setWidgetsParams(ArrayList<SetWidgetsParams> visibilityWidgetsParams, ArrayList<SetWidgetsParams> availabilityWidgetsParams) {
if (visibilityWidgetsParams != null) {
regWidgetsVisibility(visibilityWidgetsParams);
}
if (availabilityWidgetsParams != null) {
regWidgetsAvailability(availabilityWidgetsParams);
}
}
public void setFeaturesIds(List<String> enabledIds, List<String> disabledIds) {
if (enabledIds != null) {
setFeaturesEnabledIds(enabledIds);
}
if (disabledIds != null) {
setFeaturesDisabledIds(disabledIds);
}
}
public void setFeaturesPatterns(List<String> enabledPatterns, List<String> disabledPatterns) {
if (enabledPatterns != null) {
setFeaturesEnabledPatterns(enabledPatterns);
}
if (disabledPatterns != null) {
setFeaturesDisabledPatterns(disabledPatterns);
}
}
public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) {
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
if (set == null) {
@ -404,25 +319,19 @@ public class OsmAndAppCustomization {
return setNavDrawerLogo(imageUri, packageName, intent);
}
public void changePluginsStatus(List<PluginParams> pluginsParams) {
for (PluginParams pluginParams : pluginsParams) {
changePluginStatus(pluginParams);
}
}
public boolean changePluginStatus(PluginParams params) {
if (params.getNewState() == 0) {
public boolean changePluginStatus(String pluginId, int newState) {
if (newState == 0) {
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
if (plugin.getId().equals(params.getPluginId())) {
if (plugin.getId().equals(pluginId)) {
OsmandPlugin.enablePlugin(null, app, plugin, false);
}
}
return true;
}
if (params.getNewState() == 1) {
if (newState == 1) {
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
if (plugin.getId().equals(params.getPluginId())) {
if (plugin.getId().equals(pluginId)) {
OsmandPlugin.enablePlugin(null, app, plugin, true);
}
}
@ -432,7 +341,7 @@ public class OsmAndAppCustomization {
return false;
}
public boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
public boolean setNavDrawerItems(String appPackage, List<NavDrawerItem> items) {
if (!TextUtils.isEmpty(appPackage) && items != null) {
clearNavDrawerItems(appPackage);
if (items.isEmpty()) {
@ -441,11 +350,9 @@ public class OsmAndAppCustomization {
List<NavDrawerItem> newItems = new ArrayList<>(MAX_NAV_DRAWER_ITEMS_PER_APP);
boolean success = true;
for (int i = 0; i < items.size() && i <= MAX_NAV_DRAWER_ITEMS_PER_APP; i++) {
net.osmand.aidl.navdrawer.NavDrawerItem item = items.get(i);
String name = item.getName();
String uri = item.getUri();
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(uri)) {
newItems.add(new NavDrawerItem(name, uri, item.getIconName(), item.getFlags()));
NavDrawerItem item = items.get(i);
if (!TextUtils.isEmpty(item.name) && !TextUtils.isEmpty(item.uri)) {
newItems.add(item);
} else {
success = false;
break;
@ -654,7 +561,7 @@ public class OsmAndAppCustomization {
this.listeners.remove(listener);
}
private static class NavDrawerItem {
public static class NavDrawerItem {
static final String NAME_KEY = "name";
static final String URI_KEY = "uri";
@ -666,7 +573,7 @@ public class OsmAndAppCustomization {
private String iconName;
private int flags;
NavDrawerItem(String name, String uri, String iconName, int flags) {
public NavDrawerItem(String name, String uri, String iconName, int flags) {
this.name = name;
this.uri = uri;
this.iconName = iconName;

View file

@ -50,9 +50,8 @@ import net.osmand.SecondSplashScreenFragment;
import net.osmand.StateChangedListener;
import net.osmand.ValueHolder;
import net.osmand.access.MapAccessibilityActions;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.aidl.OsmandAidlApi.AMapPointUpdateListener;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.core.android.AtlasMapRendererView;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@ -1923,13 +1922,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
@Override
public void onAMapPointUpdated(final AMapPoint point, String layerId) {
public void onAMapPointUpdated(final AidlMapPointWrapper point, String layerId) {
if (canUpdateAMapPointMenu(point, layerId)) {
app.runInUIThread(new Runnable() {
@Override
public void run() {
ALatLon loc = point.getLocation();
LatLon latLon = new LatLon(loc.getLatitude(), loc.getLongitude());
LatLon latLon = point.getLocation();
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName());
mapContextMenu.update(latLon, pointDescription, point);
mapContextMenu.centerMarkerLocation();
@ -1938,12 +1936,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
private boolean canUpdateAMapPointMenu(AMapPoint point, String layerId) {
private boolean canUpdateAMapPointMenu(AidlMapPointWrapper point, String layerId) {
Object object = mapContextMenu.getObject();
if (!mapContextMenu.isVisible() || !(object instanceof AMapPoint)) {
if (!mapContextMenu.isVisible() || !(object instanceof AidlMapPointWrapper)) {
return false;
}
AMapPoint oldPoint = (AMapPoint) object;
AidlMapPointWrapper oldPoint = (AidlMapPointWrapper) object;
return oldPoint.getLayerId().equals(layerId) && oldPoint.getId().equals(point.getId());
}

View file

@ -25,7 +25,7 @@ public class OsmandRestoreOrExitDialog extends BottomSheetDialogFragment {
View view = getActivity().getLayoutInflater()
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
try {
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterAppName();
} catch (Exception e) {
e.printStackTrace();
}

View file

@ -15,8 +15,8 @@ import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.aidl.AidlSearchResultWrapper;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@ -663,7 +663,7 @@ public class ExternalApiHelper {
searchLocation.getLatitude(), searchLocation.getLongitude(),
1, 1, new OsmandAidlApi.SearchCompleteCallback() {
@Override
public void onSearchComplete(final List<SearchResult> resultSet) {
public void onSearchComplete(final List<AidlSearchResultWrapper> resultSet) {
final MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
mapActivity.getMyApplication().runInUIThread(new Runnable() {
@ -674,7 +674,7 @@ public class ExternalApiHelper {
dlg.dismiss();
}
if (resultSet.size() > 0) {
final SearchResult res = resultSet.get(0);
final AidlSearchResultWrapper res = resultSet.get(0);
LatLon to = new LatLon(res.getLatitude(), res.getLongitude());
PointDescription toDesc = new PointDescription(
PointDescription.POINT_TYPE_TARGET, res.getLocalName() + ", " + res.getLocalTypeName());
@ -707,13 +707,13 @@ public class ExternalApiHelper {
core.setOnResultsComplete(new Runnable() {
@Override
public void run() {
List<SearchResult> resultSet = new ArrayList<>();
List<AidlSearchResultWrapper> resultSet = new ArrayList<>();
SearchUICore.SearchResultCollection resultCollection = core.getCurrentSearchResult();
int count = 0;
for (net.osmand.search.core.SearchResult r : resultCollection.getCurrentSearchResults()) {
String name = QuickSearchListItem.getName(app, r);
String typeName = QuickSearchListItem.getTypeName(app, r);
SearchResult result = new SearchResult(r.location.getLatitude(), r.location.getLongitude(),
AidlSearchResultWrapper result = new AidlSearchResultWrapper(r.location.getLatitude(), r.location.getLongitude(),
name, typeName, r.alternateName, new ArrayList<>(r.otherNames));
resultSet.add(result);
count++;

View file

@ -2,9 +2,7 @@ package net.osmand.plus.mapcontextmenu;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
@ -17,13 +15,11 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import java.util.Map;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.NativeLibrary.RenderedObject;
import net.osmand.PlatformUtil;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.binary.RouteDataObject;
@ -211,8 +207,8 @@ public abstract class MenuController extends BaseMenuController implements Colla
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
} else if (object instanceof TransportStop) {
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
} else if (object instanceof AMapPoint) {
menuController = new AMapPointMenuController(mapActivity, pointDescription, (AMapPoint) object);
} else if (object instanceof AidlMapPointWrapper) {
menuController = new AMapPointMenuController(mapActivity, pointDescription, (AidlMapPointWrapper) object);
} else if (object instanceof LatLon) {
if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription);

View file

@ -10,9 +10,10 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Pair;
import net.osmand.aidl.contextmenu.AContextMenuButton;
import net.osmand.aidl.contextmenu.ContextMenuButtonsParams;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.AidlContextMenuButtonWrapper;
import net.osmand.aidl.AidlContextMenuButtonsWrapper;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.aidl2.maplayer.point.AMapPoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
@ -24,7 +25,6 @@ import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.widgets.tools.CropCircleTransformation;
import net.osmand.util.Algorithms;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@ -35,19 +35,19 @@ public class AMapPointMenuController extends MenuController {
private static final float NO_VALUE = -1;
private static final int NO_ICON = 0;
private AMapPoint point;
private AidlMapPointWrapper point;
private Drawable pointDrawable;
public AMapPointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final AMapPoint point) {
public AMapPointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final AidlMapPointWrapper point) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.point = point;
pointDrawable = getPointDrawable();
final OsmandApplication app = mapActivity.getMyApplication();
Map<String, ContextMenuButtonsParams> buttonsParamsMap = app.getAidlApi().getContextMenuButtonsParams();
Map<String, AidlContextMenuButtonsWrapper> buttonsParamsMap = app.getAidlApi().getContextMenuButtonsParams();
if (!buttonsParamsMap.isEmpty()) {
additionalButtonsControllers = new ArrayList<>();
for (ContextMenuButtonsParams buttonsParams : buttonsParamsMap.values()) {
for (AidlContextMenuButtonsWrapper buttonsParams : buttonsParamsMap.values()) {
List<String> pointsIds = buttonsParams.getPointsIds();
if (((pointsIds == null || pointsIds.isEmpty()) || pointsIds.contains(point.getId())) || buttonsParams.getLayerId().equals(point.getLayerId())) {
long callbackId = buttonsParams.getCallbackId();
@ -61,8 +61,8 @@ public class AMapPointMenuController extends MenuController {
@Override
protected void setObject(Object object) {
if (object instanceof AMapPoint) {
this.point = (AMapPoint) object;
if (object instanceof AidlMapPointWrapper) {
this.point = (AidlMapPointWrapper) object;
}
}
@ -179,7 +179,7 @@ public class AMapPointMenuController extends MenuController {
return false;
}
private TitleButtonController createAdditionButtonController(final AContextMenuButton contextMenuButton, final long callbackId) {
private TitleButtonController createAdditionButtonController(final AidlContextMenuButtonWrapper contextMenuButton, final long callbackId) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null || contextMenuButton == null) {
return null;

View file

@ -16,9 +16,9 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import net.osmand.AndroidUtils;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.maplayer.AMapLayer;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.AidlMapLayerWrapper;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.aidl2.maplayer.point.AMapPoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
@ -39,7 +39,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider<AMapPoint> {
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider<AidlMapPointWrapper> {
private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f;
@ -51,7 +51,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
private final MapActivity map;
private OsmandMapTileView view;
private AMapLayer aidlLayer;
private AidlMapLayerWrapper aidlLayer;
private Paint pointInnerCircle;
private Paint pointOuterCircle;
@ -75,9 +75,9 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
private Map<String, Bitmap> pointImages = new ConcurrentHashMap<>();
private Set<String> imageRequests = new HashSet<>();
private List<AMapPoint> displayedPoints = new ArrayList<>();
private List<AidlMapPointWrapper> displayedPoints = new ArrayList<>();
public AidlMapLayer(MapActivity map, AMapLayer aidlLayer) {
public AidlMapLayer(MapActivity map, AidlMapLayerWrapper aidlLayer) {
this.map = map;
this.aidlLayer = aidlLayer;
}
@ -140,8 +140,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
String selectedPointId = getSelectedContextMenuPointId();
for (AMapPoint point : aidlLayer.getPoints()) {
ALatLon l = point.getLocation();
for (AidlMapPointWrapper point : aidlLayer.getPoints()) {
LatLon l = point.getLocation();
if (l != null) {
int x = (int) tileBox.getPixXFromLatLon(l.getLatitude(), l.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(l.getLatitude(), l.getLongitude());
@ -169,7 +169,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
mapTextLayer.putData(this, displayedPoints);
}
private void drawPoint(Canvas canvas, int x, int y, RotatedTileBox tb, AMapPoint point, Bitmap image, boolean selected) {
private void drawPoint(Canvas canvas, int x, int y, RotatedTileBox tb, AidlMapPointWrapper point, Bitmap image, boolean selected) {
if (image == null) {
image = placeholder;
}
@ -205,8 +205,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
private String getSelectedContextMenuPointId() {
MapContextMenu mapContextMenu = map.getContextMenu();
Object object = mapContextMenu.getObject();
if (mapContextMenu.isVisible() && object instanceof AMapPoint) {
AMapPoint aMapPoint = (AMapPoint) object;
if (mapContextMenu.isVisible() && object instanceof AidlMapPointWrapper) {
AidlMapPointWrapper aMapPoint = (AidlMapPointWrapper) object;
return aMapPoint.getId();
}
return null;
@ -226,7 +226,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
return rect;
}
private boolean isStale(AMapPoint point) {
private boolean isStale(AidlMapPointWrapper point) {
return Boolean.parseBoolean(point.getParams().get(AMapPoint.POINT_STALE_LOC_PARAM));
}
@ -251,7 +251,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public boolean isObjectClickable(Object o) {
return o instanceof AMapPoint;
return o instanceof AidlMapPointWrapper;
}
@Override
@ -266,40 +266,33 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public LatLon getObjectLocation(Object o) {
if (o instanceof AMapPoint) {
ALatLon loc = ((AMapPoint) o).getLocation();
if (loc != null) {
return new LatLon(loc.getLatitude(), loc.getLongitude());
}
if (o instanceof AidlMapPointWrapper) {
return ((AidlMapPointWrapper) o).getLocation();
}
return null;
}
@Override
public PointDescription getObjectName(Object o) {
if (o instanceof AMapPoint) {
return new PointDescription(PointDescription.POINT_TYPE_MARKER, ((AMapPoint) o).getFullName());
if (o instanceof AidlMapPointWrapper) {
return new PointDescription(PointDescription.POINT_TYPE_MARKER, ((AidlMapPointWrapper) o).getFullName());
} else {
return null;
}
}
@Nullable
public AMapPoint getPoint(@NonNull String id) {
public AidlMapPointWrapper getPoint(@NonNull String id) {
return aidlLayer.getPoint(id);
}
@Override
public LatLon getTextLocation(AMapPoint o) {
ALatLon loc = o.getLocation();
if (loc != null) {
return new LatLon(loc.getLatitude(), loc.getLongitude());
}
return null;
public LatLon getTextLocation(AidlMapPointWrapper o) {
return o.getLocation();
}
@Override
public int getTextShift(AMapPoint o, RotatedTileBox rb) {
public int getTextShift(AidlMapPointWrapper o, RotatedTileBox rb) {
if (pointsType == PointsType.STANDARD) {
return (int) (getRadiusPoi(rb) * 1.5);
} else if (pointsType == PointsType.CIRCLE) {
@ -313,7 +306,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
}
@Override
public String getText(AMapPoint o) {
public String getText(AidlMapPointWrapper o) {
return o.getShortName();
}
@ -376,13 +369,13 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
return r * 3 / 2;
}
private void getFromPoint(RotatedTileBox tb, PointF point, List<? super AMapPoint> points) {
private void getFromPoint(RotatedTileBox tb, PointF point, List<? super AidlMapPointWrapper> points) {
if (view != null) {
int ex = (int) point.x;
int ey = (int) point.y;
int radius = getPointRadius(tb);
for (AMapPoint p : aidlLayer.getPoints()) {
ALatLon position = p.getLocation();
for (AidlMapPointWrapper p : aidlLayer.getPoints()) {
LatLon position = p.getLocation();
if (position != null) {
int x = (int) tb.getPixXFromLatLon(position.getLatitude(), position.getLongitude());
int y = (int) tb.getPixYFromLatLon(position.getLatitude(), position.getLongitude());

View file

@ -25,7 +25,7 @@ import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.NativeLibrary.RenderedObject;
import net.osmand.RenderingContext;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.AidlMapPointWrapper;
import net.osmand.core.android.MapRendererView;
import net.osmand.core.jni.AmenitySymbolsProvider.AmenitySymbolsGroup;
import net.osmand.core.jni.AreaI;
@ -205,7 +205,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
RenderedObject r = (RenderedObject) selectedObject;
x = r.getX();
y = r.getY();
} else if (selectedObject instanceof AMapPoint) {
} else if (selectedObject instanceof AidlMapPointWrapper) {
markerCustomized = true;
}
if (x != null && y != null && x.size() > 2) {