GithubHelp home page GithubHelp logo

nbsp-team / materialfilepicker Goto Github PK

View Code? Open in Web Editor NEW
1.1K 40.0 229.0 788 KB

Picking files since 2015

License: Apache License 2.0

Java 80.32% Kotlin 19.68%
android file-picker material picker android-library

materialfilepicker's People

Contributors

arteaprogramar avatar artemnikitin avatar asad-khan-aasanjobs avatar ashqal avatar costular avatar dimorinny avatar frankyxcs avatar frogggias avatar grenderg avatar lukaville avatar owniz avatar prscx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialfilepicker's Issues

License question

I so that you use the GPL 2.0 licence. I want to use my app commercially. Can you use Apache?

How to filter multiple file extensions?

Great tool, but I would like to know if it is possible to filter 2 or more file types. For example in my app I want the user to be able to pick only mp3 files, so i used this line

.withFilter(Pattern.compile(".*\\.mp3$"))

But now what if i wanted the user to be able to choose also .ogg file? How could I achieve that?

Using the library changes the app name

Hey,
When i am compiling this library it changing my whole app name to 'MaterialFilePicker'.
Maybe this is because you have a @string/app_name resource that overrides mine.

Opening intended directory

Hi,
How can I put some extra in the intent that would open not the starting directory, but app's directory or any else directory that I wish?

Just something like this implemented would be very appreciated:
intent.putExtra(FilePickerActivity.ARG_PATH, /*My path*/);

Changing orientation changes directory too

Using version 1.6 on Google Pixel. If I change the orientation of the device from portrait to landscape while picking a file, the current directory moves up (ala cd ..).

Invoked as

     new MaterialFilePicker().withActivity(a).withRequestCode
            (1).withFilter(Pattern.compile(".*\\.mp3")).withHiddenFiles(false).withPath
                    (lastDirectory);

Is this expected behavior?

Crashes on initialization when Path sent

If the current path is sent, but not the root path.

The cause is here

This is due to my assumption that the current path would be the path where the picker starts. Now I'm using the root path and everything is ok. What is the purpose of the Current Path, then?

Reason to revert to 23.1.1 version of support libraries

Hello!
What was the reason to downgrade support libraries version from 23.2.0?
If there was some bugs, have you tested 23.2.1 version, which has a lot of bugfixes?
Support libraries 23.2 bring Vector Drawables, which can be used there.

Opening large files

Hello,
In my app I am opening large obj files, so when I click on such file, the phone is lagging on the FilePickerActivity, and returns to my activity when my file is already opened. I assume that's actually not your problem or fault. Although I would be very appreciate if you implemented some mechanism such as progressView while the clicked file is being loaded OR to return to my activity immediately after it's clicked, so the process of loading is going there visually...

Thanks in advance.

Multiple filter

How can set more than one filter ?
for example just show .txt files and .mp4 files !
how ?

What's the minimum requirement?

Is there any minimum requirement to use this lib?

I'm planning to use this in my project, but can't find any details about requirements needed. (My project min sdk API16 and targeting API25).

not able to add filter

if i use this MaterialFilePicker and set filter i dont get any results

new MaterialFilePicker()
.withActivity(QuickCvRegistration.this)
.withRequestCode(12346)
.withFilter(Pattern.compile(".*.txt$")) // Filtering files and directories by file name using regexp
.withFilterDirectories(true) // Set directories filterable (false by default)
.withHiddenFiles(true) // Show hidden files and folders
.start();

Crash

Fast open/close activity.

java.lang.IllegalStateException: Activity has been destroyed
at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1352)
at android.app.BackStackRecord.commitInternal(BackStackRecord.java:597)
at android.app.BackStackRecord.commit(BackStackRecord.java:575)
at com.nbsp.materialfilepicker.ui.FilePickerActivity.addFragmentToBackStack(FilePickerActivity.java:136)
at com.nbsp.materialfilepicker.ui.FilePickerActivity.handleFileClicked(FilePickerActivity.java:180)
at com.nbsp.materialfilepicker.ui.FilePickerActivity.access$000(FilePickerActivity.java:24)
at com.nbsp.materialfilepicker.ui.FilePickerActivity$1.run(FilePickerActivity.java:173)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
at dalvik.system.NativeStart.main(Native Method)

Library not working with newest Android versions

This library is not working with Android version >= 6.

No directories are shown probably because of permission-granting related issue mentioned here #13

I tested this libarry on device with Android 4.4 and it works and looks nice there. So would be great to have support for the newest Android versions too ;)

problem with swipe to refresh

I was updated your lib to 1.03 and SwipeRefreshLayout died. If I do a downgrade to 1.02 it works again but appears the bug with the language...

External storage: SD card

Is it possible to select a different directory for the filepicker? Im working with large files and these need to be selected from the SD card

Empty directories

Opening filePicker like this

new MaterialFilePicker()
.withActivity(this)
.withRequestCode(1)
.start();

I expect to see all files, but all directories on device are empty. What am I doing wrong ?

java.lang.NullPointerException: storage == null

java.lang.RuntimeException: Unable to start activity ComponentInfo{net.memozz.myapplication/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.NullPointerException: storage == null
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                          at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:134)
                                                                       Caused by: java.lang.NullPointerException: storage == null
                                                                          at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
                                                                          at java.util.Arrays.asList(Arrays.java:155)
                                                                          at com.nbsp.materialfilepicker.utils.FileUtils.getFileListByDirPath(FileUtils.java:16)
                                                                          at com.nbsp.materialfilepicker.ui.DirectoryFragment.initFilesList(DirectoryFragment.java:84)
                                                                          at com.nbsp.materialfilepicker.ui.DirectoryFragment.onViewCreated(DirectoryFragment.java:79)
                                                                          at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:988)
                                                                          at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
                                                                          at android.app.BackStackRecord.run(BackStackRecord.java:793)
                                                                          at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
                                                                          at android.app.FragmentController.execPendingActions(FragmentController.java:325)
                                                                          at android.app.Activity.performStart(Activity.java:6267)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:148) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                          at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:134) 

Documentation

Is there some kind of documentation? What means all the option?

  • withFilterDirectories(true) // Set directories filterable (false by default)
    What does that mean?

Difference between withRootPath and withPath?

Is it possible to set the path parent to data? (So the user could select SD card)

Thank you in advance,

How to use it from inside Fragment?

Thank you very much for this library.
I am having issue to get the selected file name from inside the Fragment, as

onActivityResult

is not working (called) in fragment.
How to make this work?
Thanks.

Theme support

Could you please provide support for Light/Dark themes, esp. the used icons. Thanks.

Empty directory

No matter what I put in filter I always getting empty directiry.

I tried like it explained in
pull 20
but still can't get any directory

Can't use ARG_FILE_FILTER as documented

The ARG_FILE_FILTER shown in the readme doesn't exist. Apparently it was replaced by ARG_FILTER. But it doesn't work.

intent.putExtra(FilePickerActivity.ARG_FILTER, Pattern.compile(".*\\.txt$"));

...results in this crash:

FATAL EXCEPTION: main
 Process: com.chalcodes.maps, PID: 5164
 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chalcodes.maps/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to com.nbsp.materialfilepicker.filter.CompositeFilter
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
     at android.app.ActivityThread.access$800(ActivityThread.java:155)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:135)
     at android.app.ActivityThread.main(ActivityThread.java:5343)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
  Caused by: java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to com.nbsp.materialfilepicker.filter.CompositeFilter
     at com.nbsp.materialfilepicker.ui.FilePickerActivity.initArguments(FilePickerActivity.java:62)
     at com.nbsp.materialfilepicker.ui.FilePickerActivity.onCreate(FilePickerActivity.java:47)
     at android.app.Activity.performCreate(Activity.java:6010)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) 
     at android.app.ActivityThread.access$800(ActivityThread.java:155) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5343) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 

Can't specify the start directory

Using the following code I am not able to get to the required directory when the file picker starts. I use the withPath(String path) method, because I want the user to go back and forth from that particular directory. It only changes the toolbar path text. But the file picker starts from the root directory instead of the specified directory. Can you please tell me what is wrong?

new MaterialFilePicker()
                .withActivity(MainActivity.this)
                .withRequestCode(500)
                .withPath(Environment.getExternalStorageDirectory().toString() + "/myFolder")
                .withFilter(Pattern.compile(".*\\.*$")) // Filtering files and directories by file name using regexp
                .withFilterDirectories(true) // Set directories filterable (false by default)
                .withHiddenFiles(true) // Show hidden files and folders
                .start();

The documentation states about withPath() method:

Specifies start directory for picker, which will be shown to user at the beginning

Show thumbnail of video or image

Hi
Is there any way to show thumbnail of video or image in the list instead of showing static icon? This will help user to choose his/her file more easily :)

withPath does not work

I want to set the default path using withPath and yet the explorer shows the root directory content.

new MaterialFilePicker()
     .withActivity((Activity) mContext)
     .withPath(Environment.getExternalStorageDirectory().getAbsolutePath() + Constants.DEFAULT_DIRECTORY)
     .withRequestCode(Constants.RESTORE_FILE_PICK_REQUEST)
     .withHiddenFiles(true)
     .start();

Whatever goes in that function is a valid directory.

Inconsistent module metadata

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not resolve com.nbsp:library:1.01.
inconsistent module metadata found. Descriptor: com.nbsp:material-file-picker:1.01 Errors: bad module name: expected='library' found='material-file-picker'

Choose language

How do i choose language? I some phones the language is set to Russian and in other it set to English. I want the language to be English all the time...

Will not work on Android M

Hi!

You should use this manual and add

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, SOME_REQUEST_CONSTANT);

to FilePickerActivity.onCreate() to provide your library with access to external storage. Otherwise it will not work on Android M.

P.S. And please make minSdkVersion = 10 for your library to cover all active android versions on market. Thanks.

Filters don't work for hidden files and directories

In example project there is example filter for txt files:
.withFilter(Pattern.compile(".*.txt$"))

But if there is ".test" file in the directory, it wont be filtered.
Futhermore, if .withFilterDirectories is set to true, there will be directories in the list.

So, let's try next config:

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

Look at the next screenshot:
5 items except ".test.txt" should not be there.
screenshot

Couldn't get the library to load using maven dependencies.

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not resolve com.nbsp:library:1.01.
Required by:
chocoprint:app:unspecified
> Could not resolve com.nbsp:library:1.01.
> inconsistent module metadata found. Descriptor: com.nbsp:material-file-picker:1.01 Errors: bad module name: expected='library' found='material-file-picker'
> Could not resolve com.nbsp:library:1.01.
> Could not get resource 'http://dl.bintray.com/lukaville/maven/com/nbsp/library/1.01/library-1.01.pom'.
> Could not HEAD 'http://dl.bintray.com/lukaville/maven/com/nbsp/library/1.01/library-1.01.pom'.
> ukproxycam.paconsulting.com

Filter out multiple files types

I am trying to filter out multiple file types using the regex below:

^.*.(?!apk$|dmg$|exe$|ipa$|app$)[^.]+$

When I test it online everything works as expected, but when I use it in the following snippet apk files are still shown. I am not a regex expert. Apologies if this is a simple question and thank you for the help!

new MaterialFilePicker()
.withActivity(this)
.withFilter(Pattern.compile("^.*\.(?!apk$|dmg$|exe$|ipa$|app$)[^.]+$"))
.withRequestCode(REQUEST_CODE_DOCUMENT_PICKER)
.withHiddenFiles(true) // Show hidden files and folders
.start();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.