fabian7593 / MagicalCamera

A library to take picture easy, transform your data in different format and save photos in your device
Apache License 2.0
338 stars 90 forks source link

Permission Problem After Marshmallow #38

Open WrathChaos opened 6 years ago

WrathChaos commented 6 years ago

Hello, Thanks for great library. I got a problem about permissions.. If user has no permissions on Camera and Storage, MagicalCamera itself cannot handle it and "return mapPermissions?.get(permission)!!" returns NullPointerException. (Tried on both Java and Kotlin)


 private fun isActivePermission(permission: String): Boolean {
        // This map is return in method onRequestPermissionsResult for view what permissions are actives
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            if (mapPermissions != null) {
                if (mapPermissions!!.size > 0) {
                    // Obtain the code of camera permissions
                     return mapPermissions?.get(permission)!!
                } else {
                    return true
                }
            } else {
                return true
            }
        } else {
            return true
        }
    }

I could not solve the problem, please help me. Thank you

WrathChaos commented 6 years ago

Edit: Solved the issue but the main issue is still remaining.. Waiting for a response. Edit2: I have another problem; when I pick a photo from gallery, MagicalCamera simply duplicate the selected photo and create the one more same photo. How to fix this issue? Thank you, Have fun :)

fabian7593 commented 6 years ago

Hello @WrathChaos , thanks for use magical camera project, and thanks for report the issues. I need to review the first issue, but I never thought that someone use magical camera withouth permissions. and for issue 2, I do not understand the problem very well, magical camera dont duplicate photo if you not required this, for example if you dont save the selected picture, well, its occurs to me that verify if photo is selected or new photo, for save this or not...

WrathChaos commented 6 years ago

Hello @fabian7593, I use magical camera with permissions, but after Marshmallow we have to ask user to request permissions. Even I got the permissions, "return mapPermissions?.get(permission)!!" this part never works for me after Marshmallow. I just return true but then I have to ask that part 2 times in a row to open the camera or library. I could not figure it out :( I will share my codes about the duplicate problem.. Then I believe that you can re-produce my issue :)

Thank you