Add quickActionsInfo to aidl
This commit is contained in:
parent
d24f8d3a75
commit
ab7b0bf57e
9 changed files with 218 additions and 2 deletions
|
@ -94,6 +94,7 @@ import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams;
|
||||||
import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams;
|
import net.osmand.aidlapi.mapmarker.RemoveMapMarkersParams;
|
||||||
|
|
||||||
import net.osmand.aidlapi.quickaction.QuickActionParams;
|
import net.osmand.aidlapi.quickaction.QuickActionParams;
|
||||||
|
import net.osmand.aidlapi.quickaction.QuickActionInfoParams;
|
||||||
|
|
||||||
// NOTE: Add new methods at the end of file!!!
|
// NOTE: Add new methods at the end of file!!!
|
||||||
|
|
||||||
|
@ -838,4 +839,6 @@ interface IOsmAndAidlInterface {
|
||||||
boolean importProfile(in ProfileSettingsParams params);
|
boolean importProfile(in ProfileSettingsParams params);
|
||||||
|
|
||||||
boolean executeQuickAction(in QuickActionParams params);
|
boolean executeQuickAction(in QuickActionParams params);
|
||||||
|
|
||||||
|
boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidlapi.quickaction;
|
||||||
|
|
||||||
|
parcelable QuickActionInfoParams;
|
|
@ -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<QuickActionInfoParams> CREATOR = new Creator<QuickActionInfoParams>() {
|
||||||
|
@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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -95,6 +95,7 @@ import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams;
|
||||||
import net.osmand.aidl.mapmarker.RemoveMapMarkersParams;
|
import net.osmand.aidl.mapmarker.RemoveMapMarkersParams;
|
||||||
|
|
||||||
import net.osmand.aidl.quickaction.QuickActionParams;
|
import net.osmand.aidl.quickaction.QuickActionParams;
|
||||||
|
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
||||||
|
|
||||||
// NOTE: Add new methods at the end of file!!!
|
// NOTE: Add new methods at the end of file!!!
|
||||||
|
|
||||||
|
@ -853,4 +854,6 @@ interface IOsmAndAidlInterface {
|
||||||
boolean importProfile(in ProfileSettingsParams params);
|
boolean importProfile(in ProfileSettingsParams params);
|
||||||
|
|
||||||
boolean executeQuickAction(in QuickActionParams params);
|
boolean executeQuickAction(in QuickActionParams params);
|
||||||
|
|
||||||
|
boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
@ -32,6 +35,7 @@ import net.osmand.aidl.gpx.AGpxFileDetails;
|
||||||
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
||||||
import net.osmand.aidl.navigation.ADirectionInfo;
|
import net.osmand.aidl.navigation.ADirectionInfo;
|
||||||
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
||||||
|
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -92,9 +96,11 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -2142,6 +2148,40 @@ public class OsmandAidlApi {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getQuickActionsInfo(List<QuickActionInfoParams> quickActions) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Type type = new TypeToken<HashMap<String, String>>() {
|
||||||
|
}.getType();
|
||||||
|
|
||||||
|
List<QuickAction> 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<net.osmand.aidlapi.quickaction.QuickActionInfoParams> quickActions) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Type type = new TypeToken<HashMap<String, String>>() {
|
||||||
|
}.getType();
|
||||||
|
|
||||||
|
List<QuickAction> 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 {
|
private class FileCopyInfo {
|
||||||
long startTime;
|
long startTime;
|
||||||
long lastAccessTime;
|
long lastAccessTime;
|
||||||
|
|
|
@ -80,6 +80,7 @@ import net.osmand.aidl.note.StartVideoRecordingParams;
|
||||||
import net.osmand.aidl.note.StopRecordingParams;
|
import net.osmand.aidl.note.StopRecordingParams;
|
||||||
import net.osmand.aidl.note.TakePhotoNoteParams;
|
import net.osmand.aidl.note.TakePhotoNoteParams;
|
||||||
import net.osmand.aidl.plugins.PluginParams;
|
import net.osmand.aidl.plugins.PluginParams;
|
||||||
|
import net.osmand.aidl.quickaction.QuickActionInfoParams;
|
||||||
import net.osmand.aidl.quickaction.QuickActionParams;
|
import net.osmand.aidl.quickaction.QuickActionParams;
|
||||||
import net.osmand.aidl.search.SearchParams;
|
import net.osmand.aidl.search.SearchParams;
|
||||||
import net.osmand.aidl.search.SearchResult;
|
import net.osmand.aidl.search.SearchResult;
|
||||||
|
@ -1314,6 +1315,17 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getQuickActionsInfo(List<QuickActionInfoParams> 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) {
|
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ import net.osmand.aidlapi.note.StartVideoRecordingParams;
|
||||||
import net.osmand.aidlapi.note.StopRecordingParams;
|
import net.osmand.aidlapi.note.StopRecordingParams;
|
||||||
import net.osmand.aidlapi.note.TakePhotoNoteParams;
|
import net.osmand.aidlapi.note.TakePhotoNoteParams;
|
||||||
import net.osmand.aidlapi.plugins.PluginParams;
|
import net.osmand.aidlapi.plugins.PluginParams;
|
||||||
|
import net.osmand.aidlapi.quickaction.QuickActionInfoParams;
|
||||||
import net.osmand.aidlapi.quickaction.QuickActionParams;
|
import net.osmand.aidlapi.quickaction.QuickActionParams;
|
||||||
import net.osmand.aidlapi.search.SearchParams;
|
import net.osmand.aidlapi.search.SearchParams;
|
||||||
import net.osmand.aidlapi.search.SearchResult;
|
import net.osmand.aidlapi.search.SearchResult;
|
||||||
|
@ -1247,6 +1248,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getQuickActionsInfo(List<QuickActionInfoParams> 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) {
|
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidl.quickaction;
|
||||||
|
|
||||||
|
parcelable QuickActionInfoParams;
|
|
@ -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<QuickActionInfoParams> CREATOR = new Creator<QuickActionInfoParams>() {
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue