singhangadin / android-filepicker Goto Github PK
View Code? Open in Web Editor NEWSelecting directories/files made a lot easier.
License: Apache License 2.0
Selecting directories/files made a lot easier.
License: Apache License 2.0
Hi!
I found out a little bug in the file picker. If you will select file and then reopen file picker it lets you to click Select button even if no file or directory has been selected.
How can i restrict user to limit the number of files to be selected?
I have a requirement where user can select/deselect dirs paths. So after using dialog.markFiles(filePaths), and when the user is deselecting the path, still the onSelectedFilePaths() method returns deselected file paths along with selected paths.
Please remove
android:allowBackup="true"
android:supportsRtl="true"
from AndroidManifest.xml file. Every app has their own policy regarding using backup or RTL. No reason for such params in 3d party library.
Also remove
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
This parameter also should be controllable by the app itself. Not by 3d party library.
How to go back after selecting a directory?
Hi
I really like your filepicker. It's simple to integrate and works without issues.
However there is one thing that's bothering me - the right-to-left animation of icons and file names while scrolling up or down. It does look nice and smooth, but it kind of doesn't fit in my app. My app is quite static and to suddenly have everything moving is a bit annoying.
Is there a simple way of switching these animations off?
Thanks.
At the moment the library does not use colors for current app theme.
If I have the following theme assigned to the app
<resources>
<style name="AppTheme.Dark.Cyan" parent="AppTheme.Dark">
<item name="colorAccent">@color/material_cyan_300</item>
</style>
</resources>
then filepicker still needs colorAccent in colors.xml to override button text.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorAccent">#ff9800</color>
<resources>
Check how this is done in android.support.v7.app.AlertDialog.
The latest version's font color does not have sufficient contrast to be seen easily.
Hello, when the first listview is loaded with directories and files of the specified path, and you press the first element to return (...), the application ends with errors. An uncontrolled nullPointerException is thrown.
I would message you if I knew how to :( I am not sure if this is the appropriate place to do this. I am new to github.
Is there a way to set a property to not show hidden files? My users are not so 'tech-savy' and when they see the dialog open with so many files starting with a period they have a hard time finding their files.
Is there already a way to adjust this?
It would be interesting to add personalization in the first and second line, showing the size or by a text pattern with variables:
%size% %size_b% %size_kb% %size_mb% %size_gb%...
%lastmod_24% %lastmod_12%
%path%
%name%
Sample:
app:patternFirstLine="%name%
app:patternSecondLine="%size_mb% - %lastmod_24h%
app:patternTime = "YYY/mm/dd"
BTW: Nice Work my Friend!! Love it!!
and here just an Idea for you i did it in my Fork:
in the File com.github.angads25.filepicker.view.FilePickerDialog:
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (internalList.size() > i) {
FileListItem fitem = internalList.get(i);
if (fitem.isDirectory()) {
....
}
else {
if (view != null) {
CheckBox checkBox = (CheckBox)view.findViewById(R.id.file_mark);
checkBox.performClick();
}
}
}
}
So you can also click on the FileName to select an Item... it's pretty handy .. for me :-)
FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
dialog.setTitle("Title");
dialog.setSelectText("Select");
dialog.setCancelText("Cancel");
dialog.setLastEditedFormat("Last edited: %s");
dialog.setParentDirText("Parent directory");
Will it be possible to show Directory only if pdf, txt, image file is present in that folder. I mean by default it is showing system Directories as well. I need to show only those directories which have at least one of the required files like pdf,txt, image.
I saw the Dialog properties where we can hide files other than specified in ext array passed as below.
String ext[] =new String[] {"jpg","jpeg","png","gif"};
properties.extensions=ext;
But here the problem I am facing is , it is still showing the folders which don't contain the above extns.
Hi,
In htc u11, if I try to click ".." in the root of internal storage. It will show "Directory cannot be accessed". I guess it is because the root ("/") can not be read. This will lead to fail to move to external storage through internal storage.
I have worked for it to add a dropdown in dir_picture to direct the current directory to external sdcard without entering "/", look picture.
Any other good ideas?
Thanks.
The following code is used to select a directory:
DialogProperties properties=new DialogProperties();
properties.selection_mode= DialogConfigs.SINGLE_MODE;
properties.selection_type=DialogConfigs.DIR_SELECT;
properties.root=new File(DialogConfigs.DEFAULT_DIR);
properties.extensions=null;
fd = new FilePickerDialog(SettingsActivity.this, properties);
fd.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
if(files == null){
utility.doNothihng();
}else if(files.length == 1){
String sPathFolder = files[0];
}
}
});
fd.show();
The result is that files.length = 0. The selected folder is Download.
BTW, thanks a lot for this great tool.
could you please help me,
when I tried to select a file from the dialog file-listing it seemed a bit unresponsive.
here is the screenshot.
and another question, is it possible to disable the animation when selecting files (the fly-in animation)?
and I also I want to make the selection by clicking the list item instead of the checkbox
Thank you
I have these config:
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.DIR_SELECT;
properties.root = new File("/sdcard/facedetect");
properties.extensions=null;
FilePickerDialog dialog = new FilePickerDialog(MainActivity.this, properties);
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
}
});
dialog.show();
I have noticed that if I use DIR_SELECT
, I cannot get the path from String[] files
. Following is the screenshot
Is a filter for filetypes (e.g. RegEx based) planned? I need a file picker that only shows SVG files :)
hello,
the path given at instantiation is the root node for the dialog, meaning you can navigate up and down from there, but you can't get up....
now i give that path, from a stored variable, so as to move the user to a section of the filesystem where his files are supposed to be....
but once set, he can't escape the actual project to go to the next.... anyway to set a top-most root and an actual position ?
It's an excellent filepicker but i can't set a title for the filepicker dialog
Title says it all. Feels like it wasn't clicked. Any quick fix?
I am using the FilePicker as a download file path selector. The user navigates to the directory they would like to save their files in and selects that folder. However, in the current implementation, that behavior does not work. Instead, the user is required to select their desired directory using the checkbox button.
I think that the library should return the file path the user navigated to without the checkbox requirement.
After switching to 1.0.3 I think I might switch back to 1.0.2. The animations are a bit too much. They definitely look cool, but my users aren't going to like it. It's hard to scroll quickly and find things and my app needs quick lookups :-/
Also when you select a file and stuff starts flying all over the screen it is too much. It almost looks like a glitch. Is it supposed to be doing all that just from hitting a checkbox? Is there a way for me to make just the check box "check" and "uncheck" without anything else moving?
One final question; can I change the colors? I need to make them match my app.
Thanks Angad.
Code:
myFilePickDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
...
}
});
It does not seem to be called when Cancel is selected..
If I tap only if checkboxes or only on elements everything is ok.
But if I tap first on checkbox and after that I tap on other element, that element is not checked only if tap it once again.
Same thing if I check and element and after that a checkbox from other element.
So in those cases the selected state is interchanged somehow.
In the files listview, clicking on a directory will open the directory, but clicking on a file does nothing unless you click on the checkbox next to file. This makes user experience very inconvenient.
Is there any work-around to this or could you please fix this?
比如,我想把黑色头部设置成主题色,想把选择按钮改为删除等等。。
Is it possible mark specific files or folders when you open dialog?
if not, it can be realized in the next version?
same as title
Even in single mode, check boxes are visible for all files. It gives a feel of being in multi-mode. Is there any way to hide check boxes and let user select the file only on clicking it for (single mode).
When I tried to grant the storage permission, android system's dialog is poped.
It says "Screen overlay detected - To change this permission setting you first have to turn off the screen overlay from Settings > Apps".
Usually this problem is caused by screen filter application but I don't use any of them.
Anyway I found that is caused by toast message.
[ FilePickerDialog.onShow() - Line203]
Toast.makeText(context,"Application needs you permission to access SD Card",Toast.LENGTH_LONG).show();
If I wait until the message disappears then I can get the app's storage permission.
Different method would be necessary to inform about permission.
can you make an option that also show the sizes of files?
if possible in humanreadable format (Bytes, KiB, MiB .... )
Hi
How to change colors or style of FilePickerDialog in code?
Getting color this way should help for changing themes:
int[] attrs = new int[] { R.attr.colorPrimary/* index 0 */}; TypedArray ta = obtainStyledAttributes(attrs); ta.getColor(0,0); ta.recycle();
Thank you
Love that lib :)
Hi,
Thanks for previous updates.
Currently theres a conflict with the title attribute on FilePickerPreference, I refer to the following compilation error:
Error:(271) Attribute "title" has already been defined
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Applications/Android/sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
This seems to be an internal Android flaw as mentioned here:
http://stackoverflow.com/questions/18617413/attribute-title-has-already-been-defined-after-adding-after-adding-android-s
I think the conflict is because I am using android.support.v7.widget.Toolbar.
Please assist in getting a work around going.
Kind Regards
Willem
I don't want to use the animation,how do I close it?thanks!
I am on version 1.02 and still getting a null pointer exception when I try to choose a directory:
java.lang.NullPointerException at com.github.angads25.filepicker.view.FilePickerDialog$1.onClick(FilePickerDialog.java:100)
This is my code:
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.DIR_SELECT;
properties.root = new File(DialogConfigs.STORAGE_DIR);
properties.extensions = null;
FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
Log.d(TAG, "onSelectedFilePaths: " + files.length);
if (files.length > 0) {
//stuff
}
}
});
dialog.show();`
When root is set to directory"/storage" on Marshmallow , the dialog does not list any folders. That directory has the following two sub-directories:
emulated
self
parent.setLocation(currLoc.getParentFile().getAbsolutePath());
if there is no access to the parent directory we have NPE, because currLoc.getParentFile() return null
I do fork and commit
https://github.com/yanchumak/android-filepicker/commit/4467efd57c47cd7fde400e9543c0f2687e7af231
now if you touch the row (filename) it just lights up shortly and nothing else happens.
can you make an option so that this will select the file?
this would be the natural way people select things
It seems that I can't find any options on your wiki to allow switch to internal / external card.
So it would be nice if you add this feature to this library.
Thanks :)
type=1400 audit(0.0:4262): avc: denied { read } for name="/" dev="rootfs" ino=2 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 ppid=2834 pcomm="main" pgid=2834 pgcomm="main"
08-01 12:08:17.129 W/System.err(30056): java.lang.NullPointerException: Attempt to get length of null array
08-01 12:08:17.129 W/System.err(30056): at com.github.angads25.filepicker.filepicker.utils.Utility(SourceFile:72)
08-01 12:08:17.129 W/System.err(30056): at com.github.angads25.filepicker.view.FilePickerDialog.onStart(SourceFile:240)
08-01 12:08:17.129 W/System.err(30056): at android.app.Dialog.show(Dialog.java:302)
08-01 12:08:17.129 W/System.err(30056): at com.github.angads25.filepicker.view.FilePickerDialog.show(SourceFile:417)
Android: 7.1.1 (API: 25)
Manufacturer: Sony
Model: G8142
Device: G8142
Board: msm8998
Brand: Sony
Product: G8142
Screen: 1080x1776 (403dpi, xxhdpi)
how to close animation?
Can I disable select button from popup before I selecting at least a file?
To help users of you Dialog dealing with the theme, you could as well simply implement a constructor of FilePickerDialog that gets the parameters of Dialog : public Dialog(@nonnull Context context, @StyleRes int themeResId) si that they can modifiy the theme.
Very simple to put in place : add this constructor :
public FilePickerDialog(Context context, DialogProperties properties, @StyleRes int themeResId) {
super(context, themeResId);
this.context = context;
this.properties = properties;
filter = new ExtensionFilter(properties);
internalList = new ArrayList<>();
}
and it's done !
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String java.io.File.getAbsolutePath()’ on a null object reference
at com.github.angads25.filepicker.view.FilePickerDialog.onItemClick(SourceFile:213)
at android.widget.AdapterView.performItemClick(AdapterView.java:334)
at android.widget.AbsListView.performItemClick(AbsListView.java:1531)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3664)
at android.widget.AbsListView$3.run(AbsListView.java:5585)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
My users do not like the behavior of the check boxes. They do not look like the screenshots. The check boxes are invisible until checked. It actually took us a while to realize we could even touch in that area to select a file.
I recommend you make the check boxes visible even when not checked. Either that or make the selection by clicking the file, but that would mess with the directory selection. Easiest way is to make all check boxes visible.
I know how to do it, but I am not sure how to recompile the library with my changes. I messed with android studio all day today and can't figure it out.
If you do this change then I would LOVE to use your library.
EDIT:
I should probably have mentioned... GREAT WORK!!! This library is awesome either way and looks great. It will be a huge time saver for me and looks better than some other ones I have seen. Just need this ooooooone tiny thing changed.
For some reason if I set the background color in my app, header looks weird (filepicker/src/main/res/layout/dialog_header.xml).
Hi,
I'm referring to the text that reads "sdcard/sdcard", it would be nice to
prompt the user to e.g. "Please select file(s) or directory" or "Please
select your profile data?".
See image (current):
https://imagebin.ca/v/2uU9uuc1iRzU
Prospected scenario:
https://imagebin.ca/v/2uUA7iGq6pSq
Also is there a way to turn off the animation?
Kind Regards,
WIllem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.