$ show leavesCZY/Matisse
Matisse is an Android image and video selection library built entirely with Kotlin and Jetpack Compose. It provides two primary entry points: `MatisseContract` for a full-featured media picker (grid selection, bucket filtering, preview, multi-select with configurable constraints) and `MatisseCaptureContract` for a standalone camera capture flow. The library abstracts image loading via an `ImageEngine` interface with built-in Coil and Glide implementations, and handles MediaStore permissions across Android versions including granular media permissions and partial access on Android 14+. Capture strategies are modular (FileProvider, MediaStore, Smart), allowing hosts to control storage location and permission needs. The sample app demonstrates configuration options (grid columns, max selectable, fast select, theme). The codebase is well-structured, uses clean architecture with ViewModels and Paging 3, and relies on AndroidX and Jetpack Compose. It is primarily a reusable library with high craftsmanship.
The LLM identified 3 files worth highlighting for reuse:
Provides a clean, extensible interface `CaptureStrategy` for handling the camera capture lifecycle (Uri creation, result loading, cancellation cleanup) with three built-in implementations: `FileProviderCaptureStrategy`, `MediaStoreCaptureStrategy`, and `SmartCaptureStrategy` that delegates by API level. The pattern is fully self-contained (all logic in one file), implements `Parcelable` for Intent serialization, and handles file-based vs. MediaStore storage with proper permission scoping. It can be extracted and reused in any Android app that needs a flexible camera capture system.
A comprehensive, isolated data access layer for querying Android MediaStore. It efficiently handles paginated media loading (with deduplication in `MediaPagingSource`), bucket aggregation via SQL GROUP BY (with fallback to full scan), MediaStore state filtering (IS_PENDING, IS_TRASHED), and MIME type selection. Uses modern `ContentResolver` query APIs (Bundle-based on R+) with manual LIMIT/OFFSET fallback. All methods are suspend functions and thread-safe. This component encapsulates all MediaStore complexity and can be reused in any Android media-related project.
Defines a clean, minimal `ImageEngine` interface with two Composable functions (`Thumbnail` and `Preview`) for displaying media content. It is `Parcelable` to enable serialization through Intents. Two implementations are provided (`CoilImageEngine`, `GlideImageEngine`) both of which handle video frames and large image downscaling. The interface is fully decoupled from any specific image loading library, allowing hosts to provide custom implementations with minimal effort. This pattern is highly reusable for any app that needs a swappable image loading strategy.