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