Fix exception with permission

This commit is contained in:
Victor Shcherb 2018-05-25 10:03:37 +02:00
parent b48fcdf0f3
commit 50f9ddbcd5

View file

@ -907,27 +907,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
} }
public void recordVideo(final double lat, final double lon, final MapActivity mapActivity, final boolean forceExternal) { public void recordVideo(final double lat, final double lon, final MapActivity mapActivity,
if (AV_EXTERNAL_RECORDER.get() || forceExternal) { final boolean forceExternal) {
captureVideoExternal(lat, lon, mapActivity); if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
} else { && ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) if (AV_EXTERNAL_RECORDER.get() || forceExternal) {
== PackageManager.PERMISSION_GRANTED captureVideoExternal(lat, lon, mapActivity);
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) } else {
== PackageManager.PERMISSION_GRANTED) {
openCamera(); openCamera();
if (cam != null) { if (cam != null) {
initRecMenu(AVActionType.REC_VIDEO, lat, lon); initRecMenu(AVActionType.REC_VIDEO, lat, lon);
recordVideoCamera(lat, lon, mapActivity); recordVideoCamera(lat, lon, mapActivity);
} }
} else {
actionLat = lat;
actionLon = lon;
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO},
CAMERA_FOR_VIDEO_REQUEST_CODE);
} }
} else {
actionLat = lat;
actionLon = lon;
ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO }, CAMERA_FOR_VIDEO_REQUEST_CODE);
} }
} }
public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) { public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) {