diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 69e0d49daa..79426de958 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -714,6 +714,13 @@ + + + + + + + diff --git a/OsmAnd/src/net/osmand/aidl/ALatLon.aidl b/OsmAnd/src/net/osmand/aidl/ALatLon.aidl new file mode 100644 index 0000000000..ed8bd49956 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/ALatLon.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl; + +parcelable ALatLon; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/ALatLon.java b/OsmAnd/src/net/osmand/aidl/ALatLon.java new file mode 100644 index 0000000000..fe3f0b48bc --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/ALatLon.java @@ -0,0 +1,83 @@ +package net.osmand.aidl; + +import android.os.Parcel; +import android.os.Parcelable; + +public class ALatLon implements Parcelable { + + private double longitude; + private double latitude; + + public ALatLon(double latitude, double longitude) { + this.latitude = latitude; + this.longitude = longitude; + } + + public ALatLon(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public ALatLon createFromParcel(Parcel in) { + return new ALatLon(in); + } + + public ALatLon[] newArray(int size) { + return new ALatLon[size]; + } + }; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + int temp; + temp = (int)Math.floor(latitude * 10000); + result = prime * result + temp; + temp = (int)Math.floor(longitude * 10000); + result = prime * result + temp; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + + ALatLon other = (ALatLon) obj; + return Math.abs(latitude - other.latitude) < 0.00001 + && Math.abs(longitude - other.longitude) < 0.00001; + } + + @Override + public String toString() { + return "Lat " + ((float)latitude) + " Lon " + ((float)longitude); + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeDouble(latitude); + out.writeDouble(longitude); + } + + public void readFromParcel(Parcel in) { + latitude = in.readDouble(); + longitude = in.readDouble(); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl new file mode 100644 index 0000000000..25b1a5219b --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -0,0 +1,43 @@ +package net.osmand.aidl; + +import net.osmand.aidl.ALatLon; +import net.osmand.aidl.mapmarker.AMapMarker; +import net.osmand.aidl.mapmarker.AddMapMarkerParams; +import net.osmand.aidl.mapmarker.RemoveMapMarkerParams; +import net.osmand.aidl.mapmarker.UpdateMapMarkerParams; +import net.osmand.aidl.calculateroute.CalculateRouteParams; + +import net.osmand.aidl.mapwidget.AMapWidget; +import net.osmand.aidl.mapwidget.AddMapWidgetParams; +import net.osmand.aidl.mapwidget.RemoveMapWidgetParams; +import net.osmand.aidl.mapwidget.UpdateMapWidgetParams; + +import net.osmand.aidl.maplayer.point.AMapPoint; +import net.osmand.aidl.maplayer.point.AddMapPointParams; +import net.osmand.aidl.maplayer.point.RemoveMapPointParams; +import net.osmand.aidl.maplayer.point.UpdateMapPointParams; +import net.osmand.aidl.maplayer.AMapLayer; +import net.osmand.aidl.maplayer.AddMapLayerParams; +import net.osmand.aidl.maplayer.RemoveMapLayerParams; +import net.osmand.aidl.maplayer.UpdateMapLayerParams; + +interface IOsmAndAidlInterface { + + boolean addMapMarker(in AddMapMarkerParams params); + boolean removeMapMarker(in RemoveMapMarkerParams params); + boolean updateMapMarker(in UpdateMapMarkerParams params); + + boolean addMapWidget(in AddMapWidgetParams params); + boolean removeMapWidget(in RemoveMapWidgetParams params); + boolean updateMapWidget(in UpdateMapWidgetParams params); + + boolean addMapPoint(in AddMapPointParams params); + boolean removeMapPoint(in RemoveMapPointParams params); + boolean updateMapPoint(in UpdateMapPointParams params); + + boolean addMapLayer(in AddMapLayerParams params); + boolean removeMapLayer(in RemoveMapLayerParams params); + boolean updateMapLayer(in UpdateMapLayerParams params); + + boolean calculateRoute(in CalculateRouteParams params); +} diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java new file mode 100644 index 0000000000..1553498199 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -0,0 +1,283 @@ +package net.osmand.aidl; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.view.View; + +import net.osmand.aidl.mapmarker.AMapMarker; +import net.osmand.aidl.mapwidget.AMapWidget; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +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.views.MapInfoLayer; +import net.osmand.plus.views.OsmandMapLayer.DrawSettings; +import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo; +import net.osmand.plus.views.mapwidgets.TextInfoWidget; +import net.osmand.util.Algorithms; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class OsmandAidlApi { + + private static final String AIDL_REFRESH_MAP = "aidl_refresh_map"; + private static final String AIDL_ADD_MAP_WIDGET = "aidl_add_map_widget"; + private static final String AIDL_REMOVE_MAP_WIDGET = "aidl_remove_map_widget"; + private static final String AIDL_MAP_WIDGET_ID = "aidl_map_widget_id"; + + private OsmandApplication app; + private Map widgets = new ConcurrentHashMap<>(); + private Map widgetControls = new ConcurrentHashMap<>(); + + private BroadcastReceiver refreshMapReceiver; + private BroadcastReceiver addMapWidgetReceiver; + private BroadcastReceiver removeMapWidgetReceiver; + + public OsmandAidlApi(OsmandApplication app) { + this.app = app; + } + + public void onCreateMapActivity(final MapActivity mapActivity) { + registerRefreshMapReceiver(mapActivity); + registerAddMapWidgetReceiver(mapActivity); + registerRemoveMapWidgetReceiver(mapActivity); + } + + public void onDestroyMapActivity(final MapActivity mapActivity) { + if (refreshMapReceiver != null) { + mapActivity.unregisterReceiver(refreshMapReceiver); + } + if (addMapWidgetReceiver != null) { + mapActivity.unregisterReceiver(addMapWidgetReceiver); + } + if (removeMapWidgetReceiver != null) { + mapActivity.unregisterReceiver(removeMapWidgetReceiver); + } + widgetControls.clear(); + } + + private void registerRefreshMapReceiver(final MapActivity mapActivity) { + refreshMapReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + mapActivity.refreshMap(); + } + }; + mapActivity.registerReceiver(refreshMapReceiver, new IntentFilter(AIDL_REFRESH_MAP)); + } + + private int getDrawableId(String id) { + if (Algorithms.isEmpty(id)) { + return 0; + } else { + return app.getResources().getIdentifier(id, "drawable", app.getPackageName()); + } + } + + private void registerAddMapWidgetReceiver(final MapActivity mapActivity) { + addMapWidgetReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String widgetId = intent.getStringExtra(AIDL_MAP_WIDGET_ID); + if (widgetId != null) { + AMapWidget widget = widgets.get(widgetId); + if (widget != null) { + MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer(); + if (layer != null) { + TextInfoWidget control = createWidgetControl(mapActivity, widgetId); + widgetControls.put(widgetId, control); + int menuIconId = getDrawableId(widget.getMenuIconName()); + MapWidgetRegInfo widgetInfo = layer.registerSideWidget(control, + menuIconId, widget.getMenuTitle(), "aidl_widget_" + widgetId, + false, widget.getOrder()); + if (!mapActivity.getMapLayers().getMapWidgetRegistry().isVisible(widgetInfo.key)) { + mapActivity.getMapLayers().getMapWidgetRegistry().setVisibility(widgetInfo, true, false); + } + layer.recreateControls(); + } + } + } + } + }; + mapActivity.registerReceiver(addMapWidgetReceiver, new IntentFilter(AIDL_ADD_MAP_WIDGET)); + } + + private void registerRemoveMapWidgetReceiver(final MapActivity mapActivity) { + removeMapWidgetReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String widgetId = intent.getStringExtra(AIDL_MAP_WIDGET_ID); + if (widgetId != null) { + MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer(); + TextInfoWidget widgetControl = widgetControls.get(widgetId); + if (layer != null && widgetControl != null) { + layer.removeSideWidget(widgetControl); + widgetControls.remove(widgetId); + layer.recreateControls(); + } + } + } + }; + mapActivity.registerReceiver(removeMapWidgetReceiver, new IntentFilter(AIDL_REMOVE_MAP_WIDGET)); + } + + public void registerWidgetControls(MapActivity mapActivity) { + for (AMapWidget widget : widgets.values()) { + MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer(); + if (layer != null) { + TextInfoWidget control = createWidgetControl(mapActivity, widget.getId()); + widgetControls.put(widget.getId(), control); + int menuIconId = getDrawableId(widget.getMenuIconName()); + MapWidgetRegInfo widgetInfo = layer.registerSideWidget(control, + menuIconId, widget.getMenuTitle(), "aidl_widget_" + widget.getId(), + false, widget.getOrder()); + if (!mapActivity.getMapLayers().getMapWidgetRegistry().isVisible(widgetInfo.key)) { + mapActivity.getMapLayers().getMapWidgetRegistry().setVisibility(widgetInfo, true, false); + } + } + } + } + + private void refreshMap() { + Intent intent = new Intent(); + intent.setAction(AIDL_REFRESH_MAP); + app.sendBroadcast(intent); + } + + public TextInfoWidget createWidgetControl(final MapActivity mapActivity, final String widgetId) { + final TextInfoWidget control = new TextInfoWidget(mapActivity) { + + @Override + public boolean updateInfo(DrawSettings drawSettings) { + AMapWidget widget = widgets.get(widgetId); + if (widget != null) { + String txt = widget.getText(); + String subtxt = widget.getDescription(); + boolean night = drawSettings != null && drawSettings.isNightMode(); + int icon = night ? getDrawableId(widget.getDarkIconName()) : getDrawableId(widget.getLightIconName()); + setText(txt, subtxt); + if (icon != 0) { + setImageDrawable(icon); + } else { + setImageDrawable(null); + } + return true; + } else { + return false; + } + } + }; + control.updateInfo(null); + + control.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AMapWidget widget = widgets.get(widgetId); + if (widget != null && widget.getIntentOnClick() != null) { + app.startActivity(widget.getIntentOnClick()); + } + } + }); + return control; + } + + boolean addMapMarker(AMapMarker marker) { + if (marker != null) { + PointDescription pd = new PointDescription( + PointDescription.POINT_TYPE_MAP_MARKER, marker.getName() != null ? marker.getName() : ""); + MapMarkersHelper markersHelper = app.getMapMarkersHelper(); + markersHelper.addMapMarker(new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude()), pd); + refreshMap(); + return true; + } else { + return false; + } + } + + boolean removeMapMarker(AMapMarker marker) { + if (marker != null) { + LatLon latLon = new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude()); + MapMarkersHelper markersHelper = app.getMapMarkersHelper(); + List mapMarkers = markersHelper.getMapMarkers(); + for (MapMarker m : mapMarkers) { + if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) { + markersHelper.removeMapMarker(m); + refreshMap(); + return true; + } + } + return false; + } else { + return false; + } + } + + boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew) { + if (markerPrev != null && markerNew != null) { + LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude()); + LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude()); + MapMarkersHelper markersHelper = app.getMapMarkersHelper(); + List mapMarkers = markersHelper.getMapMarkers(); + for (MapMarker m : mapMarkers) { + if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) { + PointDescription pd = new PointDescription( + PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : ""); + MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index); + markersHelper.moveMapMarker(marker, latLonNew); + refreshMap(); + return true; + } + } + return false; + } else { + return false; + } + } + + boolean addMapWidget(AMapWidget widget) { + if (widget != null) { + if (widgets.containsKey(widget.getId())) { + updateMapWidget(widget); + } else { + widgets.put(widget.getId(), widget); + Intent intent = new Intent(); + intent.setAction(AIDL_ADD_MAP_WIDGET); + intent.putExtra(AIDL_MAP_WIDGET_ID, widget.getId()); + app.sendBroadcast(intent); + } + refreshMap(); + return true; + } else { + return false; + } + } + + boolean removeMapWidget(String widgetId) { + if (!Algorithms.isEmpty(widgetId) && widgets.containsKey(widgetId)) { + widgets.remove(widgetId); + Intent intent = new Intent(); + intent.setAction(AIDL_REMOVE_MAP_WIDGET); + intent.putExtra(AIDL_MAP_WIDGET_ID, widgetId); + app.sendBroadcast(intent); + return true; + } else { + return false; + } + } + + boolean updateMapWidget(AMapWidget widget) { + if (widget != null && widgets.containsKey(widget.getId())) { + widgets.put(widget.getId(), widget); + refreshMap(); + return true; + } else { + return false; + } + } +} diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java new file mode 100644 index 0000000000..a1df7c460f --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -0,0 +1,176 @@ +package net.osmand.aidl; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; + +import net.osmand.aidl.calculateroute.CalculateRouteParams; +import net.osmand.aidl.maplayer.AddMapLayerParams; +import net.osmand.aidl.maplayer.RemoveMapLayerParams; +import net.osmand.aidl.maplayer.UpdateMapLayerParams; +import net.osmand.aidl.maplayer.point.AddMapPointParams; +import net.osmand.aidl.maplayer.point.RemoveMapPointParams; +import net.osmand.aidl.maplayer.point.UpdateMapPointParams; +import net.osmand.aidl.mapmarker.AddMapMarkerParams; +import net.osmand.aidl.mapmarker.RemoveMapMarkerParams; +import net.osmand.aidl.mapmarker.UpdateMapMarkerParams; +import net.osmand.aidl.mapwidget.AddMapWidgetParams; +import net.osmand.aidl.mapwidget.RemoveMapWidgetParams; +import net.osmand.aidl.mapwidget.UpdateMapWidgetParams; +import net.osmand.plus.OsmandApplication; + +public class OsmandAidlService extends Service { + + OsmandApplication getApp() { + return (OsmandApplication) getApplication(); + } + + OsmandAidlApi getApi() { + return getApp().getAidlApi(); + } + + @Override + public IBinder onBind(Intent intent) { + // Return the interface + return mBinder; + } + + private final IOsmAndAidlInterface.Stub mBinder = new IOsmAndAidlInterface.Stub() { + + @Override + public boolean addMapMarker(AddMapMarkerParams params) throws RemoteException { + try { + return params != null && getApi().addMapMarker(params.getMarker()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean removeMapMarker(RemoveMapMarkerParams params) throws RemoteException { + try { + return params != null && getApi().removeMapMarker(params.getMarker()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean updateMapMarker(UpdateMapMarkerParams params) throws RemoteException { + try { + return params != null && getApi().updateMapMarker(params.getMarkerPrev(), params.getMarkerNew()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean addMapWidget(AddMapWidgetParams params) throws RemoteException { + try { + return params != null && getApi().addMapWidget(params.getWidget()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean removeMapWidget(RemoveMapWidgetParams params) throws RemoteException { + try { + return params != null && getApi().removeMapWidget(params.getId()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean updateMapWidget(UpdateMapWidgetParams params) throws RemoteException { + try { + return params != null && getApi().updateMapWidget(params.getWidget()); + } catch (Exception e) { + return false; + } + } + + @Override + public boolean addMapPoint(AddMapPointParams params) throws RemoteException { + return false; + } + + @Override + public boolean removeMapPoint(RemoveMapPointParams params) throws RemoteException { + return false; + } + + @Override + public boolean updateMapPoint(UpdateMapPointParams params) throws RemoteException { + return false; + } + + @Override + public boolean addMapLayer(AddMapLayerParams params) throws RemoteException { + return false; + } + + @Override + public boolean removeMapLayer(RemoveMapLayerParams params) throws RemoteException { + return false; + } + + @Override + public boolean updateMapLayer(UpdateMapLayerParams params) throws RemoteException { + return false; + } + + @Override + public boolean calculateRoute(CalculateRouteParams params) throws RemoteException { + if (params == null || params.getEndPoint() == null) { + return false; + } else { + /* + final TargetPointsHelper targets = app.getTargetPointsHelper(); + targets.removeAllWayPoints(false, true); + + List intermediatePoints = params.getIntermediatePoints(); + List intermediateNames = params.getIntermediateNames(); + ALatLon intermediatePoint; + String intermediateName; + for (int i = 0; i < intermediatePoints.size(); i++ ) { + intermediatePoint = intermediatePoints.get(i); + if (i < intermediateNames.size()) { + intermediateName = intermediateNames.get(i); + } else { + intermediateName = ""; + } + if (intermediateName == null) { + intermediateName = ""; + } + targets.navigateToPoint( + new LatLon(intermediatePoint.getLatitude(), intermediatePoint.getLongitude()), + false, -1, new PointDescription(PointDescription.POINT_TYPE_LOCATION, intermediateName)); + } + + PointDescription endPointDescription = null; + if (params.getEndPointName() != null) { + endPointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, params.getEndPointName()); + } + targets.navigateToPoint( + new LatLon(params.getEndPoint().getLatitude(), params.getEndPoint().getLongitude()), + true, -1, endPointDescription); + + LatLon startPoint = null; + if (params.getStartPoint() != null) { + startPoint = new LatLon(params.getStartPoint().getLatitude(), params.getStartPoint().getLongitude()); + } + PointDescription startPointDescription = null; + if (params.getStartPointName() != null) { + startPointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, params.getStartPointName()); + } + + //mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, startPoint, startPointDescription, true, false); + */ + return true; + } + } + }; +} diff --git a/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.aidl b/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.aidl new file mode 100644 index 0000000000..017dd5e944 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.calculateroute; + +parcelable CalculateRouteParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.java b/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.java new file mode 100644 index 0000000000..c22a0c6d37 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/calculateroute/CalculateRouteParams.java @@ -0,0 +1,100 @@ +package net.osmand.aidl.calculateroute; + +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.ALatLon; + +import java.util.ArrayList; +import java.util.List; + +public class CalculateRouteParams implements Parcelable { + + private ALatLon startPoint; + private String startPointName; + private ALatLon endPoint; + private String endPointName; + private List intermediatePoints = new ArrayList<>(); + private List intermediateNames = new ArrayList<>(); + + public CalculateRouteParams(ALatLon startPoint, String startPointName, + ALatLon endPoint, String endPointName, + List intermediatePoints, List intermediateNames) { + + if (endPoint == null) { + throw new IllegalArgumentException("endPoint cannot be null"); + } + + this.startPoint = startPoint; + this.startPointName = startPointName; + this.endPoint = endPoint; + this.endPointName = endPointName; + if (intermediatePoints != null) { + this.intermediatePoints.addAll(intermediatePoints); + } + if (intermediateNames != null) { + this.intermediateNames.addAll(intermediateNames); + } + } + + public CalculateRouteParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public CalculateRouteParams createFromParcel(Parcel in) { + return new CalculateRouteParams(in); + } + + public CalculateRouteParams[] newArray(int size) { + return new CalculateRouteParams[size]; + } + }; + + public ALatLon getStartPoint() { + return startPoint; + } + + public String getStartPointName() { + return startPointName; + } + + public ALatLon getEndPoint() { + return endPoint; + } + + public String getEndPointName() { + return endPointName; + } + + public List getIntermediatePoints() { + return intermediatePoints; + } + + public List getIntermediateNames() { + return intermediateNames; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(startPoint, flags); + out.writeString(startPointName); + out.writeParcelable(endPoint, flags); + out.writeString(endPointName); + out.writeTypedList(intermediatePoints); + out.writeStringList(intermediateNames); + } + + private void readFromParcel(Parcel in) { + startPoint = in.readParcelable(ALatLon.class.getClassLoader()); + startPointName = in.readString(); + endPoint = in.readParcelable(ALatLon.class.getClassLoader()); + endPointName = in.readString(); + in.readTypedList(intermediatePoints, ALatLon.CREATOR); + in.readStringList(intermediateNames); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.aidl new file mode 100644 index 0000000000..745f49f1a5 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer; + +parcelable AMapLayer; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.java b/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.java new file mode 100644 index 0000000000..1c9d5b6833 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/AMapLayer.java @@ -0,0 +1,63 @@ +package net.osmand.aidl.maplayer; + +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.maplayer.point.AMapPoint; + +import java.util.HashMap; + +public class AMapLayer implements Parcelable { + private String id; + private String name; + private HashMap points = new HashMap<>(); + + public AMapLayer(String id, String name, HashMap points) { + this.id = id; + this.name = name; + this.points = points; + } + + public AMapLayer(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AMapLayer createFromParcel(Parcel in) { + return new AMapLayer(in); + } + + public AMapLayer[] newArray(int size) { + return new AMapLayer[size]; + } + }; + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public HashMap getPoints() { + return points; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(id); + out.writeString(name); + out.writeMap(points); + } + + private void readFromParcel(Parcel in) { + id = in.readString(); + name = in.readString(); + in.readMap(points, HashMap.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.aidl new file mode 100644 index 0000000000..8116760a45 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer; + +parcelable AddMapLayerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.java new file mode 100644 index 0000000000..9c6611d577 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/AddMapLayerParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.maplayer; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AddMapLayerParams implements Parcelable { + private AMapLayer layer; + + public AddMapLayerParams(AMapLayer layer) { + this.layer = layer; + } + + public AddMapLayerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AddMapLayerParams createFromParcel(Parcel in) { + return new AddMapLayerParams(in); + } + + public AddMapLayerParams[] newArray(int size) { + return new AddMapLayerParams[size]; + } + }; + + public AMapLayer getLayer() { + return layer; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(layer, flags); + } + + private void readFromParcel(Parcel in) { + layer = in.readParcelable(AMapLayer.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.aidl new file mode 100644 index 0000000000..20a972ee95 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer; + +parcelable RemoveMapLayerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.java new file mode 100644 index 0000000000..0eb01b0827 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/RemoveMapLayerParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.maplayer; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveMapLayerParams implements Parcelable { + private String id; + + public RemoveMapLayerParams(String id) { + this.id = id; + } + + public RemoveMapLayerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public RemoveMapLayerParams createFromParcel(Parcel in) { + return new RemoveMapLayerParams(in); + } + + public RemoveMapLayerParams[] newArray(int size) { + return new RemoveMapLayerParams[size]; + } + }; + + public String getId() { + return id; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(id); + } + + private void readFromParcel(Parcel in) { + id = in.readString(); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.aidl new file mode 100644 index 0000000000..eafe8ef464 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer; + +parcelable UpdateMapLayerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.java new file mode 100644 index 0000000000..9414eb35c0 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/UpdateMapLayerParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.maplayer; + +import android.os.Parcel; +import android.os.Parcelable; + +public class UpdateMapLayerParams implements Parcelable { + private AMapLayer layer; + + public UpdateMapLayerParams(AMapLayer layer) { + this.layer = layer; + } + + public UpdateMapLayerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public UpdateMapLayerParams createFromParcel(Parcel in) { + return new UpdateMapLayerParams(in); + } + + public UpdateMapLayerParams[] newArray(int size) { + return new UpdateMapLayerParams[size]; + } + }; + + public AMapLayer getLayer() { + return layer; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(layer, flags); + } + + private void readFromParcel(Parcel in) { + layer = in.readParcelable(AMapLayer.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.aidl new file mode 100644 index 0000000000..53fb86b788 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer.point; + +parcelable AMapPoint; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.java b/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.java new file mode 100644 index 0000000000..1e96029978 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/AMapPoint.java @@ -0,0 +1,77 @@ +package net.osmand.aidl.maplayer.point; + +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.ALatLon; + +public class AMapPoint implements Parcelable { + private String id; + private String shortName; + private String fullName; + private int color; + private ALatLon location; + + public AMapPoint(String id, String shortName, String fullName, int color, ALatLon location) { + this.id = id; + this.shortName = shortName; + this.fullName = fullName; + this.color = color; + this.location = location; + } + + public AMapPoint(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AMapPoint createFromParcel(Parcel in) { + return new AMapPoint(in); + } + + public AMapPoint[] newArray(int size) { + return new AMapPoint[size]; + } + }; + + public String getId() { + return id; + } + + public String getShortName() { + return shortName; + } + + public String getFullName() { + return fullName; + } + + public int getColor() { + return color; + } + + public ALatLon getLocation() { + return location; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(id); + out.writeString(shortName); + out.writeString(fullName); + out.writeInt(color); + out.writeParcelable(location, flags); + } + + private void readFromParcel(Parcel in) { + id = in.readString(); + shortName = in.readString(); + shortName = in.readString(); + color = in.readInt(); + location = in.readParcelable(ALatLon.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.aidl new file mode 100644 index 0000000000..d41d6b69ca --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer.point; + +parcelable AddMapPointParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.java new file mode 100644 index 0000000000..79cb96914c --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/AddMapPointParams.java @@ -0,0 +1,51 @@ +package net.osmand.aidl.maplayer.point; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AddMapPointParams implements Parcelable { + private String layerId; + private AMapPoint point; + + public AddMapPointParams(String layerId, AMapPoint point) { + this.layerId = layerId; + this.point = point; + } + + public AddMapPointParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AddMapPointParams createFromParcel(Parcel in) { + return new AddMapPointParams(in); + } + + public AddMapPointParams[] newArray(int size) { + return new AddMapPointParams[size]; + } + }; + + public String getLayerId() { + return layerId; + } + + public AMapPoint getPoint() { + return point; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(layerId); + out.writeParcelable(point, flags); + } + + private void readFromParcel(Parcel in) { + layerId = in.readString(); + point = in.readParcelable(AMapPoint.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.aidl new file mode 100644 index 0000000000..68a5fdcf11 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer.point; + +parcelable RemoveMapPointParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.java new file mode 100644 index 0000000000..3c7f2105f0 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/RemoveMapPointParams.java @@ -0,0 +1,51 @@ +package net.osmand.aidl.maplayer.point; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveMapPointParams implements Parcelable { + private String layerId; + private String pointId; + + public RemoveMapPointParams(String layerId, String pointId) { + this.layerId = layerId; + this.pointId = pointId; + } + + public RemoveMapPointParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public RemoveMapPointParams createFromParcel(Parcel in) { + return new RemoveMapPointParams(in); + } + + public RemoveMapPointParams[] newArray(int size) { + return new RemoveMapPointParams[size]; + } + }; + + public String getLayerId() { + return layerId; + } + + public String getPointId() { + return pointId; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(layerId); + out.writeString(pointId); + } + + private void readFromParcel(Parcel in) { + layerId = in.readString(); + pointId = in.readString(); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.aidl b/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.aidl new file mode 100644 index 0000000000..d81ea87253 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.maplayer.point; + +parcelable UpdateMapPointParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.java b/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.java new file mode 100644 index 0000000000..013d650622 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/maplayer/point/UpdateMapPointParams.java @@ -0,0 +1,51 @@ +package net.osmand.aidl.maplayer.point; + +import android.os.Parcel; +import android.os.Parcelable; + +public class UpdateMapPointParams implements Parcelable { + private String layerId; + private AMapPoint point; + + public UpdateMapPointParams(String layerId, AMapPoint point) { + this.layerId = layerId; + this.point = point; + } + + public UpdateMapPointParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public UpdateMapPointParams createFromParcel(Parcel in) { + return new UpdateMapPointParams(in); + } + + public UpdateMapPointParams[] newArray(int size) { + return new UpdateMapPointParams[size]; + } + }; + + public String getLayerId() { + return layerId; + } + + public AMapPoint getPoint() { + return point; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(layerId); + out.writeParcelable(point, flags); + } + + private void readFromParcel(Parcel in) { + layerId = in.readString(); + point = in.readParcelable(AMapPoint.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.aidl b/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.aidl new file mode 100644 index 0000000000..4721b1812b --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapmarker; + +parcelable AMapMarker; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.java b/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.java new file mode 100644 index 0000000000..dc6084e680 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/AMapMarker.java @@ -0,0 +1,63 @@ +package net.osmand.aidl.mapmarker; + +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.ALatLon; + +public class AMapMarker implements Parcelable { + + private ALatLon latLon; + private String name; + + public AMapMarker(ALatLon latLon, String name) { + + if (latLon == null) { + throw new IllegalArgumentException("latLon cannot be null"); + } + + if (name == null) { + name = ""; + } + + this.latLon = latLon; + this.name = name; + } + + public AMapMarker(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AMapMarker createFromParcel(Parcel in) { + return new AMapMarker(in); + } + + public AMapMarker[] newArray(int size) { + return new AMapMarker[size]; + } + }; + + public ALatLon getLatLon() { + return latLon; + } + + public String getName() { + return name; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(latLon, flags); + out.writeString(name); + } + + private void readFromParcel(Parcel in) { + latLon = in.readParcelable(ALatLon.class.getClassLoader()); + name = in.readString(); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.aidl b/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.aidl new file mode 100644 index 0000000000..eef370b4e2 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapmarker; + +parcelable AddMapMarkerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.java b/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.java new file mode 100644 index 0000000000..cc707006e4 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/AddMapMarkerParams.java @@ -0,0 +1,44 @@ +package net.osmand.aidl.mapmarker; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AddMapMarkerParams implements Parcelable { + + private AMapMarker marker; + + public AddMapMarkerParams(AMapMarker marker) { + this.marker = marker; + } + + public AddMapMarkerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AddMapMarkerParams createFromParcel(Parcel in) { + return new AddMapMarkerParams(in); + } + + public AddMapMarkerParams[] newArray(int size) { + return new AddMapMarkerParams[size]; + } + }; + + public AMapMarker getMarker() { + return marker; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(marker, flags); + } + + private void readFromParcel(Parcel in) { + marker = in.readParcelable(AMapMarker.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.aidl b/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.aidl new file mode 100644 index 0000000000..e5b5b126ad --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapmarker; + +parcelable RemoveMapMarkerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.java b/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.java new file mode 100644 index 0000000000..08f489922c --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/RemoveMapMarkerParams.java @@ -0,0 +1,44 @@ +package net.osmand.aidl.mapmarker; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveMapMarkerParams implements Parcelable { + + private AMapMarker marker; + + public RemoveMapMarkerParams(AMapMarker marker) { + this.marker = marker; + } + + public RemoveMapMarkerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public RemoveMapMarkerParams createFromParcel(Parcel in) { + return new RemoveMapMarkerParams(in); + } + + public RemoveMapMarkerParams[] newArray(int size) { + return new RemoveMapMarkerParams[size]; + } + }; + + public AMapMarker getMarker() { + return marker; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(marker, flags); + } + + private void readFromParcel(Parcel in) { + marker = in.readParcelable(AMapMarker.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.aidl b/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.aidl new file mode 100644 index 0000000000..2a17fa9369 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapmarker; + +parcelable UpdateMapMarkerParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.java b/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.java new file mode 100644 index 0000000000..d03bc0d7f6 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapmarker/UpdateMapMarkerParams.java @@ -0,0 +1,52 @@ +package net.osmand.aidl.mapmarker; + +import android.os.Parcel; +import android.os.Parcelable; + +public class UpdateMapMarkerParams implements Parcelable { + + private AMapMarker markerPrev; + private AMapMarker markerNew; + + public UpdateMapMarkerParams(AMapMarker markerPrev, AMapMarker markerNew) { + this.markerPrev = markerPrev; + this.markerNew = markerNew; + } + + public UpdateMapMarkerParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public UpdateMapMarkerParams createFromParcel(Parcel in) { + return new UpdateMapMarkerParams(in); + } + + public UpdateMapMarkerParams[] newArray(int size) { + return new UpdateMapMarkerParams[size]; + } + }; + + public AMapMarker getMarkerPrev() { + return markerPrev; + } + + public AMapMarker getMarkerNew() { + return markerNew; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(markerPrev, flags); + out.writeParcelable(markerNew, flags); + } + + private void readFromParcel(Parcel in) { + markerPrev = in.readParcelable(AMapMarker.class.getClassLoader()); + markerNew = in.readParcelable(AMapMarker.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.aidl b/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.aidl new file mode 100644 index 0000000000..7798986483 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapwidget; + +parcelable AMapWidget; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.java b/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.java new file mode 100644 index 0000000000..f6fac08942 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/AMapWidget.java @@ -0,0 +1,110 @@ +package net.osmand.aidl.mapwidget; + +import android.content.Intent; +import android.os.Parcel; +import android.os.Parcelable; + +public class AMapWidget implements Parcelable { + 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 AMapWidget(String id, String menuIconName, String menuTitle, + String lightIconName, String darkIconName, String text, String description, + int order, Intent intentOnClick) { + this.id = id; + this.menuIconName = menuIconName; + this.menuTitle = menuTitle; + this.lightIconName = lightIconName; + this.darkIconName = darkIconName; + this.text = text; + this.description = description; + this.order = order; + this.intentOnClick = intentOnClick; + } + + public AMapWidget(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AMapWidget createFromParcel(Parcel in) { + return new AMapWidget(in); + } + + public AMapWidget[] newArray(int size) { + return new AMapWidget[size]; + } + }; + + 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; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(id); + out.writeString(menuIconName); + out.writeString(menuTitle); + out.writeString(lightIconName); + out.writeString(darkIconName); + out.writeString(text); + out.writeString(description); + out.writeInt(order); + out.writeParcelable(intentOnClick, flags); + } + + private void readFromParcel(Parcel in) { + id = in.readString(); + menuIconName = in.readString(); + menuTitle = in.readString(); + lightIconName = in.readString(); + darkIconName = in.readString(); + text = in.readString(); + description = in.readString(); + order = in.readInt(); + intentOnClick = in.readParcelable(Intent.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.aidl b/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.aidl new file mode 100644 index 0000000000..891d338eb8 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapwidget; + +parcelable AddMapWidgetParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.java b/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.java new file mode 100644 index 0000000000..69b337209e --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/AddMapWidgetParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.mapwidget; + +import android.os.Parcel; +import android.os.Parcelable; + +public class AddMapWidgetParams implements Parcelable { + private AMapWidget widget; + + public AddMapWidgetParams(AMapWidget widget) { + this.widget = widget; + } + + public AddMapWidgetParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public AddMapWidgetParams createFromParcel(Parcel in) { + return new AddMapWidgetParams(in); + } + + public AddMapWidgetParams[] newArray(int size) { + return new AddMapWidgetParams[size]; + } + }; + + public AMapWidget getWidget() { + return widget; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(widget, flags); + } + + private void readFromParcel(Parcel in) { + widget = in.readParcelable(AMapWidget.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.aidl b/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.aidl new file mode 100644 index 0000000000..445b0c994d --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapwidget; + +parcelable RemoveMapWidgetParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.java b/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.java new file mode 100644 index 0000000000..e1433d530c --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/RemoveMapWidgetParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.mapwidget; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveMapWidgetParams implements Parcelable { + private String id; + + public RemoveMapWidgetParams(String id) { + this.id = id; + } + + public RemoveMapWidgetParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public RemoveMapWidgetParams createFromParcel(Parcel in) { + return new RemoveMapWidgetParams(in); + } + + public RemoveMapWidgetParams[] newArray(int size) { + return new RemoveMapWidgetParams[size]; + } + }; + + public String getId() { + return id; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(id); + } + + private void readFromParcel(Parcel in) { + id = in.readString(); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.aidl b/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.aidl new file mode 100644 index 0000000000..b92f94c008 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapwidget; + +parcelable UpdateMapWidgetParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.java b/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.java new file mode 100644 index 0000000000..07114ad16e --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/mapwidget/UpdateMapWidgetParams.java @@ -0,0 +1,43 @@ +package net.osmand.aidl.mapwidget; + +import android.os.Parcel; +import android.os.Parcelable; + +public class UpdateMapWidgetParams implements Parcelable { + private AMapWidget widget; + + public UpdateMapWidgetParams(AMapWidget widget) { + this.widget = widget; + } + + public UpdateMapWidgetParams(Parcel in) { + readFromParcel(in); + } + + public static final Parcelable.Creator CREATOR = new + Parcelable.Creator() { + public UpdateMapWidgetParams createFromParcel(Parcel in) { + return new UpdateMapWidgetParams(in); + } + + public UpdateMapWidgetParams[] newArray(int size) { + return new UpdateMapWidgetParams[size]; + } + }; + + public AMapWidget getWidget() { + return widget; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(widget, flags); + } + + private void readFromParcel(Parcel in) { + widget = in.readParcelable(AMapWidget.class.getClassLoader()); + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 35614a1235..15b3b8f1ca 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -13,6 +13,7 @@ import android.support.v7.app.AlertDialog; import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; +import net.osmand.aidl.OsmandAidlApi; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.map.OsmandRegions; import net.osmand.map.OsmandRegions.RegionTranslation; @@ -363,6 +364,7 @@ public class AppInitializer implements IProgress { app.gpxDatabase = startupInit(new GPXDatabase(app), GPXDatabase.class); app.favorites = startupInit(new FavouritesDbHelper(app), FavouritesDbHelper.class); app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class); + app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class); app.regions = startupInit(new OsmandRegions(), OsmandRegions.class); updateRegionVars(); diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 5a51aae975..4f9e0633cd 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -27,6 +27,8 @@ import android.widget.Toast; import net.osmand.CallbackWithObject; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; +import net.osmand.aidl.OsmandAidlApi; +import net.osmand.aidl.OsmandAidlService; import net.osmand.data.LatLon; import net.osmand.map.OsmandRegions; import net.osmand.map.WorldRegion; @@ -85,7 +87,9 @@ public class OsmandApplication extends MultiDexApplication { Handler uiHandler; NavigationService navigationService; - + + OsmandAidlApi aidlApi; + // start variables ResourceManager resourceManager; OsmAndLocationProvider locationProvider; @@ -449,6 +453,10 @@ public class OsmandApplication extends MultiDexApplication { this.navigationService = navigationService; } + public OsmandAidlApi getAidlApi() { + return aidlApi; + } + public void stopNavigation() { if (locationProvider.getLocationSimulation().isRouteAnimating()) { locationProvider.getLocationSimulation().stop(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 5852ae61d9..b50f6d7555 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -292,6 +292,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven screenOffReceiver = new ScreenOffReceiver(); registerReceiver(screenOffReceiver, filter); + app.getAidlApi().onCreateMapActivity(this); + mIsDestroyed = false; } @@ -964,6 +966,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven protected void onDestroy() { super.onDestroy(); unregisterReceiver(screenOffReceiver); + app.getAidlApi().onDestroyMapActivity(this); FailSafeFuntions.quitRouteRestoreDialog(); OsmandPlugin.onMapActivityDestroy(this); getMyApplication().unsubscribeInitListener(initListener); diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 6ef8af5e99..ceb66670f4 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -82,6 +82,7 @@ public class MapInfoLayer extends OsmandMapLayer { expand = (ImageButton) map.findViewById(R.id.map_collapse_button); // update and create controls registerAllControls(); + map.getMyApplication().getAidlApi().registerWidgetControls(map); recreateControls(); } @@ -92,6 +93,13 @@ public class MapInfoLayer extends OsmandMapLayer { updateReg(calculateTextState(), reg); } + public MapWidgetRegInfo registerSideWidget(TextInfoWidget widget, int drawableMenu, + String message, String key, boolean left, int priorityOrder) { + MapWidgetRegInfo reg = mapInfoControls.registerSideWidgetInternal(widget, drawableMenu, message, key, left, priorityOrder); + updateReg(calculateTextState(), reg); + return reg; + } + public void registerSideWidget(TextInfoWidget widget, WidgetState widgetState, String key, boolean left, int priorityOrder) { MapWidgetRegInfo reg = mapInfoControls.registerSideWidgetInternal(widget, widgetState, key, left, priorityOrder); updateReg(calculateTextState(), reg); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 869db417ac..9e6865f6b0 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -159,6 +159,23 @@ public class MapWidgetRegistry { return ii; } + public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, + @DrawableRes int drawableMenu, + String message, + String key, boolean left, int priorityOrder) { + MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu, + message, priorityOrder, left); + processVisibleModes(key, ii); + if (widget != null) { + widget.setContentTitle(message); + } + if (left) { + this.leftWidgetSet.add(ii); + } else { + this.rightWidgetSet.add(ii); + } + return ii; + } public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, @DrawableRes int drawableMenu, @@ -221,7 +238,7 @@ public class MapWidgetRegistry { return elements != null && elements.contains(key); } - private void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) { + public void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) { ApplicationMode mode = settings.APPLICATION_MODE.get(); defineDefaultSettingsElement(mode); // clear everything @@ -375,6 +392,9 @@ public class MapWidgetRegistry { } public String getText(Context ctx, final ApplicationMode mode, final MapWidgetRegInfo r) { + if (r.getMessage() != null) { + return (r.visibleCollapsed(mode) ? " + " : " ") + r.getMessage(); + } return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.getMessageId()); } @@ -447,7 +467,7 @@ public class MapWidgetRegistry { final boolean selected = r.visibleCollapsed(mode) || r.visible(mode); final String desc = mapActivity.getString(R.string.shared_string_collapse); - contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.getMessageId(), mapActivity) + ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder() .setIcon(r.getDrawableMenu()) .setSelected(selected) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) @@ -519,7 +539,11 @@ public class MapWidgetRegistry { } ContextMenuItem item = adapter.getItem(pos); item.setIcon(r.getDrawableMenu()); - item.setTitle(mapActivity.getResources().getString(r.getMessageId())); + if (r.getMessage() != null) { + item.setTitle(r.getMessage()); + } else { + item.setTitle(mapActivity.getResources().getString(r.getMessageId())); + } adapter.notifyDataSetChanged(); return true; } @@ -555,7 +579,13 @@ public class MapWidgetRegistry { item.setDescription(visible && collapsed ? desc : null); adapter.notifyDataSetChanged(); } - }).createItem()); + }); + if (r.getMessage() != null) { + itemBuilder.setTitle(r.getMessage()); + } else { + itemBuilder.setTitleId(r.getMessageId(), mapActivity); + } + contextMenuAdapter.addItem(itemBuilder.createItem()); } } @@ -566,6 +596,7 @@ public class MapWidgetRegistry { private int drawableMenu; @StringRes private int messageId; + private String message; private WidgetState widgetState; public final String key; public final boolean left; @@ -584,6 +615,16 @@ public class MapWidgetRegistry { this.left = left; } + public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu, + String message, int priorityOrder, boolean left) { + this.key = key; + this.widget = widget; + this.drawableMenu = drawableMenu; + this.message = message; + this.priorityOrder = priorityOrder; + this.left = left; + } + public MapWidgetRegInfo(String key, TextInfoWidget widget, WidgetState widgetState, int priorityOrder, boolean left) { this.key = key; @@ -601,6 +642,10 @@ public class MapWidgetRegistry { } } + public String getMessage() { + return message; + } + public int getMessageId() { if (widgetState != null) { return widgetState.getMenuTitleId(); @@ -667,6 +712,9 @@ public class MapWidgetRegistry { @Override public int hashCode() { + if (getMessage() != null) { + return getMessage().hashCode(); + } return getMessageId(); } @@ -680,16 +728,27 @@ public class MapWidgetRegistry { return false; } MapWidgetRegInfo other = (MapWidgetRegInfo) obj; + if (getMessageId() == 0 && other.getMessageId() == 0) { + return key.equals(other.key); + } return getMessageId() == other.getMessageId(); } @Override public int compareTo(@NonNull MapWidgetRegInfo another) { - if (getMessageId() == another.getMessageId()) { + if (getMessageId() == 0 && another.getMessageId() == 0) { + if (key.equals(another.key)) { + return 0; + } + } else if (getMessageId() == another.getMessageId()) { return 0; } if (priorityOrder == another.priorityOrder) { - return getMessageId() - another.getMessageId(); + if (getMessageId() == 0 && another.getMessageId() == 0) { + return key.compareTo(key); + } else { + return getMessageId() - another.getMessageId(); + } } return priorityOrder - another.priorityOrder; }