Fix #8862
This commit is contained in:
parent
100561be7b
commit
da1a065846
9 changed files with 162 additions and 0 deletions
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.quickaction;
|
||||
|
||||
parcelable QuickActionParams;
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<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) {
|
||||
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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.quickaction;
|
||||
|
||||
parcelable QuickActionParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue