Robert Menke

    Robert Menke

    1 year ago
    Is there a compose compatible image picker library out there? Something like this that doesn’t depend on an activity? https://github.com/esafirm/android-image-picker
    i

    Ian Lake

    1 year ago
    Note that with the storage restrictions in recent versions of Android, you should really avoid having an image picker in your own UI, instead relying on
    GET_CONTENT
    to have the user select an image using the standard image picker.
    https://issuetracker.google.com/172690553 tracks making it easy to use the Activity Result API from Compose (but links to the code you can use right now)
    Robert Menke

    Robert Menke

    1 year ago
    Awesome, I found that stackoverflow answer you created just after I posted in here. Great answer! I think I’ll be able to make due with that for now and refactor once the equivalent API is made available from one of the compose libraries. Thanks @Ian Lake!
    gildor

    gildor

    1 year ago
    Note that with the storage restrictions in recent versions of Android, you should really avoid having an image picker in your own UI
    @Ian Lake but isn’t it still possible to have custom file picker on Android 11, it requires READ_EXTERNAL_STORAGE, which provides read only access to files I’m not a fan of custom file picker, but if you check, most of big apps who rely a lot on file picking (like messengers) have custom file picker, and it very sad situation, because overall idea of document open intent is very good, but it for some reason doesn’t work, we also pushed by product to do the same, and I understand this argument, default behaviours of document picker are very strange (like remembering position in completely unrelated pick request with different file type)
    i

    Ian Lake

    1 year ago
    It continues to be a terrible idea that only applies to local files and completely fails to allow photos from Google Photos, Drive, Dropbox, etc. If the user always selects photos from Drive, I don't know why you'd call remembering that a bug - that's working as intended
    gildor

    gildor

    1 year ago
    It continues to be a terrible idea that only applies to local files
    Completely agree about it, but it doesn’t prevent you from still allowing select document picker (though no one allows to do that as I see)
    If the user always selects photos from Drive, I don’t know why you’d call remembering that a bug - that’s working as intended
    Simple use case, we have image picker and audio picker, there is no reason to remember dir with audio files on Google Drive when pick image Also, looks that there are some device specific bugs for file picker
    I kinda in between here, I would love to use system file picker and do not spent time on development and maintaining of this code. But system file picker may be awkward, especially on wide range of devices, and I see why product team of many apps choose to invest to own solution
    i

    Ian Lake

    1 year ago
    Just keep in mind that the storage permission is, by far (double every other permission), the most denied permission and that number of denials goes up and up on every version of Android. You might be losing 50%+ of your users before even getting to your custom file picker.
    gildor

    gildor

    1 year ago
    Good point, thanks