Coder Social home page Coder Social logo

imagepicker-new's Introduction

ImagePicker

An android library which help selecting images from the device with customizable UI.

Android Arsenal

Preview

Changelog

  • Fix permission error when running on Android 13.
  • Upgrade some dependency versions.

Installation

In settings.gradle file, add JitPack maven like below:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the following dependency in app build.gradle:

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

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

android.useAndroidX=true
android.enableJetifier=true

For any Java projects, please follow this guide to add Kotlin to existing app.

Usage

Define an ActivityResultLauncher class variable in Activity or Fragment.

private val launcher = registerImagePicker { images ->
        // Selected images are ready to use
        if(images.isNotEmpty()){
        val sampleImage = images[0]
        Glide.with(this@MainActivity)
        .load(sampleImage.uri)
        .into(imageView)
        }
        }

Then, launch image picker when needed.

  • With default configuration:
launcher.launch()
  • With customize configuration:
val config = ImagePickerConfig(
        statusBarColor = "#000000",
        isLightStatusBar = false,
        isFolderMode = true,
        isMultipleMode = true,
        maxSize = 10,
        rootDirectory = Config.ROOT_DIR_DOWNLOAD,
        subDirectory = "Photos",
        folderGridCount = GridCount(2, 4),
        imageGridCount = GridCount(3, 5),
        // See more at configuration attributes table below
        )

        launcher.launch(config)

Configuration attributes

Name Description Default
statusBarColor Status bar color (require API >= 21) #000000
isLightStatusBar Set status bar to light/dark mode to change it's content to dark/light (require API >= 21) false
toolbarColor Toolbar color #212121
toolbarTextColor Toolbar text color #FFFFFF
toolbarIconColor Toolbar icon color #FFFFFF
backgroundColor Background color #424242
progressIndicatorColor Loading indicator color #009688
selectedIndicatorColor Selected image's indicator color #1976D2
isCameraOnly Open camera, then capture and return an image false
isMultipleMode Allow to select multiple images true
isFolderMode Show images by folders false
folderGridCount Set folder colums for portrait and landscape orientation GridCount(2, 4)
imageGridCount Set image colums for portrait and landscape orientation GridCount(3, 5)
doneTitle Done button title DONE
folderTitle Toolbar title for folder mode (require FolderMode = true) Albums
imageTitle Toolbar title for image mode (require FolderMode = false) Photos
isShowCamera Show camera button true
isShowNumberIndicator Show selected image's indicator as number false
isAlwaysShowDoneButton Show done button even though no images've been selected yet false
rootDirectory Public root directory of captured image, should be one of: RootDirectory.DCIM, RootDirectory.PICTURES, RootDirectory.DOWNLOADS. RootDirectory.DCIM
subDirectory Root directory's sub folder of captured image Application name
maxSize Max images can be selected Int.MAX_VALUE
limitMessage Message to be displayed when total selected images exceeds max size ...
selectedImages List of images that will be shown as selected in ImagePicker Empty list

License

Copyright (c) 2022 Nguyen Hoang Lam

imagepicker-new's People

Contributors

nguyenhoanglam avatar andybdahl avatar beta avatar bkhezry avatar kishanviramgama avatar rainer-lang avatar boss1088 avatar dattran-pt19 avatar brainsucker avatar nubpro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.