Merge pull request #4369 from osmandapp/aidl_gpx_recording

Fix #4330
This commit is contained in:
Alexey 2017-08-31 11:28:38 +03:00 committed by GitHub
commit 28207bee87
7 changed files with 135 additions and 0 deletions

View file

@ -22,6 +22,8 @@ import net.osmand.aidl.calculateroute.CalculateRouteParams;
import net.osmand.aidl.gpx.ImportGpxParams;
import net.osmand.aidl.gpx.ShowGpxParams;
import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.gpx.HideGpxParams;
import net.osmand.aidl.gpx.ASelectedGpxFile;
@ -77,4 +79,7 @@ interface IOsmAndAidlInterface {
boolean removeFavorite(in RemoveFavoriteParams params);
boolean updateFavorite(in UpdateFavoriteParams params);
boolean startGpxRecording(in StartGpxRecordingParams params);
boolean stopGpxRecording(in StopGpxRecordingParams params);
}

View file

@ -13,6 +13,8 @@ import net.osmand.IndexConstants;
import net.osmand.aidl.favorite.AFavorite;
import net.osmand.aidl.favorite.group.AFavoriteGroup;
import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.maplayer.AMapLayer;
import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.mapmarker.AMapMarker;
@ -29,9 +31,11 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.views.AidlMapLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer;
@ -841,4 +845,24 @@ public class OsmandAidlApi {
app.sendBroadcast(intent);
return true;
}
boolean startGpxRecording(StartGpxRecordingParams params) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
plugin.startGPXMonitoring(null);
plugin.updateControl();
return true;
}
return false;
}
boolean stopGpxRecording(StopGpxRecordingParams params) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
plugin.stopRecording();
plugin.updateControl();
return true;
}
return false;
}
}

View file

@ -16,6 +16,8 @@ import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.gpx.HideGpxParams;
import net.osmand.aidl.gpx.ImportGpxParams;
import net.osmand.aidl.gpx.ShowGpxParams;
import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.map.SetMapLocationParams;
import net.osmand.aidl.maplayer.AddMapLayerParams;
import net.osmand.aidl.maplayer.RemoveMapLayerParams;
@ -320,5 +322,23 @@ public class OsmandAidlService extends Service {
return true;
}
}
@Override
public boolean startGpxRecording(StartGpxRecordingParams params) throws RemoteException {
try {
return getApi().startGpxRecording(params);
} catch (Exception e) {
return false;
}
}
@Override
public boolean stopGpxRecording(StopGpxRecordingParams params) throws RemoteException {
try {
return getApi().stopGpxRecording(params);
} catch (Exception e) {
return false;
}
}
};
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.gpx;
parcelable StartGpxRecordingParams;

View file

@ -0,0 +1,40 @@
package net.osmand.aidl.gpx;
import android.os.Parcel;
import android.os.Parcelable;
public class StartGpxRecordingParams implements Parcelable {
public StartGpxRecordingParams() {
}
public StartGpxRecordingParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<StartGpxRecordingParams> CREATOR = new Creator<StartGpxRecordingParams>() {
@Override
public StartGpxRecordingParams createFromParcel(Parcel in) {
return new StartGpxRecordingParams(in);
}
@Override
public StartGpxRecordingParams[] newArray(int size) {
return new StartGpxRecordingParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.gpx;
parcelable StopGpxRecordingParams;

View file

@ -0,0 +1,40 @@
package net.osmand.aidl.gpx;
import android.os.Parcel;
import android.os.Parcelable;
public class StopGpxRecordingParams implements Parcelable {
public StopGpxRecordingParams() {
}
public StopGpxRecordingParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<StopGpxRecordingParams> CREATOR = new Creator<StopGpxRecordingParams>() {
@Override
public StopGpxRecordingParams createFromParcel(Parcel in) {
return new StopGpxRecordingParams(in);
}
@Override
public StopGpxRecordingParams[] newArray(int size) {
return new StopGpxRecordingParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}