Matisse README

The project's README from github.com/zhihu/Matisse. As one markdown file: README.md.

Image

Matisse

Build Status Download

Matisse is a well-designed local image and video selector for Android. You can

Zhihu Style Dracula Style Preview

Download

Gradle:

repositories {
    jcenter()
}

dependencies {
    implementation 'com.zhihu.android:matisse:$latest_version'
}

Check out Matisse releases to see more unstable versions.

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.

How do I use Matisse?

Permission

The library requires two permissions:

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

Simple usage snippet


Start MatisseActivity from current Activity or Fragment:

Matisse.from(MainActivity.this)
        .choose(MimeType.allOf())
        .countable(true)
        .maxSelectable(9)
        .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
        .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
        .thumbnailScale(0.85f)
        .imageEngine(new GlideEngine())
        .showPreview(false) // Default is `true`
        .forResult(REQUEST_CODE_CHOOSE);

Themes

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

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

Receive Result

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

List<Uri> mSelected;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
        mSelected = Matisse.obtainResult(data);
        Log.d("Matisse", "mSelected: " + mSelected);
    }
}

More

Find more details about Matisse in wiki.

Contributing

Matisse is an Open Source Project

Thanks

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

License

Copyright 2017 Zhihu Inc.

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.

Matisse (zhihu/Matisse)

Searching Database…

12.5K ·GitHub
What is this?Matisse is an Android library that gives your app a well-designed local image and video picker, so you do not need to build your own gallery selection screen.
Is it a standalone app or a library I add to my project?It is an Android library you embed in your own app; it is launched as an Activity from your Activity or Fragment, not a separate app.
How do I add it to my Android project?Add it via Gradle as a dependency, check the releases page for versions, then start MatisseActivity from your Activity or Fragment and handle the result in onActivityResult().
Do I need to set up anything else before using it, like permissions or ProGuard rules?Yes: the library needs READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions (handled at runtime on Android 6.0+), and if you use Glide or Picasso as the image loader you must add their specific ProGuard rules plus one extra rule.
What file types and customization does it actually support?It supports selecting JPEG, PNG, GIF images and MPEG, MP4 videos, with two built-in themes (Zhihu light, Dracula dark), custom theme support, swappable image loaders, and custom filter rules.
What are the two built-in themes called?R.style.MatisseZhihu for a light mode and R.style.MatisseDracula for a dark mode; you can also define your own custom theme.
Which image loading libraries does it work with?It supports pluggable image engines, with explicit ProGuard setup instructions given for both Glide and Picasso.
Why was Matisse built?It was created by Zhihu to give Android developers a polished, ready-made local media picker instead of everyone building their own from scratch.
Creator
zhihu
Size
1.9 MB
Stars
12.5K
Age
9y
Commits · 90 Days