GithubHelp home page GithubHelp logo

charles's Introduction

Charles

Build Status Download

Charles is a local file selector for Android. You can

  • Use it in Activity or Fragment
  • Select multi-media file including images, videos, audio and documents
  • Apply different themes, including two built-in themes and custom themes
  • Restrict different screen orientations
  • Find more by yourself
Charles Style Charles Dark Style Empty View
Charles Style Empty View Charles Empty Layout

Download

  • Add the JitPack repository to your build file:
allprojects {
    repositories {
        jcenter()
    }
}
  • Add the dependency:
dependencies {
    implementation 'io.github.tonnyl:charles:x.y.z'
}

ProGuard

If you use Glide as your image engine, add rules as Glide's README says. And add extra rule:

-dontwarn com.squareup.picasso.**

If you use Picasso as your image engine, add rules as Picasso's README says. And add extra rule:

-dontwarn com.bumptech.glide.**

Attention: The above progurad rules are correct.

Usage

Permission

The library requires two permissions:

  • android.permission.READ_EXTERNAL_STORAGE
  • android.permission.WRITE_EXTERNAL_STORAGE

So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.

Simple Usage Snippet

Start CharlesActivity from current Activity or Fragment:

Charles.from(this@MainActivity)
        .choose()
        .maxSelectable(9)
        .progressRate(true)
        .theme(R.style.Charles)
        .imageEngine(GlideEngine())
        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
        .forResult(REQUEST_CODE_CHOOSE)

Themes

There are two built-in themes you can use to start CharlesActivity:

  • R.style.Charles (light mode)
  • R.style.CharlesDark (dark mode)

And Also you can define your own theme as you wish.

Receive Result

In onActivityResult() callback of the starting Activity or Fragment:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == Activity.RESULT_OK) {
        val uris = Charles.obtainResult(data)
        val paths = Charles.obtainPathResult(data)

        Log.d("charles", "uris: $uris")
        Log.d("charles", "paths: $paths")
    }
}

More

Find more details about Charles in wiki.

Contribution

Discussions and pull requests are welcomed 💖.

Thanks

This library is inspired by Matisse and uses some of its source code.

License

Charles is under the MIT license. See the LICENSE for more information.

charles's People

Contributors

tonnyl avatar

Watchers

 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.