From 50f9ddbcd5587d3998c5b36aa4e36fa22ee2f798 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 25 May 2018 10:03:37 +0200 Subject: [PATCH] Fix exception with permission --- .../audionotes/AudioVideoNotesPlugin.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 887027c7d9..13376edd5b 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -907,27 +907,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } } - public void recordVideo(final double lat, final double lon, final MapActivity mapActivity, final boolean forceExternal) { - if (AV_EXTERNAL_RECORDER.get() || forceExternal) { - captureVideoExternal(lat, lon, mapActivity); - } else { - if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) - == PackageManager.PERMISSION_GRANTED - && ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) - == PackageManager.PERMISSION_GRANTED) { + public void recordVideo(final double lat, final double lon, final MapActivity mapActivity, + final boolean forceExternal) { + if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED + && ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) { + if (AV_EXTERNAL_RECORDER.get() || forceExternal) { + captureVideoExternal(lat, lon, mapActivity); + } else { openCamera(); if (cam != null) { initRecMenu(AVActionType.REC_VIDEO, lat, lon); 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) {