hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

Navigating up in browser #27

Closed HappyAmos closed 5 years ago

HappyAmos commented 5 years ago

I used the template in your README.md to create a basic chooser for selecting a file, setting the path to the devices public Downloads folder. This works, and looks great. The only problem I'm running into is that the user can't navigate up past the root of internal storage. If I tell it to set the path as ROOT (Environment.getRootDirectory().toString()) than they can navigate everywhere, but the average user may be confused by the file path they are looking at. Can you suggest a way of allowing them to navigate to a file that may be on local OR external storage? I have already implemented the appropriate read permissions.

hedzr commented 5 years ago

withNavigateUpTo() can tell chooser kernel whether could go up from a folder:

                    .withNavigateUpTo(new ChooserDialog.CanNavigateUp() {
                        @Override
                        public boolean canUpTo(File dir) {
                            return true;
                        }
                    })

but you couldn't navigate up to a folder unless it has read permission. default withNavigateUpTo() handler checks the permission of dir to protected user cannot navigate to security area. and kernel codes do similar works on listing directories and files.

for the same reason, you could only give a start path if it has read permission. .withStartFile(_path) will check the start path for its existence and permission and relocated to internal storage root (/sdcard) if necessary. generally you couldn't use .withStartFile("/") because kernel code disable it (see ChooserDialog.java#L771).


unfortunately we had had no effective approaches to switch in multiple roots such as internal and external storage root.


in you case, try your callback with withNavigateUpTo(), it could be a way. too bad that almost not work.

hedzr commented 5 years ago

here is a temporary patch for u. if external storage presents, we add the faked ".. SDCard" or ".. Primary" entry at top of file list. try it and call me.

HappyAmos commented 5 years ago

I removed the old library reference from my build.gradle, did a Build -> Clean Project, then went into my top level build.gradle and added maven { url "https://jitpack.io" }. I went back into my second level build.gradle and added implementation 'com.github.hedzr:android-file-chooser:master-SNAPSHOT'. Now, however, the project won't build:

I know this isn't a technical support forum, but I'm unfamiliar with this process, and am not sure if I missed a step or if something was possibly typed in wrong off your instructions on the readme?

Could not find com.github.hedzr:android-file-chooser:master-SNAPSHOT.
Searched in the following locations:
    file:/home/andrew/Android/Sdk/extras/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    file:/home/andrew/Android/Sdk/extras/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.pom
    file:/home/andrew/Android/Sdk/extras/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.jar
    file:/home/andrew/Android/Sdk/extras/google/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    file:/home/andrew/Android/Sdk/extras/google/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.pom
    file:/home/andrew/Android/Sdk/extras/google/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.jar
    file:/home/andrew/Android/Sdk/extras/android/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    file:/home/andrew/Android/Sdk/extras/android/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.pom
    file:/home/andrew/Android/Sdk/extras/android/m2repository/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.jar
    https://dl.google.com/dl/android/maven2/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    https://dl.google.com/dl/android/maven2/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.pom
    https://dl.google.com/dl/android/maven2/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.jar
    https://jcenter.bintray.com/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    https://jcenter.bintray.com/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.pom
    https://jcenter.bintray.com/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-SNAPSHOT.jar
    https://jitpack.io/com/github/hedzr/android-file-chooser/master-SNAPSHOT/maven-metadata.xml
    https://jitpack.io/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-v1.1.10-g25460ba-84.pom
    https://jitpack.io/com/github/hedzr/android-file-chooser/master-SNAPSHOT/android-file-chooser-master-v1.1.10-g25460ba-84.jar
Required by:
    project :app
hedzr commented 5 years ago

it seems a bug from one of my commits, i'm fixing...

hedzr commented 5 years ago

i just posted a commit (d6467e57a53dc8a847e7dae59458191ad344d866) with wrong comment (#29). it fixed jitpack import error. please synchronizing your project again and importer should be fine.

HappyAmos commented 5 years ago

hmm, did a "clean" and it is still telling me Could not find com.github.hedzr:android-file-chooser:master-SNAPSHOT. Searched in the following locations:...

hedzr commented 5 years ago

i'm checking jitpack log and waiting for its building done.

hedzr commented 5 years ago

master-branch is ready. my sincerely.

HappyAmos commented 5 years ago

Looking good!