From 100561be7b5e7241c5f8e657f92432576098577d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 May 2020 13:57:16 +0300 Subject: [PATCH 1/5] Update tracker aidl --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 37 ++++++----- .../customization/ProfileSettingsParams.aidl | 3 + .../customization/ProfileSettingsParams.java | 64 +++++++++++++++++++ 3 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.java diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 541194e18d..b4394d647a 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -73,6 +73,7 @@ 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.customization.ProfileSettingsParams; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFileDetails; @@ -305,6 +306,13 @@ interface IOsmAndAidlInterface { */ boolean addFavoriteGroup(in AddFavoriteGroupParams params); + /** + * Remove favorite group with given name. + * + * @param name (String) - name of favorite group. + */ + boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params); + /** * Update favorite group with given params. * @@ -315,13 +323,6 @@ interface IOsmAndAidlInterface { * @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); /** @@ -338,6 +339,16 @@ interface IOsmAndAidlInterface { */ boolean addFavorite(in AddFavoriteParams 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 removeFavorite(in RemoveFavoriteParams params); + /** * Update favorite at given location with given params. * @@ -356,16 +367,6 @@ interface IOsmAndAidlInterface { * "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); /** @@ -846,4 +847,6 @@ interface IOsmAndAidlInterface { * */ boolean getGpxColor(inout GpxColorParams params); + + boolean importProfile(in ProfileSettingsParams params); } diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.aidl new file mode 100644 index 0000000000..9e21787596 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.customization; + +parcelable ProfileSettingsParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.java b/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.java new file mode 100644 index 0000000000..6c2f82cd8f --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/customization/ProfileSettingsParams.java @@ -0,0 +1,64 @@ +package net.osmand.aidl.customization; + +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; + +public class ProfileSettingsParams implements Parcelable { + + private Uri profileSettingsUri; + private String latestChanges; + private int version; + + public ProfileSettingsParams(Uri profileSettingsUri, String latestChanges, int version) { + this.profileSettingsUri = profileSettingsUri; + this.latestChanges = latestChanges; + this.version = version; + } + + public ProfileSettingsParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public ProfileSettingsParams createFromParcel(Parcel in) { + return new ProfileSettingsParams(in); + } + + @Override + public ProfileSettingsParams[] newArray(int size) { + return new ProfileSettingsParams[size]; + } + }; + + public int getVersion() { + return version; + } + + public String getLatestChanges() { + return latestChanges; + } + + public Uri getProfileSettingsUri() { + return profileSettingsUri; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(version); + out.writeString(latestChanges); + out.writeParcelable(profileSettingsUri, flags); + } + + private void readFromParcel(Parcel in) { + version = in.readInt(); + latestChanges = in.readString(); + profileSettingsUri = in.readParcelable(Uri.class.getClassLoader()); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file From da1a06584672cafd7b7d6fcdeae88cda305084a7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 May 2020 14:01:51 +0300 Subject: [PATCH 2/5] Fix #8862 --- .../osmand/aidlapi/IOsmAndAidlInterface.aidl | 4 ++ .../quickaction/QuickActionParams.aidl | 3 ++ .../quickaction/QuickActionParams.java | 45 ++++++++++++++++++ .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 4 ++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 32 +++++++++++++ .../net/osmand/aidl/OsmandAidlService.java | 12 +++++ .../net/osmand/aidl/OsmandAidlServiceV2.java | 12 +++++ .../aidl/quickaction/QuickActionParams.aidl | 3 ++ .../aidl/quickaction/QuickActionParams.java | 47 +++++++++++++++++++ 9 files changed, 162 insertions(+) create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.aidl create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.java create mode 100644 OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.java diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index f628f6804a..095b92d241 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -93,6 +93,8 @@ import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams; +import net.osmand.aidlapi.quickaction.QuickActionParams; + // NOTE: Add new methods at the end of file!!! interface IOsmAndAidlInterface { @@ -834,4 +836,6 @@ interface IOsmAndAidlInterface { boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params); boolean importProfile(in ProfileSettingsParams params); + + boolean executeQuickAction(in QuickActionParams params); } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.aidl new file mode 100644 index 0000000000..fa32216ce0 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.quickaction; + +parcelable QuickActionParams; \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.java b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.java new file mode 100644 index 0000000000..927ba128c0 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionParams.java @@ -0,0 +1,45 @@ +package net.osmand.aidlapi.quickaction; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class QuickActionParams extends AidlParams { + + private int actionNumber; + + public QuickActionParams(int actionNumber) { + this.actionNumber = actionNumber; + } + + public QuickActionParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public QuickActionParams createFromParcel(Parcel in) { + return new QuickActionParams(in); + } + + @Override + public QuickActionParams[] newArray(int size) { + return new QuickActionParams[size]; + } + }; + + public int getActionNumber() { + return actionNumber; + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putInt("actionNumber", actionNumber); + } + + @Override + protected void readFromBundle(Bundle bundle) { + actionNumber = bundle.getInt("actionNumber"); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index d01667b04d..c5603a5914 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -94,6 +94,8 @@ import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidl.mapmarker.RemoveMapMarkersParams; +import net.osmand.aidl.quickaction.QuickActionParams; + // NOTE: Add new methods at the end of file!!! interface IOsmAndAidlInterface { @@ -849,4 +851,6 @@ interface IOsmAndAidlInterface { boolean getGpxColor(inout GpxColorParams params); boolean importProfile(in ProfileSettingsParams params); + + boolean executeQuickAction(in QuickActionParams params); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 9404442c1d..e2b91edc81 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -63,6 +63,8 @@ import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.other.IContextMenuButtonListener; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.myplaces.TrackBitmapDrawer; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routing.IRoutingDataUpdateListener; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; @@ -167,6 +169,9 @@ public class OsmandAidlApi { private static final String AIDL_HIDE_SQLITEDB_FILE = "aidl_hide_sqlitedb_file"; private static final String AIDL_FILE_NAME = "aidl_file_name"; + private static final String AIDL_EXECUTE_QUICK_ACTION = "aidl_execute_quick_action"; + private static final String AIDL_QUICK_ACTION_NUMBER = "aidl_quick_action_number"; + private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; @@ -216,6 +221,7 @@ public class OsmandAidlApi { registerUnmuteNavigationReceiver(mapActivity); registerShowSqliteDbFileReceiver(mapActivity); registerHideSqliteDbFileReceiver(mapActivity); + registerExecuteQuickActionReceiver(mapActivity); initOsmandTelegram(); app.getAppCustomization().addListener(mapActivity); aMapPointUpdateListener = mapActivity; @@ -824,6 +830,24 @@ public class OsmandAidlApi { registerReceiver(hideSqliteDbFileReceiver, mapActivity, AIDL_HIDE_SQLITEDB_FILE); } + private void registerExecuteQuickActionReceiver(MapActivity mapActivity) { + final WeakReference mapActivityRef = new WeakReference<>(mapActivity); + BroadcastReceiver executeQuickActionReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + int actionNumber = intent.getIntExtra(AIDL_QUICK_ACTION_NUMBER, -1); + MapActivity mapActivity = mapActivityRef.get(); + if (actionNumber != -1 && mapActivity != null) { + List actionsList = app.getQuickActionRegistry().getFilteredQuickActions(); + if (actionNumber < actionsList.size()) { + QuickActionRegistry.produceAction(actionsList.get(actionNumber)).execute(mapActivity); + } + } + } + }; + registerReceiver(executeQuickActionReceiver, mapActivity, AIDL_EXECUTE_QUICK_ACTION); + } + public void registerMapLayers(@NonNull MapActivity mapActivity) { for (ConnectedApp connectedApp : connectedApps.values()) { connectedApp.registerMapLayers(mapActivity); @@ -2110,6 +2134,14 @@ public class OsmandAidlApi { } } + public boolean executeQuickAction(int actionNumber) { + Intent intent = new Intent(); + intent.setAction(AIDL_EXECUTE_QUICK_ACTION); + intent.putExtra(AIDL_QUICK_ACTION_NUMBER, actionNumber); + app.sendBroadcast(intent); + return true; + } + private class FileCopyInfo { long startTime; long lastAccessTime; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 6fc69f9328..69c46c0db6 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -80,6 +80,7 @@ import net.osmand.aidl.note.StartVideoRecordingParams; import net.osmand.aidl.note.StopRecordingParams; import net.osmand.aidl.note.TakePhotoNoteParams; import net.osmand.aidl.plugins.PluginParams; +import net.osmand.aidl.quickaction.QuickActionParams; import net.osmand.aidl.search.SearchParams; import net.osmand.aidl.search.SearchResult; import net.osmand.aidl.tiles.ASqliteDbFile; @@ -1302,6 +1303,17 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return false; } } + + @Override + public boolean executeQuickAction(QuickActionParams params) { + try { + OsmandAidlApi api = getApi("executeQuickAction"); + return api != null && api.executeQuickAction(params.getActionNumber()); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 21b80c229d..6d0f545d34 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -81,6 +81,7 @@ import net.osmand.aidlapi.note.StartVideoRecordingParams; import net.osmand.aidlapi.note.StopRecordingParams; import net.osmand.aidlapi.note.TakePhotoNoteParams; import net.osmand.aidlapi.plugins.PluginParams; +import net.osmand.aidlapi.quickaction.QuickActionParams; import net.osmand.aidlapi.search.SearchParams; import net.osmand.aidlapi.search.SearchResult; import net.osmand.aidlapi.tiles.ASqliteDbFile; @@ -1235,6 +1236,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } + + @Override + public boolean executeQuickAction(QuickActionParams params) { + try { + OsmandAidlApi api = getApi("executeQuickAction"); + return api != null && api.executeQuickAction(params.getActionNumber()); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.aidl b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.aidl new file mode 100644 index 0000000000..2a2fca38d8 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.quickaction; + +parcelable QuickActionParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.java b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.java new file mode 100644 index 0000000000..b9fd262600 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionParams.java @@ -0,0 +1,47 @@ +package net.osmand.aidl.quickaction; + +import android.os.Parcel; +import android.os.Parcelable; + +public class QuickActionParams implements Parcelable { + + private int actionNumber; + + public QuickActionParams(int actionNumber) { + this.actionNumber = actionNumber; + } + + public QuickActionParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public QuickActionParams createFromParcel(Parcel in) { + return new QuickActionParams(in); + } + + @Override + public QuickActionParams[] newArray(int size) { + return new QuickActionParams[size]; + } + }; + + public int getActionNumber() { + return actionNumber; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(actionNumber); + } + + private void readFromParcel(Parcel in) { + actionNumber = in.readInt(); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file From 1b16a9122ec3bc799ebd5a1543406e0535174ac0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 May 2020 14:43:54 +0300 Subject: [PATCH 3/5] Add intent call to execute quick action --- .../osmand/plus/helpers/ExternalApiHelper.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 1012b0d52b..a8bc0af1ab 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -36,6 +36,8 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; @@ -96,6 +98,8 @@ public class ExternalApiHelper { public static final String API_CMD_SAVE_GPX = "save_gpx"; public static final String API_CMD_CLEAR_GPX = "clear_gpx"; + public static final String API_EXECUTE_QUICK_ACTION = "execute_quick_action"; + public static final String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications"; public static final int VERSION_CODE = 1; @@ -137,6 +141,7 @@ public class ExternalApiHelper { public static final String PARAM_CLOSE_AFTER_COMMAND = "close_after_command"; + public static final String PARAM_QUICK_ACTION_NUMBER = "quick_action_number"; public static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{ ApplicationMode.CAR, @@ -157,6 +162,7 @@ public class ExternalApiHelper { public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 1005; public static final int RESULT_CODE_ERROR_EMPTY_SEARCH_QUERY = 1006; public static final int RESULT_CODE_ERROR_SEARCH_LOCATION_UNDEFINED = 1007; + public static final int RESULT_CODE_ERROR_QUICK_ACTION_NOT_FOUND = 1008; private MapActivity mapActivity; private int resultCode; @@ -581,6 +587,18 @@ public class ExternalApiHelper { finish = true; } resultCode = Activity.RESULT_OK; + } else if (API_EXECUTE_QUICK_ACTION.equals(cmd)) { + String actionNumberStr = uri.getQueryParameter(PARAM_QUICK_ACTION_NUMBER); + if (!Algorithms.isEmpty(actionNumberStr)) { + int actionNumber = Integer.parseInt(actionNumberStr); + List actionsList = app.getQuickActionRegistry().getFilteredQuickActions(); + if (actionNumber >= 0 && actionNumber < actionsList.size()) { + QuickActionRegistry.produceAction(actionsList.get(actionNumber)).execute(mapActivity); + resultCode = Activity.RESULT_OK; + } else { + resultCode = RESULT_CODE_ERROR_QUICK_ACTION_NOT_FOUND; + } + } } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) { // not implemented yet resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED; From d24f8d3a75703efc148042c20d2c05b748669db1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 May 2020 15:00:11 +0300 Subject: [PATCH 4/5] Update tracker aidl --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 4 ++ .../aidl/quickaction/QuickActionParams.aidl | 3 ++ .../aidl/quickaction/QuickActionParams.java | 47 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.java diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index b4394d647a..31158b895b 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -94,6 +94,8 @@ import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidl.mapmarker.RemoveMapMarkersParams; +import net.osmand.aidl.quickaction.QuickActionParams; + // NOTE: Add new methods at the end of file!!! interface IOsmAndAidlInterface { @@ -849,4 +851,6 @@ interface IOsmAndAidlInterface { boolean getGpxColor(inout GpxColorParams params); boolean importProfile(in ProfileSettingsParams params); + + boolean executeQuickAction(in QuickActionParams params); } diff --git a/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.aidl new file mode 100644 index 0000000000..2a2fca38d8 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.quickaction; + +parcelable QuickActionParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.java b/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.java new file mode 100644 index 0000000000..b9fd262600 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/quickaction/QuickActionParams.java @@ -0,0 +1,47 @@ +package net.osmand.aidl.quickaction; + +import android.os.Parcel; +import android.os.Parcelable; + +public class QuickActionParams implements Parcelable { + + private int actionNumber; + + public QuickActionParams(int actionNumber) { + this.actionNumber = actionNumber; + } + + public QuickActionParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public QuickActionParams createFromParcel(Parcel in) { + return new QuickActionParams(in); + } + + @Override + public QuickActionParams[] newArray(int size) { + return new QuickActionParams[size]; + } + }; + + public int getActionNumber() { + return actionNumber; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(actionNumber); + } + + private void readFromParcel(Parcel in) { + actionNumber = in.readInt(); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file From ab7b0bf57e9e89b1e3e03577fec0a1bb48afb94c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 6 May 2020 15:37:17 +0300 Subject: [PATCH 5/5] Add quickActionsInfo to aidl --- .../osmand/aidlapi/IOsmAndAidlInterface.aidl | 7 +- .../quickaction/QuickActionInfoParams.aidl | 3 + .../quickaction/QuickActionInfoParams.java | 69 ++++++++++++++++++ .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 3 + OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 40 +++++++++++ .../net/osmand/aidl/OsmandAidlService.java | 12 ++++ .../net/osmand/aidl/OsmandAidlServiceV2.java | 12 ++++ .../quickaction/QuickActionInfoParams.aidl | 3 + .../quickaction/QuickActionInfoParams.java | 71 +++++++++++++++++++ 9 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.aidl create mode 100644 OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.java create mode 100644 OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.aidl create mode 100644 OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.java diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index 095b92d241..45bf3907f7 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -94,6 +94,7 @@ import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams; import net.osmand.aidlapi.quickaction.QuickActionParams; +import net.osmand.aidlapi.quickaction.QuickActionInfoParams; // NOTE: Add new methods at the end of file!!! @@ -819,10 +820,10 @@ interface IOsmAndAidlInterface { * */ 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 @@ -838,4 +839,6 @@ interface IOsmAndAidlInterface { boolean importProfile(in ProfileSettingsParams params); boolean executeQuickAction(in QuickActionParams params); + + boolean getQuickActionsInfo(out List quickActions); } \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.aidl b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.aidl new file mode 100644 index 0000000000..cc755f9022 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidlapi.quickaction; + +parcelable QuickActionInfoParams; \ No newline at end of file diff --git a/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.java b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.java new file mode 100644 index 0000000000..c36b8170c6 --- /dev/null +++ b/OsmAnd-api/src/net/osmand/aidlapi/quickaction/QuickActionInfoParams.java @@ -0,0 +1,69 @@ +package net.osmand.aidlapi.quickaction; + +import android.os.Bundle; +import android.os.Parcel; + +import net.osmand.aidlapi.AidlParams; + +public class QuickActionInfoParams extends AidlParams { + + private int actionId; + private String name; + private String actionType; + private String params; + + public QuickActionInfoParams(int actionId, String name, String actionType, String params) { + this.actionId = actionId; + this.name = name; + this.actionType = actionType; + this.params = params; + } + + public QuickActionInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public QuickActionInfoParams createFromParcel(Parcel in) { + return new QuickActionInfoParams(in); + } + + @Override + public QuickActionInfoParams[] newArray(int size) { + return new QuickActionInfoParams[size]; + } + }; + + public int getActionId() { + return actionId; + } + + public String getName() { + return name; + } + + public String getActionType() { + return actionType; + } + + public String getParams() { + return params; + } + + @Override + public void writeToBundle(Bundle bundle) { + bundle.putInt("actionId", actionId); + bundle.putString("name", name); + bundle.putString("actionType", actionType); + bundle.putString("params", params); + } + + @Override + protected void readFromBundle(Bundle bundle) { + actionId = bundle.getInt("actionNumber"); + name = bundle.getString("name"); + actionType = bundle.getString("actionType"); + params = bundle.getString("params"); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index c5603a5914..91410a35c7 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -95,6 +95,7 @@ import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidl.mapmarker.RemoveMapMarkersParams; import net.osmand.aidl.quickaction.QuickActionParams; +import net.osmand.aidl.quickaction.QuickActionInfoParams; // NOTE: Add new methods at the end of file!!! @@ -853,4 +854,6 @@ interface IOsmAndAidlInterface { boolean importProfile(in ProfileSettingsParams params); boolean executeQuickAction(in QuickActionParams params); + + boolean getQuickActionsInfo(out List quickActions); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index e2b91edc81..810a9a3d27 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -20,6 +20,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities; @@ -32,6 +35,7 @@ import net.osmand.aidl.gpx.AGpxFileDetails; import net.osmand.aidl.gpx.ASelectedGpxFile; import net.osmand.aidl.navigation.ADirectionInfo; import net.osmand.aidl.navigation.OnVoiceNavigationParams; +import net.osmand.aidl.quickaction.QuickActionInfoParams; import net.osmand.aidl.tiles.ASqliteDbFile; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; @@ -92,9 +96,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -2142,6 +2148,40 @@ public class OsmandAidlApi { return true; } + public boolean getQuickActionsInfo(List quickActions) { + Gson gson = new Gson(); + Type type = new TypeToken>() { + }.getType(); + + List actionsList = app.getQuickActionRegistry().getFilteredQuickActions(); + for (int i = 0; i < actionsList.size(); i++) { + QuickAction action = actionsList.get(i); + String name = action.getName(app); + String actionType = action.getActionType().getStringId(); + String params = gson.toJson(action.getParams(), type); + + quickActions.add(new QuickActionInfoParams(i, name, actionType, params)); + } + return true; + } + + public boolean getQuickActionsInfoV2(List quickActions) { + Gson gson = new Gson(); + Type type = new TypeToken>() { + }.getType(); + + List actionsList = app.getQuickActionRegistry().getFilteredQuickActions(); + for (int i = 0; i < actionsList.size(); i++) { + QuickAction action = actionsList.get(i); + String name = action.getName(app); + String actionType = action.getActionType().getStringId(); + String params = gson.toJson(action.getParams(), type); + + quickActions.add(new net.osmand.aidlapi.quickaction.QuickActionInfoParams(i, name, actionType, params)); + } + return true; + } + private class FileCopyInfo { long startTime; long lastAccessTime; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 69c46c0db6..ea16a30d2f 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -80,6 +80,7 @@ import net.osmand.aidl.note.StartVideoRecordingParams; import net.osmand.aidl.note.StopRecordingParams; import net.osmand.aidl.note.TakePhotoNoteParams; import net.osmand.aidl.plugins.PluginParams; +import net.osmand.aidl.quickaction.QuickActionInfoParams; import net.osmand.aidl.quickaction.QuickActionParams; import net.osmand.aidl.search.SearchParams; import net.osmand.aidl.search.SearchResult; @@ -1314,6 +1315,17 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return false; } } + + @Override + public boolean getQuickActionsInfo(List quickActions) { + try { + OsmandAidlApi api = getApi("getQuickActionsInfo"); + return api != null && api.getQuickActionsInfo(quickActions); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 6d0f545d34..9ce3378677 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -81,6 +81,7 @@ import net.osmand.aidlapi.note.StartVideoRecordingParams; import net.osmand.aidlapi.note.StopRecordingParams; import net.osmand.aidlapi.note.TakePhotoNoteParams; import net.osmand.aidlapi.plugins.PluginParams; +import net.osmand.aidlapi.quickaction.QuickActionInfoParams; import net.osmand.aidlapi.quickaction.QuickActionParams; import net.osmand.aidlapi.search.SearchParams; import net.osmand.aidlapi.search.SearchResult; @@ -1247,6 +1248,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } + + @Override + public boolean getQuickActionsInfo(List quickActions) { + try { + OsmandAidlApi api = getApi("getQuickActionsInfo"); + return api != null && api.getQuickActionsInfoV2(quickActions); + } catch (Exception e) { + handleException(e); + return false; + } + } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.aidl b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.aidl new file mode 100644 index 0000000000..cd372308ad --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.quickaction; + +parcelable QuickActionInfoParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.java b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.java new file mode 100644 index 0000000000..c5bbf91476 --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/quickaction/QuickActionInfoParams.java @@ -0,0 +1,71 @@ +package net.osmand.aidl.quickaction; + +import android.os.Parcel; +import android.os.Parcelable; + +public class QuickActionInfoParams implements Parcelable { + + private int actionId; + private String name; + private String actionType; + private String params; + + public QuickActionInfoParams(int actionId, String name, String actionType, String params) { + this.actionId = actionId; + this.name = name; + this.actionType = actionType; + this.params = params; + } + + public QuickActionInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public QuickActionInfoParams createFromParcel(Parcel in) { + return new QuickActionInfoParams(in); + } + + @Override + public QuickActionInfoParams[] newArray(int size) { + return new QuickActionInfoParams[size]; + } + }; + + public int getActionId() { + return actionId; + } + + public String getName() { + return name; + } + + public String getActionType() { + return actionType; + } + + public String getParams() { + return params; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(actionId); + out.writeString(name); + out.writeString(actionType); + out.writeString(params); + } + + private void readFromParcel(Parcel in) { + actionId = in.readInt(); + name = in.readString(); + actionType = in.readString(); + params = in.readString(); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file