Easy to use and configurable library to Pick an image from the Gallery or Capture an image using a Camera... 📸
Easy to use and configurable library to Pick multiple images from the Gallery or Capture an image using Camera with maximum size, extension, crop, rotate, zoom and compress features.
Camera Picker | Gallery Picker | Multi Selection Gallery Picker |
---|---|---|
Picker Option Bottom Sheet | Crop Options | Extension Options |
---|---|---|
System Photo Picker (Android 11+) |
---|
Add the JitPack repository to your project's build.gradle file
allprojects {
repositories {
...
maven { url = "https://jitpack.io" }
}
}
dependencyResolutionManagement
block dependencyResolutionManagement {
repositories {
...
maven { url = "https://jitpack.io" }
}
}
Enable data binding feature in your app's build.gradle file (More Details) .
android {
...
buildFeatures {
dataBinding=true
}
}
Add the dependency in your app's build.gradle file
dependencies {
implementation("com.github.SimformSolutionsPvtLtd:SSImagePicker:2.2")
}
SSImagePicker
is default theme for
image picker activity. If you want to set custom theme check
out customization guide. Make sure to add
the android:configChanges
to handle the rotation.
<activity android:name="com.app.imagepickerlibrary.ui.activity.ImagePickerActivity"
android:configChanges="orientation|screenSize" android:theme="@style/SSImagePicker" />
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 -> {}
}
}
ImagePicker
class. private val imagePicker: ImagePicker by lazy {
registerImagePicker(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
}
//To display the picker screen call open method on image picker object passing the picker type.
imagePicker.open(PickerType.GALLERY)
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)
ImagePickerResultListener
. class MainActivity : AppCompatActivity(), ImagePickerResultListener {
...
}
onImagePick(uri: Uri?)
callback. override fun onImagePick(uri: Uri?) {
//Do something with uri
}
onMultiImagePick(uris: List<Uri>?)
callback. override fun onMultiImagePick(uris: List<Uri>?) {
//Do something with uris
}
SSImagePicker Uses following permissions to display images. For system Photo Picker on Android 11+ no permission is required.
android.permission.READ_EXTERNAL_STORAGE
android.permission.READ_MEDIA_IMAGES
Support it by joining stargazers for this repository. :star:
Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! : muscle:
Check out our Contributing Guide for ideas on contributing.
For bugs, feature requests, and discussion please use GitHub Issues.
MIT License
Copyright (c) 2022 Simform Solutions
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.