Convert Figma logo to code with AI

nbsp-team logoMaterialFilePicker

Picking files since 2015

1,139
229
1,139
33

Top Related Projects

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Android view for displaying PDFs rendered with PdfiumAndroid

Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress notification. Support for persistent upload requests, customizations and custom plugins.

Image Cropping Library for Android, optimized for Camera / Gallery.

11,868

Image Cropping Library for Android

12,516

:fireworks: A well-designed local image and video selector for Android

Quick Overview

MaterialFilePicker is an Android library that provides a file picker implemented in Material Design. It allows users to select files from their device storage with a clean and modern interface, following Google's Material Design guidelines.

Pros

  • Implements Material Design for a consistent and attractive user interface
  • Customizable appearance and behavior to fit various app requirements
  • Supports both file and directory selection
  • Integrates easily with existing Android projects

Cons

  • Limited to Android platform only
  • May require additional setup for newer Android versions due to storage permission changes
  • Not actively maintained (last update was in 2018)
  • Lacks some advanced features like cloud storage integration

Code Examples

  1. Basic usage to start the file picker:
val intent = Intent(this, FilePickerActivity::class.java)
val fileFilter = arrayOf("jpg", "jpeg", "png")
intent.putExtra(FilePickerActivity.ARG_FILTER, fileFilter)
startActivityForResult(intent, FILE_PICKER_REQUEST_CODE)
  1. Customizing the file picker appearance:
val intent = Intent(this, FilePickerActivity::class.java)
intent.putExtra(FilePickerActivity.ARG_THEME, R.style.FilePickerTheme)
intent.putExtra(FilePickerActivity.ARG_TITLE, "Select a file")
intent.putExtra(FilePickerActivity.ARG_DIRECTORY, Environment.getExternalStorageDirectory().path)
startActivityForResult(intent, FILE_PICKER_REQUEST_CODE)
  1. Handling the result in onActivityResult:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == FILE_PICKER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        val filePath = data?.getStringExtra(FilePickerActivity.RESULT_FILE_PATH)
        // Do something with the selected file path
    }
}

Getting Started

  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.nbsp-team:MaterialFilePicker:1.9'
}
  1. Add the FilePickerActivity to your AndroidManifest.xml:
<activity
    android:name="com.nbsp.materialfilepicker.ui.FilePickerActivity"
    android:theme="@style/FilePickerTheme" />
  1. Request storage permissions in your app before using the file picker.

Competitor Comparisons

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Pros of material-dialogs

  • More comprehensive library with a wider range of dialog types and customization options
  • Actively maintained with frequent updates and bug fixes
  • Extensive documentation and community support

Cons of material-dialogs

  • Larger library size, which may impact app size and performance
  • Steeper learning curve due to more complex API and features
  • May include unnecessary components for projects only needing file picking functionality

Code Comparison

MaterialFilePicker:

MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start()

material-dialogs:

MaterialDialog(this).show {
    fileChooser(
        initialDirectory = File(Environment.getExternalStorageDirectory().path),
        filter = { it.isDirectory || it.extension == "txt" },
        allowFolderCreation = true
    ) { _, file ->
        // Handle selected file
    }
}

Both libraries offer file picking functionality, but material-dialogs provides a more integrated approach within its dialog system. MaterialFilePicker is more focused on file selection, while material-dialogs offers a broader range of dialog options beyond just file picking.

Android view for displaying PDFs rendered with PdfiumAndroid

Pros of AndroidPdfViewer

  • Specialized for PDF viewing, offering more advanced PDF-specific features
  • Supports zooming, page navigation, and rendering of PDF documents
  • Actively maintained with regular updates and bug fixes

Cons of AndroidPdfViewer

  • Limited to PDF files, not a general-purpose file picker
  • May have a steeper learning curve for integration due to its specialized nature
  • Potentially larger library size due to PDF rendering capabilities

Code Comparison

MaterialFilePicker:

MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start()

AndroidPdfViewer:

pdfView.fromAsset("sample.pdf")
    .pages(0, 2, 1, 3, 3, 3)
    .defaultPage(1)
    .showMinimap(false)
    .enableSwipe(true)
    .load()

MaterialFilePicker is designed for general file selection with customizable filters, while AndroidPdfViewer focuses on rendering and interacting with PDF documents. The code snippets demonstrate the different use cases and initialization processes for each library.

Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress notification. Support for persistent upload requests, customizations and custom plugins.

Pros of android-upload-service

  • Specialized for file uploads, offering more advanced upload features
  • Supports background uploads and multi-part uploads
  • Provides detailed upload progress and status notifications

Cons of android-upload-service

  • More complex to set up and use compared to MaterialFilePicker
  • Focused solely on uploads, lacking file browsing functionality
  • May be overkill for simple file selection tasks

Code Comparison

MaterialFilePicker (file selection):

MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start()

android-upload-service (file upload):

val uploadRequest = MultipartUploadRequest(context, serverUrl)
    .setMethod("POST")
    .addFileToUpload(filePath, "file")
    .setMaxRetries(2)
uploadRequest.startUpload()

MaterialFilePicker is designed for simple file selection within an app, while android-upload-service focuses on handling file uploads to a server. MaterialFilePicker provides an easy-to-use interface for browsing and selecting files, whereas android-upload-service offers more advanced features for managing and monitoring file uploads, including background processing and detailed progress tracking.

Image Cropping Library for Android, optimized for Camera / Gallery.

Pros of Android-Image-Cropper

  • Specialized for image cropping with advanced features like rotation and aspect ratio control
  • Provides a customizable UI for image cropping
  • Supports both gallery and camera image selection

Cons of Android-Image-Cropper

  • Limited to image files only, not suitable for other file types
  • May have a steeper learning curve due to its specialized nature
  • Larger library size compared to a more general file picker

Code Comparison

Android-Image-Cropper:

CropImage.activity(imageUri)
    .setGuidelines(CropImageView.Guidelines.ON)
    .setAspectRatio(1, 1)
    .start(this)

MaterialFilePicker:

MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start()

Android-Image-Cropper focuses on image manipulation, offering specific methods for cropping and adjusting images. MaterialFilePicker, on the other hand, provides a more general file selection interface with options for filtering file types and handling hidden files. The choice between these libraries depends on whether the application requires specialized image cropping functionality or a more versatile file selection tool.

11,868

Image Cropping Library for Android

Pros of uCrop

  • Advanced image cropping functionality with gesture support
  • Customizable UI with various styling options
  • Supports both bitmap and Uri input for image processing

Cons of uCrop

  • Limited to image cropping, not a general file picker
  • May have a steeper learning curve due to more complex features
  • Larger library size due to additional image processing capabilities

Code Comparison

MaterialFilePicker:

new MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start();

uCrop:

UCrop.of(sourceUri, destinationUri)
    .withAspectRatio(16, 9)
    .withMaxResultSize(maxWidth, maxHeight)
    .start(this);

Key Differences

  • MaterialFilePicker is a general-purpose file picker, while uCrop focuses on image cropping
  • uCrop offers more advanced image manipulation features
  • MaterialFilePicker provides a simpler API for file selection
  • uCrop has a more customizable UI for image editing
  • MaterialFilePicker supports various file types, whereas uCrop is specific to images

Use Cases

MaterialFilePicker is ideal for applications requiring general file selection, while uCrop is better suited for apps needing precise image cropping and editing functionality.

12,516

:fireworks: A well-designed local image and video selector for Android

Pros of Matisse

  • More comprehensive image and video selection functionality
  • Supports custom themes and UI customization
  • Offers built-in image cropping and filtering options

Cons of Matisse

  • Larger library size and potentially higher resource usage
  • Steeper learning curve due to more complex API

Code Comparison

MaterialFilePicker:

new MaterialFilePicker()
    .withActivity(this)
    .withRequestCode(1)
    .withFilter(Pattern.compile(".*\\.txt$"))
    .withHiddenFiles(true)
    .start();

Matisse:

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
    .thumbnailScale(0.85f)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

MaterialFilePicker is more focused on file selection with a simpler API, while Matisse offers more advanced features for image and video selection with greater customization options. MaterialFilePicker may be easier to implement for basic file picking needs, whereas Matisse provides a more polished and feature-rich experience for media selection tasks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Material File Picker Unofficial

Material file picker library for Android by Arte al Programar

What's new

  • Require Android Jelly Bean 4.1.x (API 16+)
  • Android 10 Compatibility
  • Material Components for Android Support
  • Night Mode Support
  • New Icon Designs

Add your project

Download library and add it to your project

or use JitPack.io

build.gradle (Project)

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}


build.gradle (Module: app)

dependencies {
    ...
    implementation 'com.github.arteaprogramar:Android_MaterialFilePicker:version'
}


Using (IMPORTANT)

  • Add to Values
colors.xml
<resources>
    ...
    <color name="colorBackground">#fafafa</color>
    ...
</resources>

styles.xml

<resources>

    ...
    <item name="android:colorBackground">@color/colorBackground</item>
    ...
</resources>

  • Open your class and add the following code
...
public static final int FILE_PICKER_REQUEST_CODE = 989
...

MaterialFilePicker()
    // Pass a source of context. Can be:
    //    .withActivity(Activity activity)
    //    .withFragment(Fragment fragment)
    //    .withSupportFragment(androidx.fragment.app.Fragment fragment)
    .withActivity(this)
    // With cross icon on the right side of toolbar for closing picker straight away
    .withCloseMenu(true)
    // Entry point path (user will start from it)
    .withPath(alarmsFolder.absolutePath)
    // Root path (user won't be able to come higher than it)
    .withRootPath(externalStorage.absolutePath)
    // Showing hidden files
    .withHiddenFiles(true)
    // Want to choose only jpg images
    .withFilter(Pattern.compile(".*\\.(jpg|jpeg)$"))
    // Don't apply filter to directories names
    .withFilterDirectories(false)
    .withTitle("Sample title")
    .withRequestCode(FILE_PICKER_REQUEST_CODE)
    .start()
...

Override on activity result:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == FILE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
        // Do anything with file
    }
}

Themes

To create a compatible (Light/Dark) theme, you can change the following colors to suit your theme.

    <!-- App Colors -->
    <color name="colorPrimary">?colorPrimary</color>
    <color name="colorPrimaryDark">?colorPrimaryDark</color>
    <color name="colorAccent">?colorAccent</color>
    <color name="colorBackground">?android:colorBackground</color>

    <!-- Default Colors -->
    <color name="textColorPrimary">#212121</color>
    <color name="colorControlHighlight">#4000695C</color>

    <!-- (API 21 Status Bar Color) (API 23 Navigation Bar Color)-->
    <color name="colorPrimaryDarkVariant">#8a000000</color>

Runtime permissions:

You should handle runtime permissions in activity, from what you called Material File Picker. Look here for example code.