Picker-kt - Media picker library powered by Jetpack Compose

Overview
logo

ANDROID LIBRARY

PickerKT

A media picker library for Android apps powered by Jetpack Compose.

Project Hero Image

🚩 Motivations

The app I worked on in my full-time job used Matisse, and it was okay until a new version of Android (11 ~ 12) came along. The app faced instability issues and, to be honest, the UI of Matisse is not consistent with the rest of the app that uses Jetpack Compose by that time. Therefore, I spent my free time building this library to (hopefully) replace Matisse.

πŸŽ€ Project Structure

PickerKT has 3 sub-modules as follows:

pickerkt-base

The Base module contains core data classes specified by the library and data loaders (ContentResolver + Paging stuffs). It includes the building blocks that you need to build your own Picker UI (Jetpack Compose or not). Even the Query Builder is in here.

Features

  1. Reactive Collection listing via CollectionListingSource.
  2. Reactive Content listing via ContentPagingSource.
  3. Comes with a DSL to config the Picker-related classes.

Caveats

  1. Non-media file MIME Type won't work with ContentResolver even if we have them defined in the code (PDF, MS Word, etc. are not visible πŸ₯² ).
  2. I decided to use threetenabp and not quite sure if I got it right (in terms of setup and appropiateness).

pickerkt-ui

The Ui module is built upon the Base module. This modules come with a ready-to-use Media Picker UI implemented using Jetpack Compose with Material 3. The screenshots in the top banner comes from this module. This is where most of efforts went into.

Features

  1. Material Design 3 based Media Picker
  2. Comes with Media Viewer (limited to images for now)
  3. Customizable via Picker Config DSL.
  4. Responsive UI (designed for both tablet and phone)

Caveats

  1. ⚠️ Low performance when scrolling (Needs hands to investigate this)
  2. No drag-to-select items
  3. Multi-language translation needs a lot of work.
  4. Some Configurable Arguments (using DSL) are not wired up properly.

sample

The sample is basically a demo of the library. You can build and install to test it on your phone.

πŸ” Required Runtime Permissions

The library requires android.Manifest.permission.READ_EXTERNAL_STORAGE permission to operate. pickerkt-ui will not perform any permission request for you, so you have to do it yourself.

⭐ Quick Start with PickerKT UI

Download

repositories {
   maven { url 'https://jitpack.io' }
}

dependencies {
   implementation 'com.github.rektplorer64:picker-kt:<VERSION>'
}

With Jetpack Compose

  1. Request android.Manifest.permission.READ_EXTERNAL_STORAGE permission from the user. If you got no idea, see the sample source code or Google it.

  2. In one of your Compose UI, declare a MutableStateList of any other State holder that can hold a List<Uri>

    val myPickerResultList = remember { mutableStateListOf<Uri>() }
  3. Declare an Activity Launcher and a trailing lambda to specify what to do with the result (In this case, we are storing the result in myPickerResultList).

    val pickerLauncher = rememberLauncherForActivityResult(contract = PickerKtActivityResult()) { resultUriList ->
        myPickerResultList.addAll(resultUriList)
    }
  4. On one of your Button, add a code to LAUNCH the Picker.

        Button(
            onClick = {
                pickerLauncher.launch(
                    PickerKt.picker {
                        allowMimes {
                            add { MimeType.Jpeg }
                            add { MimeType.Png }
                            add { MimeType.Gif }
                            add { MimeType.Svg }
                            add { MimeType.Mpeg4 }
                            add { MimeType.Mp3 }
                        }
    
                        selection {
                            maxSelection(25)
                        }
                    }
                )
            }
        ) {
            Text(text = "Open Picker")
        }

    In this code, we set the Picker to show only files with MIME equals to JPEG, PNG, GIF, SVG, MPEG4, and MP3. We allow up to 25 files to be picked.

That's all you have to do for Jetpack Compose. To use the result list, use myPickerResultList as declared in step 1.

βœ… Requirements

  • AndroidX
  • Min SDK: 24

πŸ“ƒ License

Copyright 2022 PickerKT Contributors.

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.
You might also like...
A fully functional social media app built with Kotlin (Android Studio) with multiple features
A fully functional social media app built with Kotlin (Android Studio) with multiple features

A social media app built with Kotlin (Android Studio) with multiple features πŸ‘‰ If you like this repo, give it a star ✨ and share πŸ‘¨πŸ»β€πŸ’» it to your f

Social media app but with new features like translate messages and posts , support video & images as posts  , chat and  notifications , etc...
Social media app but with new features like translate messages and posts , support video & images as posts , chat and notifications , etc...

social-media-app Social media app but with new features like translate messages and posts , support video & images as posts , chat and notifications ,

Is a new version of code for my (Social media app) with Clean Architecture

Is a new version of code for my Social media app with Clean Architecture. I used most of Clean code tips with android, SOLID principles and design-patterns..

An Android app to stream and download your media stored in Google Drive in an Awesome way !!
An Android app to stream and download your media stored in Google Drive in an Awesome way !!

⚑ Thunder : An Android app to stream and download your media stored in Google Drive in an Awesome way !! (Just Movies for now) πŸ”˜ Getting Started : Le

 A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK
MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK

MvvmKotlinJetpackCompose Why do we need an architecture even when you can make an app without it? let's say you created a project without any architec

E- commerce appπŸ‘•  built with Jetpack Compose and Compose Destinations. The design was inspired by Sajjad Mohammadi Nia
E- commerce appπŸ‘• built with Jetpack Compose and Compose Destinations. The design was inspired by Sajjad Mohammadi Nia

E-Commerce Clothing App πŸ‘• This a Jetpack Compose app that replicates of an E-commerce app design I was inspired by on Dribble. It's an E-Commerce app

Productivity Note App utilizing Jetpack Compose
Productivity Note App utilizing Jetpack Compose

DailyDoc Productivity Note App utilizing Jetpack Compose Currently working on improving UI features and will be applying these directly to the main br

A feed for GitHub, written in Kotlin using Jetpack Compose.

Gimmick A while back, I noticed that the official GitHub app doesn't have a feed similar to the one can find on the GitHub homepage. Naturally I had t

Comments
  • The scroll position of a collection screen is not retained after previewing a media file.

    The scroll position of a collection screen is not retained after previewing a media file.

    Version

    0.1.0

    Reproduction Steps

    1. Enter a collection screen with enough files for it to be scrollable.
    2. Scroll down a bit
    3. Tap on an image to open the preview on another screen.
    4. Press the back button.

    Expected Result

    The scroll position should be retained not resetting to the top.

    Actual Result

    The scroll position is not retained. The user has to manually scroll down again in order to continue.

    bug β­ pickerkt-ui 
    opened by rektplorer64 0
Releases(0.1.0)
Owner
Tanawin Wichit
πŸ‘‹ Hello There!! I am an ICT student from Mahidol University who is currently working at LINE as an Android Dev. I ❀️ Android App and Backend Dev.
Tanawin Wichit
HyperUPnP is Android Application that lets you to Stream Media from PC, NAS or any other device running UPnP/DLNA compliant media server to your Android Device.

Hyper UPnP Android UPnP/DLNA client Stream Media from PC, NAS or any other device running UPnP/DLNA compliant media server to your Android Device. Int

Var Bhat 8 Jul 17, 2022
An app to detect color palettes in the real world - powered by VisionCamera

Colorwaver An app to detect colorwaves (swatches/palettes) in the real world - powered by VisionCamera and Reanimated. I wrote this app in less than a

Marc Rousavy 476 Dec 25, 2022
Event Bus powered by Kotlin Coroutines Flow

FlowBus FlowBus is a kotlin event bus implementation. Powered by Kotlin Coroutines and Flows Android MainThread-aware Fully operable from Java code Ex

Robert Kosakowski 26 Dec 27, 2022
LedBuzz is a NodeMCU-powered see-through propeller display

LedBuzz What it does LedBuzz is a NodeMCU-powered see-through propeller display. By simply staring at your ceiling fan, you receive notification alert

Jatin 2 Jan 9, 2022
Get a libGDX-powered Android live wallpaper up and running quickly with this project template

This project is a libGDX Android live wallpaper template. It's the demo application created by the libGDX code generator, remade as a live wallpaper.

Kurtis LoVerde 1 Jun 30, 2022
🐦 Loritta's Social media relayer via Discord Webhooks micro-service

?? SocialRelayer ?? SocialRelayer is a social media relayer to Discord via webhooks, pulling Loritta's guild configurations to automatically register

Loritta 6 Jun 2, 2022
Simple app to Transfer Media and Text from computer to mobile.

TransferByte Simple app to Transfer Media and Text from computer to mobile.Written in kotlin. Recycler view used for listing the media posted and down

AFIL K UMMER 3 Jun 15, 2021
A minimalist clone of the popular Social Media Platform "Instagram"

InstaLocal A minimalist clone of the popular Social Media Platform "Instagram" powered by Firebase and written in Kotlin. The app allows users to sign

Raktim Bhuyan 1 Nov 7, 2021
H4SGTAG MANAGER - CRUD that saves hashtags for social media

H4SGTAG_MANAGER CRUD that saves hashtags for social media made using android stu

Aldo Malacara 0 Jan 13, 2022
Simple media hosting system written in kotlin.

media-server This project is a simple media server implementation that allows you to upload and share files. This project was made in Kotlin and HTML,

null 4 May 15, 2022