Merge pull request #6842 from osmandapp/aidl_new_method
Aidl new method
This commit is contained in:
commit
64b7b3198c
12 changed files with 954 additions and 30 deletions
37
OsmAnd/src/net/osmand/aidl/AidlCallbackListener.java
Normal file
37
OsmAnd/src/net/osmand/aidl/AidlCallbackListener.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package net.osmand.aidl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AidlCallbackListener {
|
||||
|
||||
/**
|
||||
* 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, OsmandAidlService.AidlCallbackParams> getAidlCallbacks();
|
||||
|
||||
}
|
|
@ -2,13 +2,38 @@ package net.osmand.aidl;
|
|||
|
||||
import net.osmand.aidl.search.SearchResult;
|
||||
import net.osmand.aidl.gpx.AGpxBitmap;
|
||||
import net.osmand.aidl.navigation.ADirectionInfo;
|
||||
|
||||
interface IOsmAndAidlCallback {
|
||||
|
||||
/**
|
||||
* Callback for search requests.
|
||||
*
|
||||
* @return resultSet - set of SearchResult
|
||||
*/
|
||||
void onSearchComplete(in List<SearchResult> resultSet);
|
||||
|
||||
|
||||
/**
|
||||
* Callback for {@link IOsmAndAidlInterface} registerForUpdates() method.
|
||||
*/
|
||||
void onUpdate();
|
||||
|
||||
/**
|
||||
* Callback for {@link IOsmAndAidlInterface} registerForOsmandInitListener() method.
|
||||
*/
|
||||
void onAppInitialized();
|
||||
|
||||
/**
|
||||
* Callback for {@link IOsmAndAidlInterface} getBitmapForGpx() method.
|
||||
*
|
||||
* @return bitmap - snapshot image of gpx track on map
|
||||
*/
|
||||
void onGpxBitmapCreated(in AGpxBitmap bitmap);
|
||||
|
||||
/**
|
||||
* Callback for {@link IOsmAndAidlInterface} registerForNavigationUpdates() method.
|
||||
*
|
||||
* @return directionInfo - update on distance to next turn and turns type.
|
||||
*/
|
||||
void updateNavigationInfo(in ADirectionInfo directionInfo);
|
||||
}
|
|
@ -81,105 +81,614 @@ import net.osmand.aidl.tiles.ASqliteDbFile;
|
|||
import net.osmand.aidl.plugins.PluginParams;
|
||||
import net.osmand.aidl.copyfile.CopyFileParams;
|
||||
|
||||
|
||||
import net.osmand.aidl.navigation.ANavigationUpdateParams;
|
||||
|
||||
|
||||
// NOTE: Add new methods at the end of file!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
||||
/**
|
||||
* Add map marker at given location.
|
||||
*
|
||||
* @param lat (double) - latitude.
|
||||
* @param lon (double) - longitude.
|
||||
* @param name (String)- name of marker.
|
||||
*/
|
||||
boolean addMapMarker(in AddMapMarkerParams params);
|
||||
|
||||
/**
|
||||
* Add map marker at given location.
|
||||
*
|
||||
* @param lat (double) - latitude.
|
||||
* @param lon (double) - longitude.
|
||||
* @param name (String)- name of marker.
|
||||
*/
|
||||
boolean removeMapMarker(in RemoveMapMarkerParams params);
|
||||
|
||||
/**
|
||||
* Update map marker at given location with name.
|
||||
*
|
||||
* @param latPrev (double) - latitude (current marker).
|
||||
* @param lonPrev (double) - longitude (current marker).
|
||||
* @param namePrev (String) - name (current marker).
|
||||
* @param latNew (double) - latitude (new marker).
|
||||
* @param lonNew (double) - longitude (new marker).
|
||||
* @param nameNew (String) - name (new marker).
|
||||
*/
|
||||
boolean updateMapMarker(in UpdateMapMarkerParams params);
|
||||
|
||||
/**
|
||||
* Add map widget to the right side of the main screen.
|
||||
* Note: any specified icon should exist in OsmAnd app resources.
|
||||
*
|
||||
* @param id (String) - widget id.
|
||||
* @param menuIconName (String) - icon name (configure map menu).
|
||||
* @param menuTitle (String) - widget name (configure map menu).
|
||||
* @param lightIconName (String) - icon name for the light theme (widget).
|
||||
* @param darkIconName (String) - icon name for the dark theme (widget).
|
||||
* @param text (String) - main widget text.
|
||||
* @param description (String) - sub text, like "km/h".
|
||||
* @param order (int) - order position in the widgets list.
|
||||
* @param intentOnClick (String) - onClick intent. Called after click on widget as startActivity(Intent intent).
|
||||
*/
|
||||
boolean addMapWidget(in AddMapWidgetParams params);
|
||||
|
||||
/**
|
||||
* Remove map widget.
|
||||
*
|
||||
* @param (String) id - widget id.
|
||||
*/
|
||||
boolean removeMapWidget(in RemoveMapWidgetParams params);
|
||||
|
||||
/**
|
||||
* Update map widget.
|
||||
* Note: any specified icon should exist in OsmAnd app resources.
|
||||
*
|
||||
* @param id (String) - widget id.
|
||||
* @param menuIconName (String) - icon name (configure map menu).
|
||||
* @param menuTitle (String) - widget name (configure map menu).
|
||||
* @param lightIconName (String) - icon name for the light theme (widget).
|
||||
* @param darkIconName (String) - icon name for the dark theme (widget).
|
||||
* @param text (String) - main widget text.
|
||||
* @param description (String) - sub text, like "km/h".
|
||||
* @param order (int) - order position in the widgets list.
|
||||
* @param intentOnClick (String) - onClick intent. Called after click on widget as startActivity(Intent intent).
|
||||
*/
|
||||
boolean updateMapWidget(in UpdateMapWidgetParams params);
|
||||
|
||||
/**
|
||||
* Add point to user layer.
|
||||
*
|
||||
* @param layerId (String) - layer id. Note: layer should be added first.
|
||||
* @param pointId (String) - point id.
|
||||
* @param shortName (String) - short name (single char). Displayed on the map.
|
||||
* @param fullName (String) - full name. Displayed in the context menu on first row.
|
||||
* @param typeName (String) - type name. Displayed in context menu on second row.
|
||||
* @param color (int) - color of circle's background.
|
||||
* @param location (ALatLon) - location of the point.
|
||||
* @param details (List<String>)- list of details. Displayed under context menu.
|
||||
* @param params (Map<String, String>) - optional map of params for point.
|
||||
*/
|
||||
boolean addMapPoint(in AddMapPointParams params);
|
||||
|
||||
|
||||
/**
|
||||
* Remove point.
|
||||
*
|
||||
* @param layerId (String) - layer id.
|
||||
* @param pointId (String) - point id.
|
||||
*/
|
||||
boolean removeMapPoint(in RemoveMapPointParams params);
|
||||
|
||||
/**
|
||||
* Update point.
|
||||
*
|
||||
* @param layerId (String) - layer id.
|
||||
* @param pointId (String) - point id.
|
||||
* @param shortName (String) - short name (single char). Displayed on the map.
|
||||
* @param fullName (String) - full name. Displayed in the context menu on first row.
|
||||
* @param typeName (String) - type name. Displayed in context menu on second row.
|
||||
* @param color (String) - color of circle's background.
|
||||
* @param location (ALatLon)- location of the point.
|
||||
* @param details (List<String>) - list of details. Displayed under context menu.
|
||||
* @param params (Map<String, String>) - optional map of params for point.
|
||||
*/
|
||||
boolean updateMapPoint(in UpdateMapPointParams params);
|
||||
|
||||
/**
|
||||
* Add user layer on the map.
|
||||
*
|
||||
* @param id (String) - layer id.
|
||||
* @param name (String) - layer name.
|
||||
* @param zOrder (float) - z-order position of layer. Default value is 5.5f
|
||||
* @param points Map<Sting, AMapPoint> - initial list of points. Nullable.
|
||||
* @param imagePoints (boolean) - use new style for points on map or not. Also default zoom bounds for new style can be edited.
|
||||
*/
|
||||
boolean addMapLayer(in AddMapLayerParams params);
|
||||
|
||||
/**
|
||||
* Remove user layer.
|
||||
*
|
||||
* @param id (String) - layer id.
|
||||
*/
|
||||
boolean removeMapLayer(in RemoveMapLayerParams params);
|
||||
|
||||
/**
|
||||
* Update user layer.
|
||||
*
|
||||
* @param id (String) - layer id.
|
||||
* @param name (String) - layer name.
|
||||
* @param zOrder (float) - z-order position of layer. Default value is 5.5f
|
||||
* @param points Map<Sting, AMapPoint> - list of points. Nullable.
|
||||
* @param imagePoints (boolean) - use new style for points on map or not. Also default zoom bounds for new style can be edited.
|
||||
*/
|
||||
boolean updateMapLayer(in UpdateMapLayerParams params);
|
||||
|
||||
boolean importGpx(in ImportGpxParams params);
|
||||
boolean showGpx(in ShowGpxParams params);
|
||||
boolean hideGpx(in HideGpxParams params);
|
||||
boolean getActiveGpx(out List<ASelectedGpxFile> files);
|
||||
/**
|
||||
* Import GPX file to OsmAnd (from URI or file).
|
||||
*
|
||||
* @param gpxUri (Uri) - URI created by FileProvider (preferable method).
|
||||
* @param file (File) - File which represents GPX track (not recomended, OsmAnd should have rights to access file location).
|
||||
* @param fileName (String) - Destination file name. May contain dirs.
|
||||
* @param color (String) - color of gpx. Can be one of: "red", "orange", "lightblue", "blue", "purple",
|
||||
* "translucent_red", "translucent_orange", "translucent_lightblue",
|
||||
* "translucent_blue", "translucent_purple"
|
||||
* @param show (boolean) - show track on the map after import
|
||||
*/
|
||||
boolean importGpx(in ImportGpxParams params);
|
||||
|
||||
/**
|
||||
* Show GPX file on map.
|
||||
*
|
||||
* @param fileName (String) - file name to show. Must be imported first.
|
||||
*/
|
||||
boolean showGpx(in ShowGpxParams params);
|
||||
|
||||
/**
|
||||
* Hide GPX file.
|
||||
*
|
||||
* @param fileName (String) - file name to hide.
|
||||
*/
|
||||
boolean hideGpx(in HideGpxParams params);
|
||||
|
||||
/**
|
||||
* Get list of active GPX files.
|
||||
*
|
||||
* @return list of active gpx files.
|
||||
*/
|
||||
boolean getActiveGpx(out List<ASelectedGpxFile> files);
|
||||
|
||||
/**
|
||||
* Set map view to current location.
|
||||
*
|
||||
* @param latitude (double) - latitude of new map center.
|
||||
* @param longitude (double) - longitude of new map center.
|
||||
* @param zoom (float) - map zoom level. Set 0 to keep zoom unchanged.
|
||||
* @param animated (boolean) - set true to animate changes.
|
||||
*/
|
||||
boolean setMapLocation(in SetMapLocationParams params);
|
||||
|
||||
|
||||
boolean setMapLocation(in SetMapLocationParams params);
|
||||
boolean calculateRoute(in CalculateRouteParams params);
|
||||
|
||||
/**
|
||||
* Refresh the map (UI)
|
||||
*/
|
||||
boolean refreshMap();
|
||||
|
||||
/**
|
||||
* Add favorite group with given params.
|
||||
*
|
||||
* @param name (String) - group name.
|
||||
* @param color (String) - group color. Can be one of: "red", "orange", "yellow",
|
||||
* "lightgreen", "green", "lightblue", "blue", "purple", "pink", "brown".
|
||||
* @param visible (boolean) - group visibility.
|
||||
*/
|
||||
boolean addFavoriteGroup(in AddFavoriteGroupParams params);
|
||||
|
||||
/**
|
||||
* Update favorite group with given params.
|
||||
*
|
||||
* @param namePrev (String) - group name (current).
|
||||
* @param colorPrev (String) - group color (current).
|
||||
* @param visiblePrev (boolean) - group visibility (current).
|
||||
* @param nameNew (String) - group name (new).
|
||||
* @param colorNew (String) - group color (new).
|
||||
* @param visibleNew (boolean) - group visibility (new).
|
||||
*/
|
||||
boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params);
|
||||
|
||||
/**
|
||||
* Remove favorite group with given name.
|
||||
*
|
||||
* @param name (String) - name of favorite group.
|
||||
*/
|
||||
boolean updateFavoriteGroup(in UpdateFavoriteGroupParams params);
|
||||
|
||||
/**
|
||||
* Add favorite at given location with given params.
|
||||
*
|
||||
* @param lat (double) - latitude.
|
||||
* @param lon (double) - longitude.
|
||||
* @param name (String) - name of favorite item.
|
||||
* @param description (String) - description of favorite item.
|
||||
* @param category (String) - category of favorite item.
|
||||
* @param color (String) - color of favorite item. Can be one of: "red", "orange", "yellow",
|
||||
* "lightgreen", "green", "lightblue", "blue", "purple", "pink", "brown".
|
||||
* @param visible (boolean) - should favorite item be visible after creation.
|
||||
*/
|
||||
boolean addFavorite(in AddFavoriteParams params);
|
||||
|
||||
/**
|
||||
* Update favorite at given location with given params.
|
||||
*
|
||||
* @param latPrev (double) - latitude (current favorite).
|
||||
* @param lonPrev (double) - longitude (current favorite).
|
||||
* @param namePrev (String) - name of favorite item (current favorite).
|
||||
* @param categoryPrev (String) - category of favorite item (current favorite).
|
||||
* @param latNew (double) - latitude (new favorite).
|
||||
* @param lonNew (double) - longitude (new favorite).
|
||||
* @param nameNew (String) - name of favorite item (new favorite).
|
||||
* @param descriptionNew (String) - description of favorite item (new favorite).
|
||||
* @param categoryNew (String) - category of favorite item (new favorite). Use only to create a new category,
|
||||
* not to update an existing one. If you want to update an existing category,
|
||||
* use the {@link #updateFavoriteGroup(String, String, boolean, String, String, boolean)} method.
|
||||
* @param colorNew (String) - color of new category. Can be one of: "red", "orange", "yellow",
|
||||
* "lightgreen", "green", "lightblue", "blue", "purple", "pink", "brown".
|
||||
* @param visibleNew (boolean) - should new category be visible after creation.
|
||||
*/
|
||||
boolean removeFavorite(in RemoveFavoriteParams params);
|
||||
|
||||
/**
|
||||
* Remove favorite at given location with given params.
|
||||
*
|
||||
* @param lat (double) - latitude.
|
||||
* @param lon (double) - longitude.
|
||||
* @param name (String) - name of favorite item.
|
||||
* @param category (String) - category of favorite item.
|
||||
*/
|
||||
boolean updateFavorite(in UpdateFavoriteParams params);
|
||||
|
||||
/**
|
||||
* Start gpx recording.
|
||||
*/
|
||||
boolean startGpxRecording(in StartGpxRecordingParams params);
|
||||
|
||||
/**
|
||||
* Stop gpx recording.
|
||||
*/
|
||||
boolean stopGpxRecording(in StopGpxRecordingParams params);
|
||||
|
||||
/**
|
||||
* Take photo note.
|
||||
*
|
||||
* @param lat (double) - latutude of photo note.
|
||||
* @param lon (double) - longitude of photo note.
|
||||
*/
|
||||
boolean takePhotoNote(in TakePhotoNoteParams params);
|
||||
|
||||
/**
|
||||
* Start video note recording.
|
||||
*
|
||||
* @param lat (double) - latutude of video note point.
|
||||
* @param lon (double) - longitude of video note point.
|
||||
*/
|
||||
boolean startVideoRecording(in StartVideoRecordingParams params);
|
||||
|
||||
/**
|
||||
* Start audio note recording.
|
||||
*
|
||||
* @param lat (double) - latutude of audio note point.
|
||||
* @param lon (double) - longitude of audio note point.
|
||||
*/
|
||||
boolean startAudioRecording(in StartAudioRecordingParams params);
|
||||
|
||||
/**
|
||||
* Stop Audio/Video recording.
|
||||
*/
|
||||
boolean stopRecording(in StopRecordingParams params);
|
||||
|
||||
/**
|
||||
* Start navigation.
|
||||
*
|
||||
* @param startName (String) - name of the start point as it displays in OsmAnd's UI. Nullable.
|
||||
* @param startLat (double) - latitude of the start point. If 0 - current location is used.
|
||||
* @param startLon (double) - longitude of the start point. If 0 - current location is used.
|
||||
* @param destName (String) - name of the start point as it displays in OsmAnd's UI.
|
||||
* @param destLat (double) - latitude of a destination point.
|
||||
* @param destLon (double) - longitude of a destination point.
|
||||
* @param profile (String) - One of: "default", "car", "bicycle", "pedestrian", "aircraft", "boat", "hiking", "motorcycle", "truck". Nullable (default).
|
||||
* @param force (boolean) - ask to stop current navigation if any. False - ask. True - don't ask.
|
||||
*/
|
||||
boolean navigate(in NavigateParams params);
|
||||
|
||||
/**
|
||||
* Start navigation using gpx file. User need to grant Uri permission to OsmAnd.
|
||||
*
|
||||
* @param gpxUri (Uri) - URI created by FileProvider.
|
||||
* @param force (boolean) - ask to stop current navigation if any. False - ask. True - don't ask.
|
||||
*/
|
||||
boolean navigateGpx(in NavigateGpxParams params);
|
||||
|
||||
/**
|
||||
* Remove GPX file.
|
||||
*
|
||||
* @param fileName (String) - file name to remove;
|
||||
*/
|
||||
boolean removeGpx(in RemoveGpxParams params);
|
||||
|
||||
|
||||
/**
|
||||
* Show AMapPoint on map in OsmAnd.
|
||||
*
|
||||
* @param layerId (String) - layer id. Note: layer should be added first.
|
||||
* @param pointId (String) - point id.
|
||||
* @param shortName (String) - short name (single char). Displayed on the map.
|
||||
* @param fullName (String) - full name. Displayed in the context menu on first row.
|
||||
* @param typeName (String) - type name. Displayed in context menu on second row.
|
||||
* @param color (int) - color of circle's background.
|
||||
* @param location (ALatLon) - location of the point.
|
||||
* @param details List<String> - list of details. Displayed under context menu.
|
||||
* @param params Map<String, String> - optional map of params for point.
|
||||
*/
|
||||
boolean showMapPoint(in ShowMapPointParams params);
|
||||
|
||||
/**
|
||||
* Method for adding up to 3 items to the OsmAnd navigation drawer.
|
||||
*
|
||||
* @param appPackage - current application package.
|
||||
* @param names - list of names for items.
|
||||
* @param uris - list of uris for intents.
|
||||
* @param iconNames - list of icon names for items.
|
||||
* @param flags - list of flags for intents. Use -1 if no flags needed.
|
||||
*/
|
||||
boolean setNavDrawerItems(in SetNavDrawerItemsParams params);
|
||||
|
||||
/**
|
||||
* Put navigation on pause.
|
||||
*/
|
||||
boolean pauseNavigation(in PauseNavigationParams params);
|
||||
|
||||
/**
|
||||
* Resume navigation if it was paused before.
|
||||
*/
|
||||
boolean resumeNavigation(in ResumeNavigationParams params);
|
||||
|
||||
/**
|
||||
* Stop navigation. Removes target / intermediate points and route path from the map.
|
||||
*/
|
||||
boolean stopNavigation(in StopNavigationParams params);
|
||||
|
||||
|
||||
/**
|
||||
* Mute voice guidance. Stays muted until unmute manually or via the api.
|
||||
*/
|
||||
boolean muteNavigation(in MuteNavigationParams params);
|
||||
|
||||
/**
|
||||
* Unmute voice guidance.
|
||||
*/
|
||||
boolean unmuteNavigation(in UnmuteNavigationParams params);
|
||||
|
||||
/**
|
||||
* Run search for POI / Address.
|
||||
*
|
||||
* @param searchQuery (String) - search query string.
|
||||
* @param searchType (int) - type of search. Values:
|
||||
* SearchParams.SEARCH_TYPE_ALL - all kind of search
|
||||
* SearchParams.SEARCH_TYPE_POI - POIs only
|
||||
* SearchParams.SEARCH_TYPE_ADDRESS - addresses only
|
||||
*
|
||||
* @param latitude (double) - latitude of original search location.
|
||||
* @param longitude (double) - longitude of original search location.
|
||||
* @param radiusLevel (int) - value from 1 to 7. Default value = 1.
|
||||
* @param totalLimit (int) - limit of returned search result rows. Default value = -1 (unlimited).
|
||||
*/
|
||||
boolean search(in SearchParams params, IOsmAndAidlCallback callback);
|
||||
|
||||
/**
|
||||
* Do search and start navigation.
|
||||
*
|
||||
* @param startName (String) - name of the start point as it displays in OsmAnd's UI. Nullable.
|
||||
* @param startLat (double) - latitude of the start point. If 0 - current location is used.
|
||||
* @param startLon (double) - longitude of the start point. If 0 - current location is used.
|
||||
* @param searchQuery (String) - Text of a query for searching a destination point. Sent as URI parameter.
|
||||
* @param searchLat (double) - original location of search (latitude). Sent as URI parameter.
|
||||
* @param searchLon (double) - original location of search (longitude). Sent as URI parameter.
|
||||
* @param profile (String) - one of: "default", "car", "bicycle", "pedestrian", "aircraft", "boat", "hiking", "motorcycle", "truck". Nullable (default).
|
||||
* @param force (boolean) - ask to stop current navigation if any. False - ask. True - don't ask.
|
||||
*/
|
||||
boolean navigateSearch(in NavigateSearchParams params);
|
||||
|
||||
/**
|
||||
* Method to register for periodical callbacks from OsmAnd
|
||||
*
|
||||
* @param updateTimeMS (long)- period of time in millisecond after which callback is triggered
|
||||
* @param callback (IOsmAndCallback)- create and provide instance of {@link IOsmAndAidlCallback} interface
|
||||
* @return id (long) - id of callback in OsmAnd. Needed to unsubscribe from updates.
|
||||
*/
|
||||
long registerForUpdates(in long updateTimeMS, IOsmAndAidlCallback callback);
|
||||
|
||||
/**
|
||||
* Method to unregister from periodical callbacks from OsmAnd
|
||||
*
|
||||
* @param callbackId (long)- id of registered callback (provided by OsmAnd
|
||||
* in {@link OsmAndAidlHelper#registerForUpdates(long, IOsmAndAidlCallback)})
|
||||
*/
|
||||
boolean unregisterFromUpdates(in long callbackId);
|
||||
|
||||
/**
|
||||
* Method for adding image to the top of Osmand's NavDrawer.
|
||||
*
|
||||
* @param imageUri (String)- image's URI.toString
|
||||
*
|
||||
* @deprecated
|
||||
* Use the {@link #setNavDrawerLogoWithParams(NavDrawerHeaderParams params)} method.
|
||||
*/
|
||||
boolean setNavDrawerLogo(in String imageUri);
|
||||
|
||||
/**
|
||||
* Method for selected UI elements (like QuickSearch button) to show.
|
||||
*
|
||||
* @param ids (List<String>)- list of menu items keys from {@link OsmAndCustomizationConstants}
|
||||
*/
|
||||
boolean setEnabledIds(in List<String> ids);
|
||||
|
||||
/**
|
||||
* Method for selected UI elements (like QuickSearch button) to hide.
|
||||
*
|
||||
* @param ids (List<String>)- list of menu items keys from {@link OsmAndCustomizationConstants}
|
||||
*/
|
||||
boolean setDisabledIds(in List<String> ids);
|
||||
|
||||
/**
|
||||
* Method to show selected NavDrawer's menu items.
|
||||
*
|
||||
* @param patterns (List<String>) - list of menu items names from {@link OsmAndCustomizationConstants}
|
||||
*/
|
||||
boolean setEnabledPatterns(in List<String> patterns);
|
||||
|
||||
/**
|
||||
* Method to hide selected NavDrawer's menu items.
|
||||
*
|
||||
* @param patterns (List<String>)- list of menu items names from {@link OsmAndCustomizationConstants}
|
||||
*/
|
||||
boolean setDisabledPatterns(in List<String> patterns);
|
||||
|
||||
/**
|
||||
* Register OsmAnd widgets for visibility.
|
||||
*
|
||||
* @param widgetKey ()- widget id.
|
||||
* @param appModKeys - list of OsmAnd Application modes widget active with. Could be "null" for all modes.
|
||||
*/
|
||||
boolean regWidgetVisibility(in SetWidgetsParams params);
|
||||
|
||||
/**
|
||||
* Register OsmAnd widgets for availability.
|
||||
*
|
||||
* @param widgetKey (String) - widget id.
|
||||
* @param appModKeys (List<String>)- ist of OsmAnd Application modes widget active with. Could be "null" for all modes.
|
||||
*/
|
||||
boolean regWidgetAvailability(in SetWidgetsParams params);
|
||||
|
||||
/**
|
||||
* Add custom parameters for OsmAnd settings to associate with client app.
|
||||
*
|
||||
* @param sharedPreferencesName (String)- string with name of clint's app for shared preferences key
|
||||
* @param bundle (Bundle)- bundle with keys from Settings IDs {@link OsmAndCustomizationConstants} and Settings params
|
||||
*/
|
||||
boolean customizeOsmandSettings(in OsmandSettingsParams params);
|
||||
|
||||
/**
|
||||
* Method to get list of gpx files currently registered (imported or created) in OsmAnd;
|
||||
*
|
||||
* @return list of gpx files
|
||||
*/
|
||||
boolean getImportedGpx(out List<AGpxFile> files);
|
||||
|
||||
/**
|
||||
* Method to get list of sqlitedb files registered in OsmAnd;
|
||||
*
|
||||
* @return list of sqlitedb files
|
||||
*/
|
||||
boolean getSqliteDbFiles(out List<ASqliteDbFile> files);
|
||||
|
||||
/**
|
||||
* Method to get list of currently active sqlitedb files
|
||||
*
|
||||
* @return list of sqlitedb files
|
||||
*/
|
||||
boolean getActiveSqliteDbFiles(out List<ASqliteDbFile> files);
|
||||
|
||||
/**
|
||||
* Method to show selected sqlitedb file as map overlay.
|
||||
*
|
||||
* @param fileName (String) - name of sqlitedb file
|
||||
*/
|
||||
boolean showSqliteDbFile(String fileName);
|
||||
|
||||
/**
|
||||
* Method to hide sqlitedb file from map overlay.
|
||||
*
|
||||
* @param fileName (String) - name of sqlitedb file
|
||||
*/
|
||||
boolean hideSqliteDbFile(String fileName);
|
||||
|
||||
/**
|
||||
* Method for adding image to the top of OsmAnd's NavDrawer with additional params
|
||||
*
|
||||
* @param imageUri (String) - image's URI.toString
|
||||
* @param packageName (String) - client's app package name
|
||||
* @param intent (String) - intent for additional functionality on image click
|
||||
*
|
||||
*/
|
||||
boolean setNavDrawerLogoWithParams(in NavDrawerHeaderParams params);
|
||||
|
||||
/**
|
||||
* Method for adding functionality to "Powered by Osmand" logo in NavDrawer's footer
|
||||
* (reset OsmAnd settings to pre-clinet app's state)
|
||||
*
|
||||
* @param packageName (String) - package name
|
||||
* @param intent (String) - intent
|
||||
* @param appName (String) - client's app name
|
||||
*/
|
||||
boolean setNavDrawerFooterWithParams(in NavDrawerFooterParams params);
|
||||
|
||||
/**
|
||||
* Restore default (pre-client) OsmAnd settings and state:
|
||||
* clears features, widgets and settings customization, NavDraw logo.
|
||||
*/
|
||||
boolean restoreOsmand();
|
||||
|
||||
/**
|
||||
* Method to change state of plug-ins in OsmAnd.
|
||||
*
|
||||
* @param pluginId (String) - id (name) of plugin.
|
||||
* @param newState (int) - new state (0 - off, 1 - on).
|
||||
*/
|
||||
boolean changePluginState(in PluginParams params);
|
||||
|
||||
/**
|
||||
* Method to register for callback on OsmAnd initialization
|
||||
* @param callback (IOsmAndAidlCallback) - create and provide instance of {@link IOsmAndAidlCallback} interface
|
||||
*/
|
||||
boolean registerForOsmandInitListener(in IOsmAndAidlCallback callback);
|
||||
|
||||
/**
|
||||
* Requests bitmap snap-shot of map with GPX file from provided URI in its center.
|
||||
* You can set bitmap size, density and GPX lines color, but you need
|
||||
* to manually download appropriate map in OsmAnd or background will be empty.
|
||||
* Bitmap will be returned through callback {@link IOsmAndAidlCallback#onGpxBitmapCreated(AGpxBitmap)}
|
||||
*
|
||||
* @param gpxUri (Uri/File) - Uri for gpx file
|
||||
* @param density (float) - image density. Recommended to use default metrics for device's display.
|
||||
* @param widthPixels (int) - width of bitmap
|
||||
* @param heightPixels (int) - height of bitmap
|
||||
* @param color (int) - color in ARGB format
|
||||
* @param callback (IOsmAndAidlCallback) - instance of callback from OsmAnd.
|
||||
*/
|
||||
boolean getBitmapForGpx(in CreateGpxBitmapParams file, IOsmAndAidlCallback callback);
|
||||
|
||||
/**
|
||||
* Method to copy files to OsmAnd part by part. For now supports only sqlitedb format.
|
||||
* Part size (bytearray) should not exceed 256k.
|
||||
*
|
||||
* @param fileName (String) - name of file
|
||||
* @param filePartData (byte[]) - parts of file, byte[] with size 256k or less.
|
||||
* @param startTime (long) - timestamp of copying start.
|
||||
* @param isDone (boolean) - boolean to mark end of copying.
|
||||
* @return number of last successfully received file part or error(-1).
|
||||
*/
|
||||
int copyFile(in CopyFileParams filePart);
|
||||
|
||||
|
||||
/**
|
||||
* Method to register for updates during navgation. Notifies user about distance to the next turn and its type.
|
||||
*
|
||||
* @params subscribeToUpdates (boolean) - boolean flag to subscribe or unsubscribe from updates
|
||||
* @params callbackId (long) - id of callback, needed to unsubscribe from updates
|
||||
* @params callback (IOsmAndAidlCallback) - callback to notify user on navigation data change
|
||||
*/
|
||||
long registerForNavigationUpdates(in ANavigationUpdateParams params, IOsmAndAidlCallback callback);
|
||||
}
|
|
@ -42,6 +42,7 @@ import net.osmand.aidl.maplayer.point.AMapPoint;
|
|||
import net.osmand.aidl.mapmarker.AMapMarker;
|
||||
import net.osmand.aidl.mapwidget.AMapWidget;
|
||||
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||
import net.osmand.aidl.navigation.ADirectionInfo;
|
||||
import net.osmand.aidl.plugins.PluginParams;
|
||||
import net.osmand.aidl.search.SearchResult;
|
||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||
|
@ -75,6 +76,8 @@ import net.osmand.plus.helpers.ExternalApiHelper;
|
|||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.routing.IRoutingDataUpdateListener;
|
||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.AidlMapLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
|
@ -83,6 +86,7 @@ import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
|||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -117,9 +121,13 @@ import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_PART_SIZE_LIMIT_ERRO
|
|||
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
||||
import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
||||
import static net.osmand.aidl.OsmandAidlConstants.OK_RESPONSE;
|
||||
import static net.osmand.aidl.OsmandAidlService.KEY_ON_NAV_DATA_UPDATE;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME;
|
||||
|
||||
public class OsmandAidlApi {
|
||||
|
||||
AidlCallbackListener aidlCallbackListener = null;
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlApi.class);
|
||||
private static final String AIDL_REFRESH_MAP = "aidl_refresh_map";
|
||||
private static final String AIDL_SET_MAP_LOCATION = "aidl_set_map_location";
|
||||
|
@ -1918,7 +1926,50 @@ public class OsmandAidlApi {
|
|||
return app.getAppCustomization().changePluginStatus(params);
|
||||
}
|
||||
|
||||
boolean getBitmapForGpx(final Uri gpxUri, final float density, final int widthPixels, final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) {
|
||||
private Map<Long, IRoutingDataUpdateListener> navUpdateCallbacks = new ConcurrentHashMap<>();
|
||||
|
||||
void registerForNavigationUpdates(long id) {
|
||||
final ADirectionInfo directionInfo = new ADirectionInfo(-1, -1, false);
|
||||
final NextDirectionInfo baseNdi = new NextDirectionInfo();
|
||||
IRoutingDataUpdateListener listener = new IRoutingDataUpdateListener() {
|
||||
@Override
|
||||
public void onRoutingDataUpdate() {
|
||||
RoutingHelper rh = app.getRoutingHelper();
|
||||
if (rh.isDeviatedFromRoute()) {
|
||||
directionInfo.setTurnType(TurnType.OFFR);
|
||||
directionInfo.setDistanceTo((int) rh.getRouteDeviation());
|
||||
} else {
|
||||
NextDirectionInfo ndi = rh.getNextRouteDirectionInfo(baseNdi, true);
|
||||
if (ndi != null && ndi.distanceTo > 0 && ndi.directionInfo != null) {
|
||||
directionInfo.setDistanceTo(ndi.distanceTo);
|
||||
directionInfo.setTurnType(ndi.directionInfo.getTurnType().getValue());
|
||||
}
|
||||
}
|
||||
if (aidlCallbackListener != null) {
|
||||
for (OsmandAidlService.AidlCallbackParams cb : aidlCallbackListener.getAidlCallbacks().values()) {
|
||||
if (!aidlCallbackListener.getAidlCallbacks().isEmpty() && (cb.getKey() & KEY_ON_NAV_DATA_UPDATE) > 0) {
|
||||
try {
|
||||
cb.getCallback().updateNavigationInfo(directionInfo);
|
||||
} catch (Exception e) {
|
||||
LOG.debug(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
navUpdateCallbacks.put(id, listener);
|
||||
app.getRoutingHelper().addRouteDataListener(listener);
|
||||
}
|
||||
|
||||
public void unregisterFromUpdates(long id) {
|
||||
app.getRoutingHelper().removeRouteDataListener(navUpdateCallbacks.get(id));
|
||||
navUpdateCallbacks.remove(id);
|
||||
}
|
||||
|
||||
|
||||
boolean getBitmapForGpx(final Uri gpxUri, final float density, final int widthPixels,
|
||||
final int heightPixels, final int color, final GpxBitmapCreatedCallback callback) {
|
||||
if (gpxUri == null || callback == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1976,6 +2027,7 @@ public class OsmandAidlApi {
|
|||
|
||||
private Map<String, FileCopyInfo> copyFilesCache = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
private class FileCopyInfo {
|
||||
long startTime;
|
||||
long lastAccessTime;
|
||||
|
@ -2103,6 +2155,8 @@ public class OsmandAidlApi {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static AGpxFileDetails createGpxFileDetails(@NonNull GPXTrackAnalysis a) {
|
||||
return new AGpxFileDetails(a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
||||
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
||||
|
@ -2179,6 +2233,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
|
||||
public interface OsmandAppInitCallback {
|
||||
void onAppInitialized();
|
||||
}
|
||||
void onAppInitialized();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,19 @@ public interface OsmandAidlConstants {
|
|||
int COPY_FILE_WRITE_LOCK_ERROR = -1003;
|
||||
int COPY_FILE_IO_ERROR = -1004;
|
||||
int COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR = -1005;
|
||||
|
||||
int TURN_TYPE_C = 1;//"C"; // continue (go straight) //$NON-NLS-1$
|
||||
int TURN_TYPE_TL = 2; // turn left //$NON-NLS-1$
|
||||
int TURN_TYPE_TSLL = 3; // turn slightly left //$NON-NLS-1$
|
||||
int TURN_TYPE_TSHL = 4; // turn sharply left //$NON-NLS-1$
|
||||
int TURN_TYPE_TR = 5; // turn right //$NON-NLS-1$
|
||||
int TURN_TYPE_TSLR = 6; // turn slightly right //$NON-NLS-1$
|
||||
int TURN_TYPE_TSHR = 7; // turn sharply right //$NON-NLS-1$
|
||||
int TURN_TYPE_KL = 8; // keep left //$NON-NLS-1$
|
||||
int TURN_TYPE_KR = 9; // keep right//$NON-NLS-1$
|
||||
int TURN_TYPE_TU = 10; // U-turn //$NON-NLS-1$
|
||||
int TURN_TYPE_TRU = 11; // Right U-turn //$NON-NLS-1$
|
||||
int TURN_TYPE_OFFR = 12; // Off route //$NON-NLS-1$
|
||||
int TURN_TYPE_RNDB = 13; // Roundabout
|
||||
int TURN_TYPE_RNLB = 14; // Roundabout left
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import android.os.IBinder;
|
|||
import android.os.RemoteException;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.aidl.OsmandAidlApi.GpxBitmapCreatedCallback;
|
||||
import net.osmand.aidl.OsmandAidlApi.OsmandAppInitCallback;
|
||||
|
@ -50,6 +52,7 @@ import net.osmand.aidl.mapwidget.UpdateMapWidgetParams;
|
|||
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||
import net.osmand.aidl.navdrawer.NavDrawerHeaderParams;
|
||||
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
|
||||
import net.osmand.aidl.navigation.ANavigationUpdateParams;
|
||||
import net.osmand.aidl.navigation.MuteNavigationParams;
|
||||
import net.osmand.aidl.navigation.NavigateGpxParams;
|
||||
import net.osmand.aidl.navigation.NavigateParams;
|
||||
|
@ -75,24 +78,27 @@ import org.apache.commons.logging.Log;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static net.osmand.aidl.OsmandAidlConstants.CANNOT_ACCESS_API_ERROR;
|
||||
import static net.osmand.aidl.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
||||
import static net.osmand.aidl.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR;
|
||||
import static net.osmand.aidl.OsmandAidlConstants.UNKNOWN_API_ERROR;
|
||||
|
||||
public class OsmandAidlService extends Service {
|
||||
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";
|
||||
|
||||
private Map<Long, IOsmAndAidlCallback> callbacks;
|
||||
public static final int KEY_ON_UPDATE = 1;
|
||||
public static final int KEY_ON_NAV_DATA_UPDATE = 2;
|
||||
|
||||
private Map<Long, AidlCallbackParams> callbacks = new ConcurrentHashMap<>();
|
||||
private Handler mHandler = null;
|
||||
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
||||
|
||||
private long updateCallbackId = 0;
|
||||
private final AtomicLong aidlCallbackId = new AtomicLong(0);
|
||||
|
||||
private OsmandApplication getApp() {
|
||||
return (OsmandApplication) getApplication();
|
||||
|
@ -121,14 +127,52 @@ public class OsmandAidlService extends Service {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
callbacks = new ConcurrentHashMap<>();
|
||||
OsmandAidlApi api = getApi("setting_listener");
|
||||
if(api != null) {
|
||||
api.aidlCallbackListener = this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mHandlerThread.quit();
|
||||
|
||||
callbacks.clear();
|
||||
OsmandAidlApi api = getApi("clear_listener");
|
||||
if(api != null) {
|
||||
api.aidlCallbackListener = null;
|
||||
}
|
||||
mHandlerThread.quit();
|
||||
}
|
||||
|
||||
private long getCallbackId() {
|
||||
return aidlCallbackId.get();
|
||||
}
|
||||
|
||||
private long getAndIncrementCallbackId() {
|
||||
return aidlCallbackId.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long addAidlCallback(IOsmAndAidlCallback callback, int key) {
|
||||
callbacks.put(getAndIncrementCallbackId(), new AidlCallbackParams(callback, key));
|
||||
return getCallbackId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAidlCallback(long id) {
|
||||
for (Long key : callbacks.keySet()) {
|
||||
if (key == id) {
|
||||
callbacks.remove(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, AidlCallbackParams> getAidlCallbacks() {
|
||||
return callbacks;
|
||||
}
|
||||
|
||||
private final IOsmAndAidlInterface.Stub mBinder = new IOsmAndAidlInterface.Stub() {
|
||||
|
@ -716,10 +760,9 @@ public class OsmandAidlService extends Service {
|
|||
public long registerForUpdates(long updateTimeMS, IOsmAndAidlCallback callback) {
|
||||
try {
|
||||
if (updateTimeMS >= MIN_UPDATE_TIME_MS) {
|
||||
updateCallbackId++;
|
||||
callbacks.put(updateCallbackId, callback);
|
||||
startRemoteUpdates(updateTimeMS, updateCallbackId, callback);
|
||||
return updateCallbackId;
|
||||
long id = addAidlCallback(callback, KEY_ON_UPDATE);
|
||||
startRemoteUpdates(updateTimeMS, id, callback);
|
||||
return getCallbackId();
|
||||
} else {
|
||||
return MIN_UPDATE_TIME_MS_ERROR;
|
||||
}
|
||||
|
@ -732,7 +775,7 @@ public class OsmandAidlService extends Service {
|
|||
@Override
|
||||
public boolean unregisterFromUpdates(long callbackId) {
|
||||
try {
|
||||
return callbacks.remove(callbackId) != null;
|
||||
return removeAidlCallback(callbackId);
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return false;
|
||||
|
@ -992,5 +1035,58 @@ public class OsmandAidlService extends Service {
|
|||
return UNKNOWN_API_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long registerForNavigationUpdates(ANavigationUpdateParams params, final IOsmAndAidlCallback callback) {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("registerForNavUpdates");
|
||||
if (api != null ) {
|
||||
if (!params.isSubscribeToUpdates() && params.getCallbackId() != -1) {
|
||||
api.unregisterFromUpdates(params.getCallbackId());
|
||||
removeAidlCallback(params.getCallbackId());
|
||||
return -1;
|
||||
} else {
|
||||
long id = addAidlCallback(callback, KEY_ON_NAV_DATA_UPDATE);
|
||||
api.registerForNavigationUpdates(id);
|
||||
return id;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return UNKNOWN_API_ERROR;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static class AidlCallbackParams {
|
||||
private IOsmAndAidlCallback callback;
|
||||
private long key;
|
||||
|
||||
AidlCallbackParams(IOsmAndAidlCallback callback, long key) {
|
||||
this.callback = callback;
|
||||
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public IOsmAndAidlCallback getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(IOsmAndAidlCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public long getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(long key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable ADirectionInfo;
|
73
OsmAnd/src/net/osmand/aidl/navigation/ADirectionInfo.java
Normal file
73
OsmAnd/src/net/osmand/aidl/navigation/ADirectionInfo.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class ADirectionInfo implements Parcelable {
|
||||
|
||||
private int distanceTo; //distance to next turn
|
||||
private int turnType; //turn type
|
||||
private boolean isLeftSide; //is movement left-sided
|
||||
|
||||
public ADirectionInfo(int distanceTo, int turnType, boolean isLeftSide) {
|
||||
this.distanceTo = distanceTo;
|
||||
this.turnType = turnType;
|
||||
this.isLeftSide = isLeftSide;
|
||||
}
|
||||
|
||||
protected ADirectionInfo(Parcel in) {
|
||||
distanceTo = in.readInt();
|
||||
turnType = in.readInt();
|
||||
isLeftSide = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<ADirectionInfo> CREATOR = new Creator<ADirectionInfo>() {
|
||||
@Override
|
||||
public ADirectionInfo createFromParcel(Parcel in) {
|
||||
return new ADirectionInfo(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ADirectionInfo[] newArray(int size) {
|
||||
return new ADirectionInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
public int getDistanceTo() {
|
||||
return distanceTo;
|
||||
}
|
||||
|
||||
public int getTurnType() {
|
||||
return turnType;
|
||||
}
|
||||
|
||||
public boolean isLeftSide() {
|
||||
return isLeftSide;
|
||||
}
|
||||
|
||||
public void setDistanceTo(int distanceTo) {
|
||||
this.distanceTo = distanceTo;
|
||||
}
|
||||
|
||||
public void setTurnType(int turnType) {
|
||||
this.turnType = turnType;
|
||||
}
|
||||
|
||||
public void setLeftSide(boolean leftSide) {
|
||||
isLeftSide = leftSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(distanceTo);
|
||||
dest.writeInt(turnType);
|
||||
dest.writeByte((byte) (isLeftSide ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable ANavigationUpdateParams;
|
|
@ -0,0 +1,57 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class ANavigationUpdateParams implements Parcelable {
|
||||
|
||||
private boolean subscribeToUpdates = true;
|
||||
private long callbackId = -1L;
|
||||
|
||||
public ANavigationUpdateParams() {
|
||||
}
|
||||
|
||||
public long getCallbackId() {
|
||||
return callbackId;
|
||||
}
|
||||
|
||||
public void setCallbackId(long callbackId) {
|
||||
this.callbackId = callbackId;
|
||||
}
|
||||
|
||||
public void setSubscribeToUpdates(boolean subscribeToUpdates) {
|
||||
this.subscribeToUpdates = subscribeToUpdates;
|
||||
}
|
||||
|
||||
public boolean isSubscribeToUpdates() {
|
||||
return subscribeToUpdates;
|
||||
}
|
||||
|
||||
protected ANavigationUpdateParams(Parcel in) {
|
||||
callbackId = in.readLong();
|
||||
subscribeToUpdates = in.readByte() != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(callbackId);
|
||||
dest.writeByte((byte) (subscribeToUpdates ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<ANavigationUpdateParams> CREATOR = new Creator<ANavigationUpdateParams>() {
|
||||
@Override
|
||||
public ANavigationUpdateParams createFromParcel(Parcel in) {
|
||||
return new ANavigationUpdateParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANavigationUpdateParams[] newArray(int size) {
|
||||
return new ANavigationUpdateParams[size];
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package net.osmand.plus.routing;
|
||||
|
||||
public interface IRoutingDataUpdateListener {
|
||||
void onRoutingDataUpdate();
|
||||
}
|
|
@ -26,6 +26,7 @@ import net.osmand.util.Algorithms;
|
|||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -39,7 +40,7 @@ public class RoutingHelper {
|
|||
private static final float POSITION_TOLERANCE = 60;
|
||||
|
||||
private List<WeakReference<IRouteInformationListener>> listeners = new LinkedList<>();
|
||||
|
||||
private List<WeakReference<IRoutingDataUpdateListener>> updateListeners = new LinkedList<>();
|
||||
private OsmandApplication app;
|
||||
private TransportRoutingHelper transportRoutingHelper;
|
||||
|
||||
|
@ -260,25 +261,60 @@ public class RoutingHelper {
|
|||
return lastProjection;
|
||||
}
|
||||
|
||||
|
||||
public void addRouteDataListener(IRoutingDataUpdateListener listener) {
|
||||
updateListeners = updateListenersList(new ArrayList<>(updateListeners), listener, true);
|
||||
}
|
||||
|
||||
public void removeRouteDataListener(IRoutingDataUpdateListener listener) {
|
||||
updateListeners = updateListenersList(new ArrayList<>(updateListeners), listener, false);
|
||||
}
|
||||
|
||||
private List<WeakReference<IRoutingDataUpdateListener>> updateListenersList(
|
||||
List<WeakReference<IRoutingDataUpdateListener>> copyList,
|
||||
IRoutingDataUpdateListener listener, boolean isNewListener) {
|
||||
Iterator<WeakReference<IRoutingDataUpdateListener>> it = copyList.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<IRoutingDataUpdateListener> ref = it.next();
|
||||
IRoutingDataUpdateListener l = ref.get();
|
||||
if (l == null || l == listener) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (isNewListener) {
|
||||
copyList.add(new WeakReference<>(listener));
|
||||
}
|
||||
return copyList;
|
||||
}
|
||||
|
||||
public void addListener(IRouteInformationListener l){
|
||||
listeners.add(new WeakReference<>(l));
|
||||
listeners = updateInformationListeners(new ArrayList<>(listeners), l, true);
|
||||
transportRoutingHelper.addListener(l);
|
||||
}
|
||||
|
||||
public boolean removeListener(IRouteInformationListener lt){
|
||||
Iterator<WeakReference<IRouteInformationListener>> it = listeners.iterator();
|
||||
while(it.hasNext()) {
|
||||
public void removeListener(IRouteInformationListener lt){
|
||||
listeners = updateInformationListeners(new ArrayList<>(listeners), lt, false);
|
||||
}
|
||||
|
||||
private List<WeakReference<IRouteInformationListener>> updateInformationListeners(
|
||||
List<WeakReference<IRouteInformationListener>> copyList,
|
||||
IRouteInformationListener listener, boolean isNewListener) {
|
||||
Iterator<WeakReference<IRouteInformationListener>> it = copyList.iterator();
|
||||
while (it.hasNext()) {
|
||||
WeakReference<IRouteInformationListener> ref = it.next();
|
||||
IRouteInformationListener l = ref.get();
|
||||
if(l == null || lt == l) {
|
||||
if (l == null || l == listener) {
|
||||
it.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
transportRoutingHelper.removeListener(lt);
|
||||
return false;
|
||||
|
||||
if (isNewListener) {
|
||||
copyList.add(new WeakReference<>(listener));
|
||||
}
|
||||
return copyList;
|
||||
}
|
||||
|
||||
|
||||
public void updateLocation(Location currentLocation) {
|
||||
if (settings.getPointToStart() == null && settings.getMyLocationToStart() == null && currentLocation != null) {
|
||||
app.getTargetPointsHelper().setMyLocationPoint(
|
||||
|
@ -502,6 +538,15 @@ public class RoutingHelper {
|
|||
route.updateCurrentRoute(newCurrentRoute + 1);
|
||||
currentRoute = newCurrentRoute + 1;
|
||||
app.getNotificationHelper().refreshNotification(NotificationType.NAVIGATION);
|
||||
if (!updateListeners.isEmpty()) {
|
||||
ArrayList<WeakReference<IRoutingDataUpdateListener>> tmp = new ArrayList<>(updateListeners);
|
||||
for (WeakReference<IRoutingDataUpdateListener> ref : tmp) {
|
||||
IRoutingDataUpdateListener l = ref.get();
|
||||
if (l != null) {
|
||||
l.onRoutingDataUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue