Merge pull request #8902 from osmandapp/fix_8862

Fix_8862
This commit is contained in:
vshcherb 2020-05-06 15:34:11 +02:00 committed by GitHub
commit aa8bed7e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 539 additions and 19 deletions

View file

@ -93,6 +93,9 @@ 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.QuickActionInfoParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
interface IOsmAndAidlInterface { interface IOsmAndAidlInterface {
@ -817,10 +820,10 @@ interface IOsmAndAidlInterface {
* *
*/ */
boolean setCustomization(in CustomizationInfoParams params); boolean setCustomization(in CustomizationInfoParams params);
/** /**
* Method to register for Voice Router voice messages during navigation. Notifies user about voice messages. * 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 subscribeToUpdates (boolean) - boolean flag to subscribe or unsubscribe from messages
* @params callbackId (long) - id of callback, needed to unsubscribe from messages * @params callbackId (long) - id of callback, needed to unsubscribe from messages
* @params callback (IOsmAndAidlCallback) - callback to notify user on voice message * @params callback (IOsmAndAidlCallback) - callback to notify user on voice message
@ -834,4 +837,8 @@ interface IOsmAndAidlInterface {
boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params); boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params);
boolean importProfile(in ProfileSettingsParams params); boolean importProfile(in ProfileSettingsParams params);
boolean executeQuickAction(in QuickActionParams params);
boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);
} }

View file

@ -0,0 +1,3 @@
package net.osmand.aidlapi.quickaction;
parcelable QuickActionInfoParams;

View file

@ -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");
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidlapi.quickaction;
parcelable QuickActionParams;

View file

@ -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<QuickActionParams> CREATOR = new Creator<QuickActionParams>() {
@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");
}
}

View file

@ -73,6 +73,7 @@ import net.osmand.aidl.customization.SetWidgetsParams;
import net.osmand.aidl.customization.OsmandSettingsParams; import net.osmand.aidl.customization.OsmandSettingsParams;
import net.osmand.aidl.customization.OsmandSettingsInfoParams; import net.osmand.aidl.customization.OsmandSettingsInfoParams;
import net.osmand.aidl.customization.CustomizationInfoParams; import net.osmand.aidl.customization.CustomizationInfoParams;
import net.osmand.aidl.customization.ProfileSettingsParams;
import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFile;
import net.osmand.aidl.gpx.AGpxFileDetails; import net.osmand.aidl.gpx.AGpxFileDetails;
@ -93,6 +94,8 @@ import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams;
import net.osmand.aidl.mapmarker.RemoveMapMarkersParams; import net.osmand.aidl.mapmarker.RemoveMapMarkersParams;
import net.osmand.aidl.quickaction.QuickActionParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
interface IOsmAndAidlInterface { interface IOsmAndAidlInterface {
@ -305,6 +308,13 @@ interface IOsmAndAidlInterface {
*/ */
boolean addFavoriteGroup(in AddFavoriteGroupParams params); 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. * Update favorite group with given params.
* *
@ -315,13 +325,6 @@ interface IOsmAndAidlInterface {
* @param colorNew (String) - group color (new). * @param colorNew (String) - group color (new).
* @param visibleNew (boolean) - group visibility (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); boolean updateFavoriteGroup(in UpdateFavoriteGroupParams params);
/** /**
@ -338,6 +341,16 @@ interface IOsmAndAidlInterface {
*/ */
boolean addFavorite(in AddFavoriteParams params); 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. * Update favorite at given location with given params.
* *
@ -356,16 +369,6 @@ interface IOsmAndAidlInterface {
* "lightgreen", "green", "lightblue", "blue", "purple", "pink", "brown". * "lightgreen", "green", "lightblue", "blue", "purple", "pink", "brown".
* @param visibleNew (boolean) - should new category be visible after creation. * @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); boolean updateFavorite(in UpdateFavoriteParams params);
/** /**
@ -846,4 +849,8 @@ interface IOsmAndAidlInterface {
* *
*/ */
boolean getGpxColor(inout GpxColorParams params); boolean getGpxColor(inout GpxColorParams params);
boolean importProfile(in ProfileSettingsParams params);
boolean executeQuickAction(in QuickActionParams params);
} }

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.customization;
parcelable ProfileSettingsParams;

View file

@ -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<ProfileSettingsParams> CREATOR = new Creator<ProfileSettingsParams>() {
@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;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.quickaction;
parcelable QuickActionParams;

View file

@ -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<QuickActionParams> CREATOR = new Creator<QuickActionParams>() {
@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;
}
}

View file

@ -94,6 +94,9 @@ 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.QuickActionInfoParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
interface IOsmAndAidlInterface { interface IOsmAndAidlInterface {
@ -849,4 +852,8 @@ interface IOsmAndAidlInterface {
boolean getGpxColor(inout GpxColorParams params); boolean getGpxColor(inout GpxColorParams params);
boolean importProfile(in ProfileSettingsParams params); boolean importProfile(in ProfileSettingsParams params);
boolean executeQuickAction(in QuickActionParams params);
boolean getQuickActionsInfo(out List<QuickActionInfoParams> quickActions);
} }

View file

@ -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;
@ -63,6 +67,8 @@ import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.IContextMenuButtonListener; import net.osmand.plus.mapcontextmenu.other.IContextMenuButtonListener;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.myplaces.TrackBitmapDrawer; 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.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.IRoutingDataUpdateListener; import net.osmand.plus.routing.IRoutingDataUpdateListener;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
@ -90,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;
@ -167,6 +175,9 @@ public class OsmandAidlApi {
private static final String AIDL_HIDE_SQLITEDB_FILE = "aidl_hide_sqlitedb_file"; 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_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; private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR;
@ -216,6 +227,7 @@ public class OsmandAidlApi {
registerUnmuteNavigationReceiver(mapActivity); registerUnmuteNavigationReceiver(mapActivity);
registerShowSqliteDbFileReceiver(mapActivity); registerShowSqliteDbFileReceiver(mapActivity);
registerHideSqliteDbFileReceiver(mapActivity); registerHideSqliteDbFileReceiver(mapActivity);
registerExecuteQuickActionReceiver(mapActivity);
initOsmandTelegram(); initOsmandTelegram();
app.getAppCustomization().addListener(mapActivity); app.getAppCustomization().addListener(mapActivity);
aMapPointUpdateListener = mapActivity; aMapPointUpdateListener = mapActivity;
@ -824,6 +836,24 @@ public class OsmandAidlApi {
registerReceiver(hideSqliteDbFileReceiver, mapActivity, AIDL_HIDE_SQLITEDB_FILE); registerReceiver(hideSqliteDbFileReceiver, mapActivity, AIDL_HIDE_SQLITEDB_FILE);
} }
private void registerExecuteQuickActionReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> 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<QuickAction> 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) { public void registerMapLayers(@NonNull MapActivity mapActivity) {
for (ConnectedApp connectedApp : connectedApps.values()) { for (ConnectedApp connectedApp : connectedApps.values()) {
connectedApp.registerMapLayers(mapActivity); connectedApp.registerMapLayers(mapActivity);
@ -2110,6 +2140,48 @@ 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;
}
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;

View file

@ -80,6 +80,8 @@ 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.search.SearchParams; import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult; import net.osmand.aidl.search.SearchResult;
import net.osmand.aidl.tiles.ASqliteDbFile; import net.osmand.aidl.tiles.ASqliteDbFile;
@ -1302,6 +1304,28 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
return false; 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;
}
}
@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) {

View file

@ -81,6 +81,8 @@ 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.search.SearchParams; import net.osmand.aidlapi.search.SearchParams;
import net.osmand.aidlapi.search.SearchResult; import net.osmand.aidlapi.search.SearchResult;
import net.osmand.aidlapi.tiles.ASqliteDbFile; import net.osmand.aidlapi.tiles.ASqliteDbFile;
@ -1235,6 +1237,28 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
return false; 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;
}
}
@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) {

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.quickaction;
parcelable QuickActionInfoParams;

View file

@ -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;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.quickaction;
parcelable QuickActionParams;

View file

@ -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<QuickActionParams> CREATOR = new Creator<QuickActionParams>() {
@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;
}
}

View file

@ -36,6 +36,8 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; 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.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; 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_SAVE_GPX = "save_gpx";
public static final String API_CMD_CLEAR_GPX = "clear_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 String API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS = "subscribe_voice_notifications";
public static final int VERSION_CODE = 1; public static final int VERSION_CODE = 1;
@ -139,6 +143,7 @@ public class ExternalApiHelper {
public static final String PARAM_CLOSE_AFTER_COMMAND = "close_after_command"; 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[]{ public static final ApplicationMode[] VALID_PROFILES = new ApplicationMode[]{
ApplicationMode.CAR, ApplicationMode.CAR,
@ -159,6 +164,7 @@ public class ExternalApiHelper {
public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 1005; 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_EMPTY_SEARCH_QUERY = 1006;
public static final int RESULT_CODE_ERROR_SEARCH_LOCATION_UNDEFINED = 1007; 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 MapActivity mapActivity;
private int resultCode; private int resultCode;
@ -589,6 +595,18 @@ public class ExternalApiHelper {
finish = true; finish = true;
} }
resultCode = Activity.RESULT_OK; 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<QuickAction> 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)) { } else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) {
// not implemented yet // not implemented yet
resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED; resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED;