Repository: cordova-plugin-camera Updated Branches: refs/heads/compat [created] 9b6d91009
Use Android compat libs for permission Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/9b6d9100 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/9b6d9100 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/9b6d9100 Branch: refs/heads/compat Commit: 9b6d91009d6dea1cdea0304fe6ef36224d05506e Parents: e219363 Author: Simon MacDonald <[email protected]> Authored: Fri Jan 8 13:32:00 2016 -0500 Committer: Simon MacDonald <[email protected]> Committed: Fri Jan 8 13:32:00 2016 -0500 ---------------------------------------------------------------------- plugin.xml | 14 ++++++++------ src/android/CameraLauncher.java | 11 ++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9b6d9100/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index 673761e..fa66f86 100644 --- a/plugin.xml +++ b/plugin.xml @@ -54,12 +54,12 @@ <feature name="Camera"> <param name="firefoxos-package" value="Camera" /> </feature> - </config-file> - + </config-file> + <js-module src="src/firefoxos/CameraProxy.js" name="CameraProxy"> <runs /> </js-module> - </platform> + </platform> <!-- android --> <platform name="android"> @@ -80,6 +80,8 @@ <clobbers target="CameraPopoverHandle" /> </js-module> + <framework src="com.android.support:support-v4:23+" /> + </platform> <!-- amazon-fireos --> @@ -102,7 +104,7 @@ </js-module> </platform> - + <!-- ubuntu --> <platform name="ubuntu"> <config-file target="config.xml" parent="/*"> @@ -151,11 +153,11 @@ <framework src="MobileCoreServices.framework" /> <framework src="CoreGraphics.framework" /> <framework src="AVFoundation.framework" /> - + <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription"> <string></string> </config-file> - + </platform> <!-- blackberry10 --> http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9b6d9100/src/android/CameraLauncher.java ---------------------------------------------------------------------- diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index ff8599b..7eb36e1 100644 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -58,6 +58,9 @@ import android.provider.MediaStore; import android.util.Base64; import android.util.Log; import android.content.pm.PackageManager; + +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; /** * This class launches the camera view, allows the user to take a picture, closes the camera view, * and returns the captured image. When the camera view is closed, the screen displayed before @@ -117,7 +120,9 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect protected void getReadPermission(int requestCode) { - cordova.requestPermission(this, requestCode, Manifest.permission.READ_EXTERNAL_STORAGE); + ActivityCompat.requestPermissions(cordova.getActivity(), + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + requestCode); } /** @@ -178,7 +183,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect // preserve the original exif data and filename in the modified file that is // created if(this.mediaType == PICTURE && (this.destType == FILE_URI || this.destType == NATIVE_URI) - && fileWillBeModified() && !cordova.hasPermission(permissions[0])) { + && fileWillBeModified() && !(ContextCompat.checkSelfPermission(cordova.getActivity(), permissions[0]) == PackageManager.PERMISSION_GRANTED)) { getReadPermission(SAVE_TO_ALBUM_SEC); } else { this.getImage(this.srcType, destType, encodingType); @@ -238,7 +243,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect * @param returnType Set the type of image to return. */ public void callTakePicture(int returnType, int encodingType) { - if (cordova.hasPermission(permissions[0])) { + if (ContextCompat.checkSelfPermission(cordova.getActivity(), permissions[0]) == PackageManager.PERMISSION_GRANTED) { takePicture(returnType, encodingType); } else { getReadPermission(TAKE_PIC_SEC); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
