Skip to content

Repository files navigation

ImagePicker

A library that supports selecting images from the device library or directly from the camera.

Android Arsenal

Screenshots

Installation

Add the following maven repositories in root build.gradle

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

Add the following dependency in app build.gradle

dependencies {
implementation'com.github.nguyenhoanglam:ImagePicker:1.4.0'
}

You NEED to migrate your project to support AndroidX by add following lines on gradle.properties file:

android.useAndroidX=trueandroid.enableJetifier=true

Usage

Start ImagePicker

ImagePicker.with(this) .setFolderMode(true) .setFolderTitle("Album") .setDirectoryName("Image Picker") .setMultipleMode(true) .setShowNumberIndicator(true)
.setMaxSize(5)
.setLimitMessage("You can select up to 5 images")
.setSelectedImages(images)
.setRequestCode(100)
.start();

Handle selected images

@OverrideprotectedvoidonActivityResult(intrequestCode, intresultCode, Intentdata) {
if (requestCode == Config.RC_PICK_IMAGES && resultCode == RESULT_OK && data != null) {
ArrayList<Image> images = data.getParcelableArrayListExtra(Config.EXTRA_IMAGES);
// do your logic here...
}
super.onActivityResult(requestCode, resultCode, data); // You MUST have this line to be here// so ImagePicker can work with fragment mode
}

Methods's description

NameDescriptionDefault
withInitialize ImagePicker with activity or fragment context
setStatusBarColorStatus bar color, require API >= 21#000000
setToolbarColorToolbar color#212121
setToolbarTextColorToolbar text color#FFFFFF
setToolbarIconColorToolbar icon color#FFFFFF
setBackgroundColorBackground color#212121
setProgressBarColorProgressBar color#4CAF50
setIndicatorColorSelected image's indicator color#1976D2
setCameraOnlyStart camera and return captured imagefalse
setMultipleModeAllow to select multiple imagestrue
setFolderModeGroup images by foldersfalse
setFolderTitleFolder screen's title, require FolderMode = trueAlbums
setImageTitleImage screen's title, require FolderMode = falseGalleries
setDoneTitleDone button's titleDONE
setAlwaysShowDoneButtonShow done button even though no image selectedfalse
setShowCameraShow camera buttontrue
setDirectoryNameFolder name for captured images (located in DCIM folder)Camera
setShowNumberIndicatorShow selected image's indicator as numberfalse
setMaxSizeMax images can be selectedInt.MAX_VALUE
setLimitMessageFolder screen's title
setSelectedImagesList of images that will be shown as selected in ImagePickerempty list
setRequestCodeRequest code for starting ImagePicker100
startOpen ImagePicker

What's new

  • Fixed bugs.
  • Supported Android 10 (API 29)
  • Updated to new UI/UX (remove selection overlay, add number indicator)
  • Converted Java code to Kotlin code
  • Upgraded Glide to v4.11, AndroidX to v1.1.0
  • Replaced savePath option with directoryName option.
  • Removed keepScreenOn config option

License

Copyright (c) 2020 Nguyen Hoang Lam

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.

About

An extension of RelativeLayout that helps show loading, empty and error layout.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages