ProPicker — A library for Android to pick any files (images/videos/files)

Ashiqul Islam Shaon
3 min readOct 25, 2020
ProPicker

There are a lot of libraries out there to pick images from the gallery and capture an image and then crop the image.

These functionalities serve by few libraries. But what is new in the ProPicker library? When I was working on this library I always ask myself this question. I am an Android Developer with over 4 years of experience, so I know what an Android Developer wants, what will make out work easy. Keep these thoughts on my mind I am developing this library.

This is just the beginning. This is not an ordinary library that you see and then you ignore.

It now supports image capture, image pick from the gallery, and cropping using uCrop library.

Features

  • CameraX — It uses CameraX library to capture an image.
  • UCrop — To Crop an image.
  • Permissions — It handles all the necessary permissions for you.

There will be support for File pick, videos pick, scanner, and lots of features. You can suggest any feature you want to see in this library.

We have talked so much. Now let’s dive in.

let’s add the ProPicker to our project.

— — — — — — — — — — — — — —

Step 1. Add the JitPack repository to your build file

allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}

Step 2. Add the dependency

dependencies {
implementation 'com.github.shaon2016:ProPicker:1.0.1'
}

Add this in your build.gradle app module

android {

//.........

kotlinOptions {
jvmTarget = "1.8"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

Start Pro image picker activity

This is a simple way to start using this library.

ProPicker.with(this)
.start { resultCode, data ->
if (resultCode == RESULT_OK && data != null) {
val list = ProPicker.getSelectedPickerDatas(data)

if (list.size > 0) {
iv.setImageURI(list[0].uri)
}
}
}

This library makes it easier to handle the result. You can handle the result within your code. No need to worry about onActivityResult any more.

Here we are getting all the images we pick and choose the first one to show in our view using its URI.

Let’s see in more details……

             ProPicker.with(this)
.cameraOnly()
.crop()
.start { resultCode, data ->
if (resultCode == RESULT_OK && data != null) {
val picker = ProPicker.getPickerData(data)

iv.setImageURI(picker?.uri)

}
}

This code starts the camera and it supports cropping. Here we use the new CameraX library for camera view. If new functionality comes we will add those to this library.

For Gallery

            ProPicker.with(this)
.galleryOnly()
.start { resultCode, data ->
if (resultCode == RESULT_OK && data != null) {
val list = ProPicker.getSelectedPickerDatas(data)
if (list.size > 0) {
Glide.with(this)
.load(list[0].file)
.into(iv)
}
}
}

Functions that offers this library

For Camera

  1. cameraOnly() -> To open the CameraX only
  2. crop() -> Only works with camera
  3. compressImage -> compresing image work for both gallery and camera

Gallery related function

  1. galleryOnly() -> To open the gallery view only
  2. singleSelection -> Pick single file
  3. multiSelection -> Pick multi file and get the result as ArrayList
  4. maxResultSize -> Max Width and Height of final image
  5. compressImage -> compresing image work for both gallery and camera
  6. compressVideo -> (Under Development)
  7. onlyImage -> Select image from gallery
  8. onlyVideo -> Select video from gallery

Receiver the result

  1. ProPicker.getPickerDataAsByteArray(this, intent) -> Returns all the data as ByteArray
  2. ProPicker.getSelectedPickerDatas(intent: Intent) -> Get all the data
  3. ProPicker.getPickerData(intent: Intent) -> Get single data

Give it a star and support it and give me any feedback to enhance its functionality.

Thanks for the reading……..

--

--