diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl index 029ad05a6c..f15fe8f44b 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl @@ -3,6 +3,7 @@ package net.osmand.aidl; import net.osmand.aidl.search.SearchResult; import net.osmand.aidl.gpx.AGpxBitmap; import net.osmand.aidl.navigation.ADirectionInfo; +import net.osmand.aidl.navigation.OnVoiceNavigationParams; interface IOsmAndAidlCallback { @@ -37,5 +38,17 @@ interface IOsmAndAidlCallback { */ void updateNavigationInfo(in ADirectionInfo directionInfo); + /** + * Callback for {@link IOsmAndAidlInterface} buttons set with addContextMenuButtons() method. + * + * @param buttonId - id of custom button + * @param pointId - id of point button associated with + * @param layerId - id of layer point and button associated with + */ void onContextMenuButtonClicked(in int buttonId, String pointId, String layerId); + + /** + * Callback for {@link IOsmAndAidlInterface} registerForVoiceRouterMessages() method. + */ + void onVoiceRouterNotify(in OnVoiceNavigationParams params); } \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 4f9fe0e953..541194e18d 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -71,10 +71,13 @@ import net.osmand.aidl.navigation.NavigateSearchParams; import net.osmand.aidl.customization.SetWidgetsParams; import net.osmand.aidl.customization.OsmandSettingsParams; +import net.osmand.aidl.customization.OsmandSettingsInfoParams; +import net.osmand.aidl.customization.CustomizationInfoParams; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFileDetails; import net.osmand.aidl.gpx.CreateGpxBitmapParams; +import net.osmand.aidl.gpx.GpxColorParams; import net.osmand.aidl.tiles.ASqliteDbFile; @@ -82,11 +85,13 @@ import net.osmand.aidl.plugins.PluginParams; import net.osmand.aidl.copyfile.CopyFileParams; import net.osmand.aidl.navigation.ANavigationUpdateParams; +import net.osmand.aidl.navigation.ANavigationVoiceRouterMessageParams; import net.osmand.aidl.contextmenu.ContextMenuButtonsParams; import net.osmand.aidl.contextmenu.UpdateContextMenuButtonsParams; import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams; +import net.osmand.aidl.mapmarker.RemoveMapMarkersParams; // NOTE: Add new methods at the end of file!!! @@ -102,16 +107,23 @@ interface IOsmAndAidlInterface { boolean addMapMarker(in AddMapMarkerParams params); /** - * Add map marker at given location. + * Remove map marker. + * + * If ignoreCoordinates is false the marker is only removed if lat/lon match the currently set values of the marker. + * If ignoreCoordinates is true the marker is removed if the name matches, the values of lat/lon are ignored. * * @param lat (double) - latitude. * @param lon (double) - longitude. * @param name (String)- name of marker. + * @param ignoreCoordinates (boolean) - flag to determine whether lat/lon shall be ignored */ boolean removeMapMarker(in RemoveMapMarkerParams params); /** - * Update map marker at given location with name. + * Update map marker. + * + * If ignoreCoordinates is false the marker gets updated only if latPrev/lonPrev match the currently set values of the marker. + * If ignoreCoordinates is true the marker gets updated if the name matches, the values of latPrev/lonPrev are ignored. * * @param latPrev (double) - latitude (current marker). * @param lonPrev (double) - longitude (current marker). @@ -119,6 +131,7 @@ interface IOsmAndAidlInterface { * @param latNew (double) - latitude (new marker). * @param lonNew (double) - longitude (new marker). * @param nameNew (String) - name (new marker). + * @param ignoreCoordinates (boolean) - flag to determine whether latPrev/lonPrev shall be ignored */ boolean updateMapMarker(in UpdateMapMarkerParams params); @@ -190,6 +203,7 @@ interface IOsmAndAidlInterface { * * @param layerId (String) - layer id. * @param pointId (String) - point id. + * @param updateOpenedMenuAndMap (boolean) - flag to enable folowing mode and menu updates for point * @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. @@ -686,17 +700,150 @@ interface IOsmAndAidlInterface { */ 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 + * @param subscribeToUpdates (boolean) - subscribe or unsubscribe from updates + * @param callbackId (long) - id of callback, needed to unsubscribe from updates + * @param callback (IOsmAndAidlCallback) - callback to notify user on navigation data change */ long registerForNavigationUpdates(in ANavigationUpdateParams params, IOsmAndAidlCallback callback); + /** + * Method to add Context Menu buttons to OsmAnd Context menu. + * + * {@link ContextMenuButtonsParams } is a wrapper class for params: + * + * @param leftButton (AContextMenuButton) - parameters for left context button: + * @param buttonId (String at AContextMenuButton) - id of button in View + * @param leftTextCaption (String at AContextMenuButton) - left-side button text + * @param rightTextCaption (String at AContextMenuButton) - right-side button text + * @param String leftIconName (String at AContextMenuButton) - name of left-side icon + * @param String rightIconName (String at AContextMenuButton) - name of right-side icon + * @param boolean needColorizeIcon (booleanat AContextMenuButton) - flag to apply color to icon + * @param boolean enabled (boolean at AContextMenuButton) - enable button flag + * + * @param rightButton (AContextMenuButton) - parameters for right context button, see leftButton param for details. + * @param id (String) - button id; + * @param appPackage (String) - clinet's app package name + * @param layerId (String) - id of Osmand's map layer + * @param callbackId (long) - {@link IOsmAndAidlCallback} id + * @param pointsIds (List) - list of point Ids to which this rules applies to. + * + * @param callback (IOsmAndAidlCallback) - AIDL callback; + * + * @return long - callback's Id; + */ long addContextMenuButtons(in ContextMenuButtonsParams params, IOsmAndAidlCallback callback); + + /** + * Method to remove Context Menu buttons from OsmAnd Context menu. + * + * {@link RemoveContextMenuButtonsParams} is a wrapper class for params: + * + * @param paramsId (String) - id of {@link ContextMenuButtonsParams} of button you want to remove; + * @param callbackId (long) - id of {@ling IOsmAndAidlCallback} of button you want to remove; + * + */ boolean removeContextMenuButtons(in RemoveContextMenuButtonsParams params); + + /** + * Method to update params on already set custom Context Button. + * + * {@link UpdateContextMenuButtonsParams } is a wrapper class for params: + * + * @param leftButton (AContextMenuButton) - parameters for left context button: + * @param buttonId (String at AContextMenuButton) - id of button in View + * @param leftTextCaption (String at AContextMenuButton) - left-side button text + * @param rightTextCaption (String at AContextMenuButton) - right-side button text + * @param String leftIconName (String at AContextMenuButton) - name of left-side icon + * @param String rightIconName (String at AContextMenuButton) - name of right-side icon + * @param boolean needColorizeIcon (booleanat AContextMenuButton) - flag to apply color to icon + * @param boolean enabled (boolean at AContextMenuButton) - enable button flag + * + * @param rightButton (AContextMenuButton) - parameters for right context button, see leftButton param for details. + * @param id (String) - button id; + * @param appPackage (String) - clinet's app package name + * @param layerId (String) - id of Osmand's map layer + * @param callbackId (long) - {@link IOsmAndAidlCallback} id + * @param pointsIds (List) - list of point Ids to which this rules applies to. + * + */ boolean updateContextMenuButtons(in UpdateContextMenuButtonsParams params); -} \ No newline at end of file + + /** + * Method to check if there is a customized setting in OsmAnd Settings. + * + * {@link OsmandSettingsInfoParams} is a wrapper class for params: + * + * @param sharedPreferencesName (String at OsmandSettingInfoParams) - key of setting in OsmAnd's preferences. + * + * @return boolean - true if setting is already set in SharedPreferences + * + */ + boolean areOsmandSettingsCustomized(in OsmandSettingsInfoParams params); + + /** + * Method to customize parameters of OsmAnd. + * + * @param params (CustomizationInfoParams) - wrapper class for custom settings and ui. + * + * @param settingsParams (OsmandSettingsParams) - wrapper class for OsmAnd shared preferences params. + * See {@link #customizeOsmandSettings(in OsmandSettingsParams params) customizeOsmandSettings} + * method description for details. + * @param navDrawerHeaderParams (NavDrawerHeaderParams) - wrapper class for OsmAnd navdrawer header params. + * See {@link #setNavDrawerLogoWithParams(in NavDrawerHeaderParams params) setNavDrawerLogoWithParams} + * method description for details. + * @param navDrawerFooterParams (NavDrawerFooterParams) - wrapper class for OsmAnd navdrawer footer params. + * See {@link #setNavDrawerFooterWithParams(in NavDrawerFooterParams params) setNavDrawerFooterWithParams} + * method description for details. + * @param visibilityWidgetsParams (ArrayList) - wrapper class for OsmAnd widgets visibility. + * See {@link #regWidgetVisibility(in SetWidgetsParams params) regWidgetVisibility} + * method description for details. + * @param availabilityWidgetsParams (ArrayList) - wrapper class for OsmAnd widgets availability. + * See {@link #regWidgetAvailability(in SetWidgetsParams params) regWidgetAvailability} + * method description for details. + * @param pluginsParams (ArrayList) - wrapper class for OsmAnd plugins states params. + * See {@link #changePluginState(in PluginParams params) changePluginState} + * method description for details. + * @param featuresEnabledIds (List) - list of UI elements (like QuickSearch button) to show. + * See {@link #setEnabledIds(in List ids) setEnabledIds} + * @param featuresDisabledIds (List) - list of UI elements (like QuickSearch button) to hide. + * See {@link #setDisabledIds(in List ids) setDisabledIds} + * @param featuresEnabledPatterns (List) - list of NavDrawer menu items to show. + * See {@link #setEnabledPatterns(in List patterns) setEnabledPatterns} + * @param featuresDisabledPatterns (List) - list of NavDrawer menu items to hide. + * See {@link #setDisabledPatterns(in List patterns) setDisabledPatterns} + * + */ + boolean setCustomization(in CustomizationInfoParams params); + + /** + * Method to register for Voice Router voice messages during navigation. Notifies user about voice messages. + * + * @params subscribeToUpdates (boolean) - boolean flag to subscribe or unsubscribe from messages + * @params callbackId (long) - id of callback, needed to unsubscribe from messages + * @params callback (IOsmAndAidlCallback) - callback to notify user on voice message + */ + long registerForVoiceRouterMessages(in ANavigationVoiceRouterMessageParams params, IOsmAndAidlCallback callback); + + /** + * Removes all active map markers (marks them as passed and moves to history) + * Empty class of params + */ + boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params); + + /** + * Method to get color name for gpx. + * + * @param fileName (String) - name of gpx file. + * + * @param gpxColor (String) - color name of gpx. Can be one of: "red", "orange", "lightblue", + * "blue", "purple", "translucent_red", "translucent_orange", + * "translucent_lightblue", "translucent_blue", "translucent_purple" + * Which used in {@link #importGpx(in ImportGpxParams params) importGpx} + * Or color hex if gpx has custom color. + * + */ + boolean getGpxColor(inout GpxColorParams params); +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl new file mode 100644 index 0000000000..e72d2d47dc --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.customization; + +parcelable CustomizationInfoParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.java b/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.java new file mode 100644 index 0000000000..0e83f7f41c --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/CustomizationInfoParams.java @@ -0,0 +1,172 @@ +package net.osmand.aidl.customization; + +import android.annotation.SuppressLint; +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.navdrawer.NavDrawerFooterParams; +import net.osmand.aidl.navdrawer.NavDrawerHeaderParams; +import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams; +import net.osmand.aidl.plugins.PluginParams; + +import java.util.ArrayList; +import java.util.List; + +public class CustomizationInfoParams implements Parcelable { + + private OsmandSettingsParams settingsParams; + + private NavDrawerHeaderParams navDrawerHeaderParams; + private NavDrawerFooterParams navDrawerFooterParams; + private SetNavDrawerItemsParams navDrawerItemsParams; + + private ArrayList visibilityWidgetsParams = new ArrayList<>(); + private ArrayList availabilityWidgetsParams = new ArrayList<>(); + + private ArrayList pluginsParams = new ArrayList<>(); + + private List featuresEnabledIds = new ArrayList<>(); + private List featuresDisabledIds = new ArrayList<>(); + private List featuresEnabledPatterns = new ArrayList<>(); + private List featuresDisabledPatterns = new ArrayList<>(); + + public CustomizationInfoParams(OsmandSettingsParams settingsParams, + NavDrawerHeaderParams navDrawerHeaderParams, + NavDrawerFooterParams navDrawerFooterParams, + SetNavDrawerItemsParams navDrawerItemsParams, + ArrayList visibilityWidgetsParams, + ArrayList availabilityWidgetsParams, + ArrayList pluginsParams, + List featuresEnabledIds, + List featuresDisabledIds, + List featuresEnabledPatterns, + List featuresDisabledPatterns) { + this.settingsParams = settingsParams; + this.navDrawerHeaderParams = navDrawerHeaderParams; + this.navDrawerFooterParams = navDrawerFooterParams; + this.navDrawerItemsParams = navDrawerItemsParams; + + if (visibilityWidgetsParams != null) { + this.visibilityWidgetsParams.addAll(visibilityWidgetsParams); + } + if (availabilityWidgetsParams != null) { + this.availabilityWidgetsParams.addAll(availabilityWidgetsParams); + } + if (pluginsParams != null) { + this.pluginsParams.addAll(pluginsParams); + } + if (featuresEnabledIds != null) { + this.featuresEnabledIds.addAll(featuresEnabledIds); + } + if (featuresDisabledIds != null) { + this.featuresDisabledIds.addAll(featuresDisabledIds); + } + if (featuresEnabledPatterns != null) { + this.featuresEnabledPatterns.addAll(featuresEnabledPatterns); + } + if (featuresDisabledPatterns != null) { + this.featuresDisabledPatterns.addAll(featuresDisabledPatterns); + } + } + + public CustomizationInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public CustomizationInfoParams createFromParcel(Parcel in) { + return new CustomizationInfoParams(in); + } + + @Override + public CustomizationInfoParams[] newArray(int size) { + return new CustomizationInfoParams[size]; + } + }; + + public OsmandSettingsParams getSettingsParams() { + return settingsParams; + } + + public NavDrawerHeaderParams getNavDrawerHeaderParams() { + return navDrawerHeaderParams; + } + + public NavDrawerFooterParams getNavDrawerFooterParams() { + return navDrawerFooterParams; + } + + public SetNavDrawerItemsParams getNavDrawerItemsParams() { + return navDrawerItemsParams; + } + + public ArrayList getVisibilityWidgetsParams() { + return visibilityWidgetsParams; + } + + public ArrayList getAvailabilityWidgetsParams() { + return availabilityWidgetsParams; + } + + public ArrayList getPluginsParams() { + return pluginsParams; + } + + public List getFeaturesEnabledIds() { + return featuresEnabledIds; + } + + public List getFeaturesDisabledIds() { + return featuresDisabledIds; + } + + public List getFeaturesEnabledPatterns() { + return featuresEnabledPatterns; + } + + public List getFeaturesDisabledPatterns() { + return featuresDisabledPatterns; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(settingsParams, flags); + + out.writeParcelable(navDrawerHeaderParams, flags); + out.writeParcelable(navDrawerFooterParams, flags); + out.writeParcelable(navDrawerItemsParams, flags); + + out.writeTypedList(visibilityWidgetsParams); + out.writeTypedList(availabilityWidgetsParams); + out.writeTypedList(pluginsParams); + + out.writeStringList(featuresEnabledIds); + out.writeStringList(featuresDisabledIds); + out.writeStringList(featuresEnabledPatterns); + out.writeStringList(featuresDisabledPatterns); + } + + @SuppressLint("ParcelClassLoader") + private void readFromParcel(Parcel in) { + settingsParams = in.readParcelable(OsmandSettingsParams.class.getClassLoader()); + + navDrawerHeaderParams = in.readParcelable(NavDrawerHeaderParams.class.getClassLoader()); + navDrawerFooterParams = in.readParcelable(NavDrawerFooterParams.class.getClassLoader()); + navDrawerItemsParams = in.readParcelable(SetNavDrawerItemsParams.class.getClassLoader()); + + in.readTypedList(visibilityWidgetsParams, SetWidgetsParams.CREATOR); + in.readTypedList(availabilityWidgetsParams, SetWidgetsParams.CREATOR); + in.readTypedList(pluginsParams, PluginParams.CREATOR); + + in.readStringList(featuresEnabledIds); + in.readStringList(featuresDisabledIds); + in.readStringList(featuresEnabledPatterns); + in.readStringList(featuresDisabledPatterns); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl new file mode 100644 index 0000000000..80d0fa56ed --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.customization; + +parcelable OsmandSettingsInfoParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java b/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java new file mode 100644 index 0000000000..ba4285af1d --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java @@ -0,0 +1,50 @@ +package net.osmand.aidl.customization; + +import android.annotation.SuppressLint; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + +public class OsmandSettingsInfoParams implements Parcelable { + + private String sharedPreferencesName; + + public OsmandSettingsInfoParams(@NonNull String sharedPreferencesName) { + this.sharedPreferencesName = sharedPreferencesName; + } + + public OsmandSettingsInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public OsmandSettingsInfoParams createFromParcel(Parcel in) { + return new OsmandSettingsInfoParams(in); + } + + @Override + public OsmandSettingsInfoParams[] newArray(int size) { + return new OsmandSettingsInfoParams[size]; + } + }; + + public String getSharedPreferencesName() { + return sharedPreferencesName; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeString(sharedPreferencesName); + } + + @SuppressLint("ParcelClassLoader") + private void readFromParcel(Parcel in) { + sharedPreferencesName = in.readString(); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/gpx/AGpxFile.java b/OsmAnd-telegram/src/net/osmand/aidl/gpx/AGpxFile.java index fb357c79b1..028c0a628a 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/gpx/AGpxFile.java +++ b/OsmAnd-telegram/src/net/osmand/aidl/gpx/AGpxFile.java @@ -11,15 +11,13 @@ public class AGpxFile implements Parcelable { private long modifiedTime; private long fileSize; private boolean active; - private String color; private AGpxFileDetails details; - public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, String color, @Nullable AGpxFileDetails details) { + public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, @Nullable AGpxFileDetails details) { this.fileName = fileName; this.modifiedTime = modifiedTime; this.fileSize = fileSize; this.active = active; - this.color = color; this.details = details; } @@ -54,10 +52,6 @@ public class AGpxFile implements Parcelable { return active; } - public String getColor() { - return color; - } - public AGpxFileDetails getDetails() { return details; } @@ -72,7 +66,6 @@ public class AGpxFile implements Parcelable { if (details != null) { out.writeParcelable(details, flags); } - out.writeString(color); } private void readFromParcel(Parcel in) { @@ -87,7 +80,6 @@ public class AGpxFile implements Parcelable { } else { details = null; } - color = in.readString(); } public int describeContents() { diff --git a/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.aidl new file mode 100644 index 0000000000..bd26e19344 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.gpx; + +parcelable GpxColorParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.java b/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.java new file mode 100644 index 0000000000..cd039ec0cc --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/gpx/GpxColorParams.java @@ -0,0 +1,66 @@ +package net.osmand.aidl.gpx; + +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + +public class GpxColorParams implements Parcelable { + + private String fileName; + private String gpxColor; + + public GpxColorParams() { + + } + + public GpxColorParams(@NonNull String fileName) { + this.fileName = fileName; + } + + public GpxColorParams(@NonNull String fileName, String gpxColor) { + this.fileName = fileName; + this.gpxColor = gpxColor; + } + + public GpxColorParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new + Creator() { + public GpxColorParams createFromParcel(Parcel in) { + return new GpxColorParams(in); + } + + public GpxColorParams[] newArray(int size) { + return new GpxColorParams[size]; + } + }; + + public String getFileName() { + return fileName; + } + + public String getGpxColor() { + return gpxColor; + } + + public void setGpxColor(String gpxColor) { + this.gpxColor = gpxColor; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(fileName); + out.writeString(gpxColor); + } + + public void readFromParcel(Parcel in) { + fileName = in.readString(); + gpxColor = in.readString(); + } + + public int describeContents() { + return 0; + } +} + diff --git a/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.aidl new file mode 100644 index 0000000000..ee5f4936d7 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.mapmarker; + +parcelable RemoveMapMarkersParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.java b/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.java new file mode 100644 index 0000000000..cf0ea8d00c --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/mapmarker/RemoveMapMarkersParams.java @@ -0,0 +1,37 @@ +package net.osmand.aidl.mapmarker; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RemoveMapMarkersParams implements Parcelable { + + + public RemoveMapMarkersParams() { + } + + public RemoveMapMarkersParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new + Creator() { + public RemoveMapMarkersParams createFromParcel(Parcel in) { + return new RemoveMapMarkersParams(in); + } + + public RemoveMapMarkersParams[] newArray(int size) { + return new RemoveMapMarkersParams[size]; + } + }; + + + public void writeToParcel(Parcel out, int flags) { + } + + private void readFromParcel(Parcel in) { + } + + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.aidl new file mode 100644 index 0000000000..6dfbe239ae --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable ANavigationVoiceRouterMessageParams; diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.java new file mode 100644 index 0000000000..196380729f --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ANavigationVoiceRouterMessageParams.java @@ -0,0 +1,56 @@ +package net.osmand.aidl.navigation; + +import android.os.Parcel; +import android.os.Parcelable; + +public class ANavigationVoiceRouterMessageParams implements Parcelable{ + private boolean subscribeToUpdates = true; + private long callbackId = -1L; + + public ANavigationVoiceRouterMessageParams() { + } + + 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 ANavigationVoiceRouterMessageParams(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 CREATOR = new Creator() { + @Override + public ANavigationVoiceRouterMessageParams createFromParcel(Parcel in) { + return new ANavigationVoiceRouterMessageParams(in); + } + + @Override + public ANavigationVoiceRouterMessageParams[] newArray(int size) { + return new ANavigationVoiceRouterMessageParams[size]; + } + }; +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.aidl new file mode 100644 index 0000000000..53ab4f6a5c --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable OnVoiceNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java new file mode 100644 index 0000000000..20fd34e13e --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java @@ -0,0 +1,57 @@ +package net.osmand.aidl.navigation; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.ArrayList; +import java.util.List; + +public class OnVoiceNavigationParams implements Parcelable { + + private List cmds; + private List played; + + public OnVoiceNavigationParams() { + cmds = new ArrayList<>(); + played = new ArrayList<>(); + } + + public OnVoiceNavigationParams(List cmds, List played) { + this.cmds = cmds; + this.played = played; + } + + public OnVoiceNavigationParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public OnVoiceNavigationParams createFromParcel(Parcel in) { + return new OnVoiceNavigationParams(in); + } + + @Override + public OnVoiceNavigationParams[] newArray(int size) { + return new OnVoiceNavigationParams[size]; + } + }; + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeStringList(cmds); + out.writeStringList(played); + } + + private void readFromParcel(Parcel in) { + cmds = new ArrayList<>(); + in.readStringList(cmds); + played = new ArrayList<>(); + in.readStringList(played); + } + + @Override + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt index 66ccd1bad8..21b4df64d0 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt @@ -127,6 +127,10 @@ class OsmandAidlHelper(private val app: TelegramApplication) { contextMenuButtonsListener!!.onContextMenuButtonClicked(buttonId, pointId, layerId) } } + + override fun onVoiceRouterNotify(params: OnVoiceNavigationParams?) { + + } } fun setSearchCompleteListener(mSearchCompleteListener: SearchCompleteListener) { @@ -1217,4 +1221,18 @@ class OsmandAidlHelper(private val app: TelegramApplication) { } return false } + + fun getGpxColor(filename: String): String? { + if (mIOsmAndAidlInterface != null) { + try { + val gpxColorParams = GpxColorParams(filename) + if (mIOsmAndAidlInterface!!.getGpxColor(gpxColorParams)) { + return gpxColorParams.gpxColor + } + } catch (e: RemoteException) { + e.printStackTrace() + } + } + return null + } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index 501133778f..5dd43f04a0 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -114,7 +114,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { setupMapLayer() osmandAidlHelper.execOsmandApi { val pointId = item.getMapPointId() - val name = item.getVisibleName() + val name = item.name val aLatLon = ALatLon(item.latLon!!.latitude, item.latLon!!.longitude) val details = generatePointDetails(item.bearing?.toFloat(), item.altitude?.toFloat(), item.precision?.toFloat()) val params = generatePointParams(if (stale) item.grayscalePhotoPath else item.photoPath, stale, item.speed?.toFloat(), item.bearing?.toFloat()) @@ -300,7 +300,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { val aGpxFile = importedGpxFiles.firstOrNull { it.fileName == name } if (aGpxFile != null) { - val color = aGpxFile.color + val color = osmandAidlHelper.getGpxColor(aGpxFile.fileName) if (!color.isNullOrEmpty()) { gpxFile.extensionsToWrite["color"] = color } diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 2038a68fbd..e97aa77883 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -77,6 +77,7 @@ import net.osmand.aidl.customization.CustomizationInfoParams; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFileDetails; import net.osmand.aidl.gpx.CreateGpxBitmapParams; +import net.osmand.aidl.gpx.GpxColorParams; import net.osmand.aidl.tiles.ASqliteDbFile; @@ -831,4 +832,18 @@ interface IOsmAndAidlInterface { * Empty class of params */ boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params); + + /** + * Method to get color name for gpx. + * + * @param fileName (String) - name of gpx file. + * + * @param gpxColor (String) - color name of gpx. Can be one of: "red", "orange", "lightblue", + * "blue", "purple", "translucent_red", "translucent_orange", + * "translucent_lightblue", "translucent_blue", "translucent_purple" + * Which used in {@link #importGpx(in ImportGpxParams params) importGpx} + * Or color hex if gpx has custom color. + * + */ + boolean getGpxColor(inout GpxColorParams params); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index a50813d692..be3325df6e 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -39,6 +39,7 @@ import net.osmand.aidl.gpx.AGpxBitmap; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFileDetails; import net.osmand.aidl.gpx.ASelectedGpxFile; +import net.osmand.aidl.gpx.GpxColorParams; import net.osmand.aidl.gpx.StartGpxRecordingParams; import net.osmand.aidl.gpx.StopGpxRecordingParams; import net.osmand.aidl.maplayer.AMapLayer; @@ -1477,17 +1478,12 @@ public class OsmandAidlApi { boolean active = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath()) != null; long modifiedTime = dataItem.getFileLastModifiedTime(); long fileSize = file.length(); - int color = dataItem.getColor(); - String colorName = ""; - if (color != 0) { - colorName = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); - } AGpxFileDetails details = null; GPXTrackAnalysis analysis = dataItem.getAnalysis(); if (analysis != null) { details = createGpxFileDetails(analysis); } - files.add(new AGpxFile(fileName, modifiedTime, fileSize, active, colorName, details)); + files.add(new AGpxFile(fileName, modifiedTime, fileSize, active, details)); } //} } @@ -1496,6 +1492,26 @@ public class OsmandAidlApi { return false; } + boolean getGpxColor(GpxColorParams params) { + if (params != null) { + List gpxDataItems = app.getGpxDatabase().getItems(); + for (GpxDataItem dataItem : gpxDataItems) { + File file = dataItem.getFile(); + if (file.exists()) { + if (file.getName().equals(params.getFileName())) { + int color = dataItem.getColor(); + if (color != 0) { + String colorName = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); + params.setGpxColor(colorName); + return true; + } + } + } + } + } + return false; + } + boolean removeGpx(String fileName) { if (!Algorithms.isEmpty(fileName)) { final File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index bec6725bdc..2cbcf691c2 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -33,6 +33,7 @@ import net.osmand.aidl.gpx.AGpxBitmap; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.gpx.CreateGpxBitmapParams; +import net.osmand.aidl.gpx.GpxColorParams; import net.osmand.aidl.gpx.HideGpxParams; import net.osmand.aidl.gpx.ImportGpxParams; import net.osmand.aidl.gpx.RemoveGpxParams; @@ -1174,6 +1175,17 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return false; } } + + @Override + public boolean getGpxColor(GpxColorParams params) throws RemoteException { + try { + OsmandAidlApi api = getApi("getGpxColor"); + return api != null && api.getGpxColor(params); + } catch (Exception e) { + handleException(e); + return false; + } + } }; public static class AidlCallbackParams { diff --git a/OsmAnd/src/net/osmand/aidl/gpx/AGpxFile.java b/OsmAnd/src/net/osmand/aidl/gpx/AGpxFile.java index fb357c79b1..028c0a628a 100644 --- a/OsmAnd/src/net/osmand/aidl/gpx/AGpxFile.java +++ b/OsmAnd/src/net/osmand/aidl/gpx/AGpxFile.java @@ -11,15 +11,13 @@ public class AGpxFile implements Parcelable { private long modifiedTime; private long fileSize; private boolean active; - private String color; private AGpxFileDetails details; - public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, String color, @Nullable AGpxFileDetails details) { + public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, @Nullable AGpxFileDetails details) { this.fileName = fileName; this.modifiedTime = modifiedTime; this.fileSize = fileSize; this.active = active; - this.color = color; this.details = details; } @@ -54,10 +52,6 @@ public class AGpxFile implements Parcelable { return active; } - public String getColor() { - return color; - } - public AGpxFileDetails getDetails() { return details; } @@ -72,7 +66,6 @@ public class AGpxFile implements Parcelable { if (details != null) { out.writeParcelable(details, flags); } - out.writeString(color); } private void readFromParcel(Parcel in) { @@ -87,7 +80,6 @@ public class AGpxFile implements Parcelable { } else { details = null; } - color = in.readString(); } public int describeContents() { diff --git a/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.aidl b/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.aidl new file mode 100644 index 0000000000..bd26e19344 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.gpx; + +parcelable GpxColorParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.java b/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.java new file mode 100644 index 0000000000..cd039ec0cc --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/gpx/GpxColorParams.java @@ -0,0 +1,66 @@ +package net.osmand.aidl.gpx; + +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + +public class GpxColorParams implements Parcelable { + + private String fileName; + private String gpxColor; + + public GpxColorParams() { + + } + + public GpxColorParams(@NonNull String fileName) { + this.fileName = fileName; + } + + public GpxColorParams(@NonNull String fileName, String gpxColor) { + this.fileName = fileName; + this.gpxColor = gpxColor; + } + + public GpxColorParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new + Creator() { + public GpxColorParams createFromParcel(Parcel in) { + return new GpxColorParams(in); + } + + public GpxColorParams[] newArray(int size) { + return new GpxColorParams[size]; + } + }; + + public String getFileName() { + return fileName; + } + + public String getGpxColor() { + return gpxColor; + } + + public void setGpxColor(String gpxColor) { + this.gpxColor = gpxColor; + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(fileName); + out.writeString(gpxColor); + } + + public void readFromParcel(Parcel in) { + fileName = in.readString(); + gpxColor = in.readString(); + } + + public int describeContents() { + return 0; + } +} + diff --git a/OsmAnd/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java b/OsmAnd/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java index 63781b1cbe..20fd34e13e 100644 --- a/OsmAnd/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java +++ b/OsmAnd/src/net/osmand/aidl/navigation/OnVoiceNavigationParams.java @@ -44,7 +44,9 @@ public class OnVoiceNavigationParams implements Parcelable { } private void readFromParcel(Parcel in) { + cmds = new ArrayList<>(); in.readStringList(cmds); + played = new ArrayList<>(); in.readStringList(played); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java index 5f19854548..52ea9d5740 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java @@ -276,7 +276,7 @@ public class AMapPointMenuController extends MenuController { } ims.close(); } - } catch (IOException e) { + } catch (Exception e) { // ignore }