ChiliLabs / ChiliPhotoPicker

Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.
Apache License 2.0
405 stars 45 forks source link
android image-picker library

ChiliPhotoPicker

Made with ❤️ by Chili Labs.

Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it without additional dependencies.

No permission Single choice Multiple choice

Setup

Gradle:

Add Jitpack to your root build.gradle file:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

Add dependency to application build.gradle file, where x.y.z is the latest release version:

implementation "com.github.ChiliLabs:ChiliPhotoPicker:x.y.z"

Usage

Initialize ChiliPhotoPicker in your Application's class onCreate

ChiliPhotoPicker.init(
        loader = GlideImageLoader(),
        authority = "lv.chi.sample.fileprovider"
    )

Create new instance of PhotoPickerFragment

PhotoPickerFragment.newInstance(
        multiple = true, 
        allowCamera = true,
        maxSelection = 5,
        theme = R.style.ChiliPhotoPicker_Dark
).show(supportFragmentManager, YOUR_TAG)

Notes: Picker will throw exception if:

ImageLoader

We don't want to depend on many image loading libraries, so we have simple ImageLoader interface, which you can implement using your preferred library (Glide, Picasso, Coil, etc.) We have two working examples of ImageLoader implementations - using Glide and Picasso. You can just copy one of them or write your own implementation

Callback

Picked photos URIs are returned via callbacks onImagesPicked function, so you just need to implement PhotoPickerFragment.Callback interface in your activity or fragment

Themes

To customize picker you can use one of built-in themes or inherit it rewriting attributes you want (see example)

Attributes:

Localization

It's difficult to translate library to each language, so default strings are on English, but you can easily override them. Example for common strings and plurals are here. All strings used in library can be found here

License

Copyright 2019 Chili Labs

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.