diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCamera.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCamera.java index e0a61b7..946c989 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCamera.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCamera.java @@ -91,19 +91,16 @@ public static int CheckPermission( Context context, final boolean isPicturePermi if( context.checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED ) return 0; } - else if( isPicturePermission ) + else if( Build.VERSION.SDK_INT < 34 && context.checkSelfPermission( isPicturePermission ? "android.permission.READ_MEDIA_IMAGES" : "android.permission.READ_MEDIA_VIDEO" ) != PackageManager.PERMISSION_GRANTED ) { - if( context.checkSelfPermission( "android.permission.READ_MEDIA_IMAGES" ) != PackageManager.PERMISSION_GRANTED ) - return 0; - } - else - { - if( context.checkSelfPermission( "android.permission.READ_MEDIA_VIDEO" ) != PackageManager.PERMISSION_GRANTED ) - return 0; + // On Android 14+ (34), partial media access permission is introduced which we want to avoid in a camera app (it'd be confusing for the end user): + // https://developer.android.com/about/versions/14/changes/partial-photo-video-access + // We're hoping that by now, the native camera apps have become smart enough to avoid saving the captured media to Gallery. + return 0; } } - // Credit: https://blog.egorand.me/taking-photos-not-so-simply-how-i-got-bitten-by-action_image_capture/ + // If CAMERA permission is declared, we must request it: https://developer.android.com/reference/android/provider/MediaStore#ACTION_IMAGE_CAPTURE if( NativeCameraUtils.IsPermissionDefinedInManifest( context, Manifest.permission.CAMERA ) && context.checkSelfPermission( Manifest.permission.CAMERA ) != PackageManager.PERMISSION_GRANTED ) return 0; diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraPermissionFragment.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraPermissionFragment.java index c6b2423..6111160 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraPermissionFragment.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraPermissionFragment.java @@ -67,19 +67,18 @@ public void onCreate( Bundle savedInstanceState ) if( Build.VERSION.SDK_INT < 33 || getActivity().getApplicationInfo().targetSdkVersion < 33 ) permissions.add( Manifest.permission.READ_EXTERNAL_STORAGE ); - else - { - boolean isPicturePermission = getArguments().getBoolean( PICTURE_PERMISSION_ID ); - if( isPicturePermission ) - permissions.add( "android.permission.READ_MEDIA_IMAGES" ); - else - permissions.add( "android.permission.READ_MEDIA_VIDEO" ); - } + else if( Build.VERSION.SDK_INT < 34 ) + permissions.add( getArguments().getBoolean( PICTURE_PERMISSION_ID ) ? "android.permission.READ_MEDIA_IMAGES" : "android.permission.READ_MEDIA_VIDEO" ); - String[] permissionsArray = new String[permissions.size()]; - permissions.toArray( permissionsArray ); + if( permissions.size() > 0 ) + { + String[] permissionsArray = new String[permissions.size()]; + permissions.toArray( permissionsArray ); - requestPermissions( permissionsArray, PERMISSIONS_REQUEST_CODE ); + requestPermissions( permissionsArray, PERMISSIONS_REQUEST_CODE ); + } + else + onRequestPermissionsResult( PERMISSIONS_REQUEST_CODE, new String[0], new int[0] ); } } diff --git a/Plugins/NativeCamera/Android/NativeCamera.aar b/Plugins/NativeCamera/Android/NativeCamera.aar index f318876..81d4ba2 100644 Binary files a/Plugins/NativeCamera/Android/NativeCamera.aar and b/Plugins/NativeCamera/Android/NativeCamera.aar differ diff --git a/Plugins/NativeCamera/NativeCamera.cs b/Plugins/NativeCamera/NativeCamera.cs index 0d69e8b..f6cdd09 100644 --- a/Plugins/NativeCamera/NativeCamera.cs +++ b/Plugins/NativeCamera/NativeCamera.cs @@ -179,7 +179,7 @@ public static Permission RequestPermission( bool isPicturePermission ) { NCPermissionCallbackAndroid nativeCallback = new NCPermissionCallbackAndroid( threadLock ); - AJC.CallStatic( "RequestPermission", Context, nativeCallback, isPicturePermission, PlayerPrefs.GetInt( "NativeCameraPermission", (int) Permission.ShouldAsk ) ); + AJC.CallStatic( "RequestPermission", Context, nativeCallback, isPicturePermission, (int) Permission.ShouldAsk ); if( nativeCallback.Result == -1 ) System.Threading.Monitor.Wait( threadLock ); diff --git a/Plugins/NativeCamera/README.txt b/Plugins/NativeCamera/README.txt index 8884b69..6b27ab4 100644 --- a/Plugins/NativeCamera/README.txt +++ b/Plugins/NativeCamera/README.txt @@ -1,4 +1,4 @@ -= Native Camera for Android & iOS (v1.3.8) = += Native Camera for Android & iOS (v1.3.9) = Online documentation & example code available at: https://github.com/yasirkula/UnityNativeCamera E-mail: yasirkula@gmail.com diff --git a/package.json b/package.json index 6c74184..0b7454b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.nativecamera", "displayName": "Native Camera", - "version": "1.3.8", + "version": "1.3.9", "documentationUrl": "https://github.com/yasirkula/UnityNativeCamera", "changelogUrl": "https://github.com/yasirkula/UnityNativeCamera/releases", "licensesUrl": "https://github.com/yasirkula/UnityNativeCamera/blob/master/LICENSE.txt",