Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nbsp-team/MaterialFilePicker
Picking files since 2015
https://github.com/nbsp-team/MaterialFilePicker
android android-library file-picker material picker
Last synced: 3 months ago
JSON representation
Picking files since 2015
- Host: GitHub
- URL: https://github.com/nbsp-team/MaterialFilePicker
- Owner: nbsp-team
- License: apache-2.0
- Created: 2015-10-22T23:39:18.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-05T02:12:13.000Z (almost 2 years ago)
- Last Synced: 2024-06-16T06:34:10.812Z (5 months ago)
- Topics: android, android-library, file-picker, material, picker
- Language: Java
- Homepage:
- Size: 770 KB
- Stars: 1,139
- Watchers: 40
- Forks: 230
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-android-ui - MaterialFilePicker - MD风格文件选择器库 (文件操作)
README
# Material File Picker Unofficial
Material file picker library for Android by Arte al Programar![](ss/main.png)
## 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...
#fafafa
...styles.xml
...
@color/colorBackground
...```
- 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:
```java
@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.
```
?colorPrimary
?colorPrimaryDark
?colorAccent
?android:colorBackground
#212121
#4000695C
#8a000000```
Runtime permissions:
You should handle runtime permissions in activity, from what you called Material File Picker.
Look [here](https://github.com/nbsp-team/MaterialFilePicker/blob/master/app/src/main/java/com/dimorinny/sample/MainActivity.java#L38-L69) for example code.