kroegerama / bottomsheet-imagepicker

Modern image picker for Android
Apache License 2.0
326 stars 48 forks source link

Android 13 Permissions Issue #26

Open MigSalsa opened 1 year ago

MigSalsa commented 1 year ago

Since Android 13 removed the storage permission, the BottomSheetImagePicker.Builder is no longer working because when it goes to BottomSeetImagePicker's onCreate, it goest into the else of the ReadStoragePermission has if it had no permission and get's stuck on a loop on PermissionUtils, because android 13 does not ask for that permission

BikramDroid commented 1 year ago

Any update on this issue?

MigSalsa commented 1 year ago

well we manage to find a workaround this issue, before calling the BottomSheetImagePicker.Builder we added the pickMultipleMedia native method.

if(Build.VERSION.SDK_INT >= 33) { pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) }

final product for this was the following :

if(ContextCompat.checkSelfPermission(requireContext(), permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(requireContext(), permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { if(Build.VERSION.SDK_INT >= 33) { pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) } else { try { BottomSheetImagePicker.Builder(BuildConfig.APPLICATION_ID + ".provider") .cameraButton(ButtonType.Button) .galleryButton(ButtonType.Button) .multiSelect(1, maxAllowed) .peekHeight(R.dimen.peekHeight)

                    .columnSize(R.dimen.columnSize)
                    .requestTag("multi")
                    .show(childFragmentManager, null)
            } catch (e: Exception) {
                Log.e("ERROR", e.toString())
            }
        }

    } else {
        requestStoragePermission()
    }
siavash-kadkhodai commented 10 months ago

pls upgrade this library for android api 33 and more!!!

this is not work for me

kroegerama commented 10 months ago

Please migrate your apps to registerForActivityResult with PickVisualMedia: https://developer.android.com/training/data-storage/shared/photopicker

I'm gonna archive this repo, because it does not make sense anymore to maintain nowadays.