Posted on

Android Smart Image Picker Library Update


android smart image picker library update

 

In this post I introduced a simple library to pick images and crop them if needed. An abstraction over Image Cropper library. Here’re few updates

 

Image Cropper is a great library, but runtime permissions make everything seem more complex. So I decided to build something simpler for a user. And just a clean version of image picker itself, without cropping. So if you’re interested and haven’t tried it yet – check this post

In the current 1.0.2 release there’re several crucial bug fixes:

FileUriExposedExeption

It was called when you start ImagePicker#openCamera on Nougat+. Had to implement starting camera intent with FileProvider

Use different file name for camera

Before I was saving picked images from camera to the file with the same name, as Image Cropper did. It’s easier to do this way, but it gave one annoying bug: ImageView ignores setImageURI method if the URI is the same as the current one, even though the file has changed. See this question

So the simple solution would be to use


For user

Obviously, it’s ugly and completely contradicts the simplicity I want to keep, so now camera saves images to files with different names and deletes previously picked when picked after a new one is picked

Delete all previously cropped images

This bug comes from the Image Cropper library (all cropped images remained), but luckuly it’s pretty easy to do with this code

NPE on ImagePicker#getFIle

It occurred when image was picked without cropping it. And was null simply because I didn’t save a picked file in that case

 

Check the source code here, let me know what you think of it, design, features you’d like to have or bugs that I missed