Api fixes
This commit is contained in:
parent
53a4073246
commit
bc967c5521
2 changed files with 20 additions and 13 deletions
|
@ -622,7 +622,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
takePhoto(latitude, longitude, mapActivity);
|
takePhoto(latitude, longitude, mapActivity, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
if (action == AV_DEFAULT_ACTION_VIDEO) {
|
if (action == AV_DEFAULT_ACTION_VIDEO) {
|
||||||
recordVideo(lat, lon, mapActivity);
|
recordVideo(lat, lon, mapActivity);
|
||||||
} else if (action == AV_DEFAULT_ACTION_TAKEPICTURE) {
|
} else if (action == AV_DEFAULT_ACTION_TAKEPICTURE) {
|
||||||
takePhoto(lat, lon, mapActivity);
|
takePhoto(lat, lon, mapActivity, false);
|
||||||
} else if (action == AV_DEFAULT_ACTION_AUDIO) {
|
} else if (action == AV_DEFAULT_ACTION_AUDIO) {
|
||||||
recordAudio(lat, lon, mapActivity);
|
recordAudio(lat, lon, mapActivity);
|
||||||
}
|
}
|
||||||
|
@ -1111,13 +1111,14 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takePhoto(final double lat, final double lon, final MapActivity mapActivity) {
|
public void takePhoto(final double lat, final double lon, final MapActivity mapActivity,
|
||||||
|
final boolean forceInternal) {
|
||||||
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
|
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
|
||||||
== PackageManager.PERMISSION_GRANTED) {
|
== PackageManager.PERMISSION_GRANTED) {
|
||||||
if (AV_EXTERNAL_PHOTO_CAM.get()) {
|
if (!AV_EXTERNAL_PHOTO_CAM.get() || forceInternal) {
|
||||||
takePhotoExternal(lat, lon, mapActivity);
|
|
||||||
} else {
|
|
||||||
takePhotoInternalOrExternal(lat, lon, mapActivity);
|
takePhotoInternalOrExternal(lat, lon, mapActivity);
|
||||||
|
} else {
|
||||||
|
takePhotoExternal(lat, lon, mapActivity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actionLat = lat;
|
actionLat = lat;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -243,7 +244,7 @@ public class ExternalApiHelper {
|
||||||
} else if (API_CMD_RECORD_VIDEO.equals(cmd)) {
|
} else if (API_CMD_RECORD_VIDEO.equals(cmd)) {
|
||||||
plugin.recordVideo(lat, lon, mapActivity);
|
plugin.recordVideo(lat, lon, mapActivity);
|
||||||
} else if (API_CMD_RECORD_PHOTO.equals(cmd)) {
|
} else if (API_CMD_RECORD_PHOTO.equals(cmd)) {
|
||||||
plugin.takePhoto(lat, lon, mapActivity);
|
plugin.takePhoto(lat, lon, mapActivity, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,9 +306,7 @@ public class ExternalApiHelper {
|
||||||
FavouritesDbHelper helper = app.getFavorites();
|
FavouritesDbHelper helper = app.getFavorites();
|
||||||
helper.addFavourite(fav);
|
helper.addFavourite(fav);
|
||||||
|
|
||||||
mapActivity.getContextMenu().show(new LatLon(lat, lon),
|
showOnMap(lat, lon, fav, mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav));
|
||||||
mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav), fav);
|
|
||||||
|
|
||||||
resultCode = RESULT_CODE_OK;
|
resultCode = RESULT_CODE_OK;
|
||||||
|
|
||||||
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
|
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
|
||||||
|
@ -323,10 +322,8 @@ public class ExternalApiHelper {
|
||||||
|
|
||||||
MapMarker marker = markersHelper.getFirstMapMarker();
|
MapMarker marker = markersHelper.getFirstMapMarker();
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
mapActivity.getContextMenu().show(new LatLon(lat, lon),
|
showOnMap(lat, lon, marker, mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker));
|
||||||
mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker), marker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultCode = RESULT_CODE_OK;
|
resultCode = RESULT_CODE_OK;
|
||||||
|
|
||||||
} else if (API_CMD_START_GPX_REC.equals(cmd)) {
|
} else if (API_CMD_START_GPX_REC.equals(cmd)) {
|
||||||
|
@ -362,6 +359,15 @@ public class ExternalApiHelper {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showOnMap(double lat, double lon, Object object, PointDescription pointDescription) {
|
||||||
|
MapContextMenu mapContextMenu = mapActivity.getContextMenu();
|
||||||
|
mapContextMenu.setMapCenter(new LatLon(lat, lon));
|
||||||
|
mapContextMenu.setMapPosition(mapActivity.getMapView().getMapPosition());
|
||||||
|
mapContextMenu.setCenterMarker(true);
|
||||||
|
mapContextMenu.setMapZoom(15);
|
||||||
|
mapContextMenu.show(new LatLon(lat, lon), pointDescription, object);
|
||||||
|
}
|
||||||
|
|
||||||
private void startNavigation(GPXFile gpx,
|
private void startNavigation(GPXFile gpx,
|
||||||
LatLon from, PointDescription fromDesc,
|
LatLon from, PointDescription fromDesc,
|
||||||
LatLon to, PointDescription toDesc,
|
LatLon to, PointDescription toDesc,
|
||||||
|
|
Loading…
Reference in a new issue