Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera.

Overview

📸 SSImagePicker

Android-Studio API Language

Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera.

  • You can easily select image from camera and gallery and upload it wherever you want. We have created this library to simplify pick or capture image feature.
  • Handled permissions for camera and gallery, also supports scoped storage.
  • Returns contentUri of selected image.
  • Easy to use and supports all major devices.

Features :

  • Capture Image Using Camera
  • Pick Image From Gallery
  • Handle Runtime Permission For Storage And Camera
  • ImagePicker Bottomsheet
  • Retrieve Image Result In Uri Format
  • Crop Image
  • Rotate Image
  • Image Zoom In, Zoom Out
  • Customize Image Picker BottomSheet Options Like :
    • Customize only text of buttons
    • Customize only text color of buttons
    • Customize multiple values of buttons like:
      • Text color, size, font family, padding using your own styles.xml
    • Customize bottomsheet's background shape and color

🎬 Preview

Capture Image Using Camera Pick Image From Gallery Customize Bottomsheet
Crop Image Rotate Image Image Zoom in, Zoom out

How it works:

  1. Gradle Dependency
  • Add the JitPack repository to your project's build.gradle file
    allprojects {
        repositories {
            ...
    	    maven { url 'https://jitpack.io' }
        }
    }
  • Add plugin in your app's build.gradle file
    plugins {
        ...
        id 'kotlin-kapt'
    } 
  • Add buildFeature in your app's build.gradle file
    android {
        ...
        buildFeatures {
            dataBinding = true
        }
    }
  • Add the dependency in your app's build.gradle file
    dependencies {
        implementation 'com.github.SimformSolutionsPvtLtd:SSImagePicker:1.6'
    }
  1. Implement ImagePickerBottomsheet.ItemClickListener, ImagePickerActivityClass.OnResult interface in your activity or fragment

  2. Use ImagePicker Bottomsheet To Choose Option For Pick Image From Gallery Or Camera

    val fragment = ImagePickerBottomsheet()
    fragment.show(FragmentManager, String) 
  1. Call ImagePickerActivityClass in your onCreate() To Handle Camera, Gallery Click And Permission Result. Pass Context, Request Permission Result Callback And activityResultRegistry, Activity or Fragment. :
    //From activity
    var imagePicker = ImagePickerActivityClass(context,onResult_Callback,activityResultRegistry,activity = this)

    //From fragment
    var imagePicker = ImagePickerActivityClass(context,onResult_Callback,activityResultRegistry,fragment = this)
  1. To Enable All Features(crop,rotate,zoomIn,zoomOut) call cropOptions(isAllCropFeaturesRequired: Boolean) And Pass true. By Default It's Set To False And Provides Only Crop Feature.
    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        imagePicker.cropOptions(true)
    }
  1. Allow Camera And Storage Permission To Pick Image And Send Your onRequestPermissionsResult To ImagePickerActivity
    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults) (required)
    }
  1. To Capture Image From Camera Use takePhotoFromCamera()
    imagePicker.takePhotoFromCamera()
  1. To Pick Image From Gallery Use choosePhotoFromGallary()
    imagePicker.choosePhotoFromGallary()
  1. Send Your onActivityResult to ImagePickerActivity
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)  (required)
        imagePicker.onActivityResult(requestCode, resultCode, data)
    }
  1. You Will Get Image Result In Uri Format In returnString() And Customize It To Upload
    override fun returnString(item: Uri?) {
        **Here You Will Get Your Image Result In Uri Format**
    }
  1. You can load image in your imageview using loadImage() func. (If you want to apply circleCrop() then pass isCircle = true, by default it's false)
    override fun returnString(item: Uri?) {
        imageViewEditProfile.loadImage(item, isCircle = true) {}
    }

To customize bottomsheet:

  • To customize bottomsheet, first override below method in your activity.
    override fun doCustomisations(fragment: ImagePickerBottomsheet) {
        //Do customizations here...
    }
  • To customize text of buttons in Bottomsheet.
    fragment.setButtonText("Select Camera","Select Gallery","Remove")
  • To only change text color of buttons in Bottomsheet.
    fragment.setButtonColors(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
  • To customize multiple values of buttons (Text color, size, font family, padding), you need to create a style in your style.xml.
    fragment.setTextAppearance(R.style.fontForNotificationLandingPage)

In styles.xml (Note: parent must be "Widget.AppCompat.TextView")

@font/poppins_medium @color/white @dimen/_18ssp ">
    <style name="fontForNotificationLandingPage" parent="Widget.AppCompat.TextView">
        <item name="android:fontFamily">@font/poppins_mediumitem>
        <item name="android:textColor">@color/whiteitem>
        <item name="android:textSize">@dimen/_18sspitem>
    style>

Note: if setTextAppearance and setButtonColors both are used than whichever function is last called will override other one.

  • To change bottomsheet's background (shape, color).
    fragment.setBottomSheetBackgroundStyle(R.drawable.drawable_bottom_sheet_dialog)

You need to make one drawable file of type shape.

">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners
            android:topLeftRadius="@dimen/_25sdp"
            android:topRightRadius="@dimen/_25sdp" />
        <padding android:top="@dimen/_5sdp" />
        <solid android:color="@color/colorPrimary" />
    shape>

Other Library used:

Find this library useful? ❤️

Support it by joining stargazers for this repository.

License

Copyright 2020 Simform Solutions

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and limitations under the License.
Comments
  • Free Hand Cropping

    Free Hand Cropping

    Thanks for developing a useful library. It would be really great if you add a new feature "free hand crop" where we can pick comers and adjust ratios.

    opened by vedraj360 11
  • Permissions handling on android 11+

    Permissions handling on android 11+

    Hello, i have a xiaomi phone and recently my phone api as been updated to android 11. So now when i open the bottomsheet dialog with any trigger , he do his work but i don't have any access to a file. I make some chearch and i see that when you target android 11+ asking read and write permission they not sufficient to have the permissions. I don't know if i'm wrong. Thank you for reply this.

    opened by llastkrakw 7
  • Free crop functionality added

    Free crop functionality added

    Added functionality -> "free hand crop" where we can pick comers and adjust ratios . Have used https://github.com/ArthurHub/Android-Image-Cropper library for cropping which is actively maintained.

    Just set imagePicker.setFreeCrop(true)

    output -> https://i.imgur.com/9JTAsrg.png

    opened by vedraj360 3
  • Call from fragment

    Call from fragment

    Can you modify it so i'm able to call it from a fragment ?

    override fun onAttach(context: Context) {
          super.onAttach(context)
          mListener = if (context is ItemClickListener) {
              context
          } else {
              throw RuntimeException("$context")
          }
      }
    

    the if condition always fails and throws RuntimeException imagePicker = ImagePickerActivityClass(requireContext(), requireActivity(), this, requireActivity().activityResultRegistry)

    opened by OmarELRayes 3
  • The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

    The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

    If I already have an installed app with this library and I try to installed another app I am getting the following error

    The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

    I think the authorities for the file provider in the manifest are the same so that why it is conflicting.

    android:authorities="com.app.imagepickerlibrary.provider"

    opened by shafayatb 2
  • open failed: ENOENT (No such file or directory)

    open failed: ENOENT (No such file or directory)

    file:/storage/emulated/0/Android/data/com.abc.customer/files/Pictures/JPEG_20210503_232332_6233313561642340468.jpg: open failed: ENOENT (No such file or directory)

    Not able to get file from returned String Device Android 10

    opened by ArisChoice 2
  • :pencil: Update README.md

    :pencil: Update README.md

    Update the README.md with the all-new library banner and new gifs.

    Changes :

    • :zap: New GIFs according to the new picker demo theme.
    • :pencil: Update license to MIT from Apache.

    Major File Changes:

    :heavy_plus_sign: Added

    • New gifs to show picker demo.

    :heavy_minus_sign: Removed

    • Removed old gifs and library banner.
    opened by priyankj-simform 0
  • :zap: Update feature - New Picker Demo

    :zap: Update feature - New Picker Demo

    Update the ImagePicker demo with a new theme and all the supported functionality with picker UI modifications.

    Update Features :

    • :sparkles: New image picker demo with all customizable methods.
    • :sparkles: Custom UI support to demonstrate usage of UI attributes of picker screen in your own custom layout.

    Major File Changes:

    :heavy_plus_sign: Added

    • PickerOptionsBottomSheet.kt - Added picker options bottom sheet to display all the configuration options of the image picker.

    :construction: Modified

    • themes.xml - Modified themes file to add custom attributes related to the picker demo screen. The demo screen theme is modified for both light and dark modes.
    • build.gradle.kts (app) - Added parcelize kotlin plugin.

    :books: Usage:

    • You can run the demo. Open the picker configuration bottom sheet and turn on the specific switch to enable a particular feature. Also, there is support for max pick count via slider and max size via input. All the selected images will be displayed at the bottom of the demo screen buttons.
    opened by priyankj-simform 0
  • :zap: Update build script and fix missing drawable file

    :zap: Update build script and fix missing drawable file

    Changes

    • Moved afterEvaluate block from android block to the root of the file.
    • Fixed an issue of drawable file not available in theme.xml of picker library.
    opened by priyankj-simform 0
  • :pencil: Update README.md - Part 5

    :pencil: Update README.md - Part 5

    Update the README.md with all documentation and guides related to the new image picker and also updated corresponding GIFs to represent the new picker demo.

    Part -5 contains the files related to readme changes with documentation and guides.

    Changes :

    • :zap: New picker documentation with config and styling guides.

    Major File Changes:

    :heavy_plus_sign: Added

    • New gifs to show picker demo.

    :heavy_minus_sign: Removed

    • Removed old gifs.
    opened by priyankj-simform 0
  • :zap: Update feature - Picker library Part 4

    :zap: Update feature - Picker library Part 4

    Update image picker library with configuration changes, picker config changes, and bucket name changes.

    Part -4 contains the files related to the new image picker library's modification and changes.

    Changes :

    • :zap: Support for the device rotation configuration change.
    • :zap: Picker config changes to limit max pick count, max size is in now float and a new way to register image picker.
    • :sparkles: Support for new photo picker up to Android 11. More details

    Major File Changes:

    :heavy_plus_sign: Added

    • PickerConfigManager.kt - This class is the manager for the picker config. It extends SavedStateProvider to persist the picker config during activity configuration changes and process death.

    :construction: Modified

    • ImagePicker.kt - Added a new way to register for the ImagePicker and it's listener. Now the user needs to create the library before on create.
    • ImagePickerViewModel.kt - Changed the MutableState flow to MutableSharedFlow. The state flow was causing issues in no data found as the same values cannot be emitted by state flow.
    • BaseFragment.kt - Modified base fragment to handle the configuration change. Rotation change will now display different grid span counts for recycler view.
    • DataModels.kt - Included support for floating max size. Also, limits the max pick count to 15.
    • attr.xml - Added an attribute ssPickerGridCountLandscape to represent grid count in landscape mode.
    • Extension.kt - Added some important extensions to easily check, get and register tasks.

    :books: 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:configChanges="orientation|screenSize"
        android:theme="@style/SSImagePicker" />
    
    1. 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 registering the image picker. It will give the object of ImagePicker class.
        private val imagePicker: ImagePicker = registerImagePicker(callback = this)
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            ...
        }
        
        //To Open the picker call the open method passing the picker type.
        imagePicker.open(PickerType.GALLERY)
    
    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)
    
    1. 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
        }
    
    1. Multiple Selection uris will be received in onMultiImagePick(uris: List?) callback.
        override fun onMultiImagePick(uris: List<Uri>?) {
            //Do something with uris
        }
    
    opened by priyankj-simform 0
  • :bug: Fix: File name must not null

    :bug: Fix: File name must not null

    Closes #53 - GetImagesList "name must not be null"

    Update Features :

    • :bug: Fixes #53

    Major File Changes:

    :construction: Modified

    • Extensions.kt - Checked if a file name is null. Added null check for all columns.
    opened by priyankj-simform 0
  • GetImagesList

    GetImagesList "name must not be null"

    Describe the bug Hello, thanks again for the library, work really well ;)

    I have a couple of crash on production linked to Extension.getImageList() when name == null

    I couldn't reproduce it, just a couple of stacktrace from crqashlytics

    Fatal Exception: java.lang.NullPointerException: name must not be null at com.app.imagepickerlibrary.ExtensionsKt$getImagesList$2.invokeSuspend(Extensions.kt:253) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

    I didn't really dig into it, and I don't know how important the name is for a picture, but I was wondering if just avoiding picture if any params of the cursor is null could fix it without creating too many unwanted behavior

    Regards

    bug 
    opened by amensia 1
  • :bug: Fix: SavedStateProvider already registered in fragment

    :bug: Fix: SavedStateProvider already registered in fragment

    Closes #51 - SavedStateProvider with the given key is already registered I also added a fragment demo for compatibility.

    Update Features :

    • :bug: Fixes #51
    • :sparkles: New fragment demo to show how to use SSImagePicker in the fragment.

    Major File Changes:

    :construction: Modified

    • PickerConfigManager.kt - Checked if a SavedStateProvider is already registered.

    :books: Usage:

    • You can run the app module. Choose the preferred demo of either activity and fragment and open the image picker.
    opened by priyankj-simform 0
  • Getting error while open fragment second time : SavedStateProvider with the given key is already registered

    Getting error while open fragment second time : SavedStateProvider with the given key is already registered

    Describe the bug I have implemented this library inside fragment. After exiting the fragment with back button and open the same fragment and try to open image picker error occur you can find the stacktrace below.

    Additional context FATAL EXCEPTION: main Process: com.example.evetanhr.debug, PID: 15333 java.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered at androidx.savedstate.SavedStateRegistry.registerSavedStateProvider(SavedStateRegistry.kt:110) at com.app.imagepickerlibrary.util.PickerConfigManager.init$lambda-0(PickerConfigManager.kt:25) at com.app.imagepickerlibrary.util.PickerConfigManager.$r8$lambda$yxq-75EwC_9xo5MojhV7-4heekM(Unknown Source:0) at com.app.imagepickerlibrary.util.PickerConfigManager$$ExternalSyntheticLambda0.onStateChanged(Unknown Source:4) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360) at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:202) at com.app.imagepickerlibrary.util.PickerConfigManager.(PickerConfigManager.kt:22) at com.app.imagepickerlibrary.ImagePicker.(ImagePicker.kt:27) at com.app.imagepickerlibrary.ImagePicker.(Unknown Source:0) at com.app.imagepickerlibrary.ImagePicker$Companion.registerImagePicker(ImagePicker.kt:232) at com.example.evetanhr.view.add.AddEmployeePersonalDetailsFragment.onCreate(AddEmployeePersonalDetailsFragment.kt:66) at androidx.fragment.app.Fragment.performCreate(Fragment.java:3090) at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:257) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7697) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

    bug 
    opened by nitspatel12 1
Releases(2.0)
Owner
Simform Solutions
Simform Solutions
AndroidFilePicker - android library which will help you to pick any type of media file in your application

AndroidFilePicker is android library which will help you to pick any type of media file in your application. No need to manage any kind of extra permission or result method override. Just create library class instance and use it or also modify ui as your requirement.

null 4 Sep 12, 2022
Built the ccp code on compose. Country Code Picker is an android library which provides an easy way to search and select country or international phone code.

Built the ccp code on compose. Country Code Picker is an android library which provides an easy way to search and select country or international phone code.

utku glsvn 7 Oct 23, 2022
Simple, Powerful and Beautiful Android Image/Video/Audio Picker 😎

Simple, Powerful and Beautiful Android Image/Video/Audio Picker ?? Features ?? No need check storage permission ?? Single and multiple selection Suppo

Majid Arabi 34 Jan 2, 2023
Image Picker for Android 🤖

Android Image Picker No config yet highly configurable image picker for Android Screenshot Click to see how image picker looks… Download Add this to y

Esa Firman 1k Jan 7, 2023
FilePicker - Android library to facilitate files picking up process and ability to convert them to request bodies

FilePicker - Android library to facilitate files picking up process and ability to convert them to request bodies

Ahmed Atwa 26 Dec 14, 2022
Unicorn File Picker is a library designed to package a powerful file selector for android.

A simple, documented, and contribution-friendly File Picker for Android.

Abhishek Tiwari 62 Dec 5, 2022
An Android library for picking location in Bangladesh

BDLocationChooser An Android library for picking location in Bangladesh Example Screenshot : Implement Library The library is available on JitPack, fo

Sharif Rafid Ur Rahman 9 Jun 26, 2022
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Jan 2, 2023
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Nov 29, 2022
Image Picker with Customizable UI for Android, Pick an image from Gallery

Image Picker A Image Picker Library for Android (Supports Android 12) with fully

null 2 May 29, 2022
Pluck - Pluck, a library helps you to pick image via Galley/Camera built using Compose

Pluck - The image-picker library for Compose This is an image-picker for your je

Himanshu Singh 255 Jan 3, 2023
A small customizable library useful to handle an gallery image pick action built-in your app. :sunrise_over_mountains::stars:

Louvre A small customizable image picker. Useful to handle an gallery image pick action built-in your app. *Images from Google Image Search Installati

André Mion 640 Nov 19, 2022
Screen Capture Utils - A plugin to handle screen capture events on android and ios

Screen Capture Utils A plugin to handle screen capture events on android and ios ?? Initialize SDK late ScreenCaptureUtils screenCaptureUtils;

Chiziaruhoma Ogbonda 41 Apr 12, 2022
Android library to choose image from gallery or camera with option to compress result image

ImagePicker Android library to choose image from gallery or camera with option to compress result image. Download Add this to your project's build.gra

Mayank Nagwanshi 73 May 20, 2022
With the Help of this libray you can pic image from camera, gallery, it's support image cropping as well and you can pic PDF

FilePicker This project aims to provide an ultimate and flexible image picking from Gallery, Camera and cropping experience as well as PDF picking fro

Raj Pratap Singh Jadon 3 Nov 24, 2022
Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Prabhakar Thota 162 Sep 13, 2022
Image Cropping Library for Android, optimised for Camera / Gallery.

Image Cropping Library for Android, optimised for Camera / Gallery.

CanHub 812 Dec 30, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
Slider-Gallery-Zoom: image slider for android supporting indicator and auto scroll with clicking on image

image slider supporting indicator and auto scroll with clicking on image to open full screen image slider swipe and pinch zoom gestures like gallery,just pass your images and the position of the current image.

Mahmoud Elian 3 May 28, 2022