Api fixes

This commit is contained in:
Alexey Kulish 2016-03-16 19:10:28 +03:00
parent 53a4073246
commit bc967c5521
2 changed files with 20 additions and 13 deletions

View file

@ -622,7 +622,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
takePhoto(latitude, longitude, mapActivity);
takePhoto(latitude, longitude, mapActivity, false);
return true;
}
@ -741,7 +741,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (action == AV_DEFAULT_ACTION_VIDEO) {
recordVideo(lat, lon, mapActivity);
} else if (action == AV_DEFAULT_ACTION_TAKEPICTURE) {
takePhoto(lat, lon, mapActivity);
takePhoto(lat, lon, mapActivity, false);
} else if (action == AV_DEFAULT_ACTION_AUDIO) {
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)
== PackageManager.PERMISSION_GRANTED) {
if (AV_EXTERNAL_PHOTO_CAM.get()) {
takePhotoExternal(lat, lon, mapActivity);
} else {
if (!AV_EXTERNAL_PHOTO_CAM.get() || forceInternal) {
takePhotoInternalOrExternal(lat, lon, mapActivity);
} else {
takePhotoExternal(lat, lon, mapActivity);
}
} else {
actionLat = lat;

View file

@ -23,6 +23,7 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.util.Algorithms;
@ -243,7 +244,7 @@ public class ExternalApiHelper {
} else if (API_CMD_RECORD_VIDEO.equals(cmd)) {
plugin.recordVideo(lat, lon, mapActivity);
} 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();
helper.addFavourite(fav);
mapActivity.getContextMenu().show(new LatLon(lat, lon),
mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav), fav);
showOnMap(lat, lon, fav, mapActivity.getMapLayers().getFavoritesLayer().getObjectName(fav));
resultCode = RESULT_CODE_OK;
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
@ -323,10 +322,8 @@ public class ExternalApiHelper {
MapMarker marker = markersHelper.getFirstMapMarker();
if (marker != null) {
mapActivity.getContextMenu().show(new LatLon(lat, lon),
mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker), marker);
showOnMap(lat, lon, marker, mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker));
}
resultCode = RESULT_CODE_OK;
} else if (API_CMD_START_GPX_REC.equals(cmd)) {
@ -362,6 +359,15 @@ public class ExternalApiHelper {
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,
LatLon from, PointDescription fromDesc,
LatLon to, PointDescription toDesc,