SimformSolutionsPvtLtd / SSImagePicker

Easy to use and configurable library to Pick an image from the Gallery or Capture an image using a Camera... 📸
Apache License 2.0
295 stars 35 forks source link

Feature - New Image Picker - Part 1 #39

Closed priyankj-simform closed 2 years ago

priyankj-simform commented 2 years ago

Add new ImagePickerActivity to display the list of images with folders support. The new Image Picker closes issues #27, #37, and #38.

Part -1 contains the files related to the new image picker's library module.

New Features :

File Changes:

Removed

Modified

Usage:

  1. Add ImagePickerActivity into your AndroidManifest.xml. SSImagePicker is the default theme for image picker activity.

    <activity
    android:name="com.app.imagepickerlibrary.ui.activity.ImagePickerActivity"
    android:theme="@style/SSImagePicker" />
  2. If you want to use Picker options Bottomsheet then implement SSPickerOptionsBottomSheet.ImagePickerClickListener in your fragment or activity. onImageProvider method will give the selected provider type.

    val pickerOptionBottomSheet = SSPickerOptionsBottomSheet.newInstance()
    pickerOptionBottomSheet.show(supportFragmentManager,"tag")
    ....
    override fun onImageProvider(provider: ImageProvider) {
        when (provider) {
            ImageProvider.GALLERY -> {
                //Open gallery
            }
            ImageProvider.CAMERA -> {
                //Open camera
            }
            ImageProvider.NONE -> {}
        }
    }
  1. Open Image Picker from activity or fragment via object of ImagePicker class.
    private val imagePicker: ImagePicker = ImagePicker.with(callback = this)
    imagePicker.open(PickerType.GALLERY, this)
  1. Add customization to the image picker via the image picker object. All the methods with descriptions are declared inside ImagePicker.kt file.

    imagePicker
            .title("My Picker")
            .multipleSelection(enable = true, maxCount = 5)
            .showCountInToolBar(false)
            .showFolder(true)
            .cameraIcon(true)
            .doneIcon(true)
            .allowCropping(true)
            .compressImage(false)
            .maxImageSize(2)
            .extension(PickExtension.JPEG)
    imagePicker.open(PickerType.GALLERY, this)
  2. To get results in activity or fragment implement ImagePickerResultListener.

    class MainActivity : AppCompatActivity(), ImagePickerResultListener {
        ...
    }
  1. Single Selection and The image captured from the camera will be received in onImagePick(uri: Uri?) callback.
    override fun onImagePick(uri: Uri?) {
        //Do something with uri
    }
  2. Multiple Selection uris will be received in onMultiImagePick(uris: List?) callback.
    override fun onMultiImagePick(uris: List<Uri>?) {
        //Do something with uris
    }