Git Product home page Git Product logo

android-folder-picker-library's Introduction

android-folder-picker-library

Demo Bintray Android Arsenal

A light-weight android library to let user's pick folder / files from storage.

Some Example Usages

  • Ask users to select folder for saving your app's files.
  • Ask users to point a folder to import / export data.
  • Ask users to choose file from phone storage for viewing, editing or any process.

Screenshots

Preview Preview Preview
Can pick folders Can create folder Can also pick file

Installation

For your convenience, it is available on jCenter, So just add this in your app dependencies:

    compile 'lib.kashif:folderpicker:2.4'

Usage

To pick folder

Just start FolderPicker activity from your app

        Intent intent = new Intent(this, FolderPicker.class);
        startActivityForResult(intent, FOLDERPICKER_CODE);        

If the user selects folder/file, the name of folder/file will be returned to you on onActivityResult method with the variable name 'data'.

        
        protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
          if (requestCode == FOLDERPICKER_CODE && resultCode == Activity.RESULT_OK) {

              String folderLocation = intent.getExtras().getString("data");
              Log.i( "folderLocation", folderLocation );
            
          }
        }
        

Options

Cusstomization options can be passed as extras to FolderPicker activity.

       //To show a custom title
       intent.putExtra("title", "Select file to upload");
       
       //To begin from a selected folder instead of sd card's root folder. Example : Pictures directory
       intent.putExtra("location", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
       
       //To pick files
       intent.putExtra("pickFiles", true);
       

Click here to see an example

License

Copyleft 2017 Kashif Anwaar.

Licensed under Apache 2.0

Do whatever you want with this library.

android-folder-picker-library's People

Contributors

kashifo 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

Watchers

 avatar  avatar  avatar  avatar  avatar

android-folder-picker-library's Issues

remove usages of jcenter

Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.

Stuck when going up

Exactly like the other issue that it is already close...
Two things happen:

  1. When I reach /storage, whatever I click, it doesn't open the folder.
  2. If I tap twice, the activity closes and the data in intent has no extras, so there is no path either.

Thank you.

Any plans to revive this repo ?

Is android-folder-picker-library actively maintained anymore ? It seems pretty dead right now. Any plans of restarting development ?

Regards

When moving to root path null pointer exception is raised

Is there a way to prevent the user from moving outside the /storage/emulated/0

On my app when I press up just launching the android folder picker library twice I get a null pointer exception because the app seems to fetch a non existing folder. I do not event press confirm, the exception is raised directly from the library activity

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=Intent { cmp=com.XXXXX/lib.folderpicker.FolderPicker }} to activity {com.XXXXX/com.XXXXXXX.activities.CreateBackupActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:4440)

stuck when going 'up' too much

Thank you for this library.

When going up above '/storage/emulated/0/' the picker behaves in strange ways.
It's probably related to the way android created these 'virtual paths'

possible solution: add an extra to the intend (max_height, top_reach)
eg. /storage/emulated/0/ > /storage/emulated/0/*
eg. /storage/emulated/0/DCIM/ > /storage/emulated/0/DCIM/*
eg. /storage/emulated/0/DCIM/Camera > /storage/emulated/0/DCIM/Camera*

Testdevice: Huawei p9 lite

Empty folders can be clicked multiple times

This makes the returned path null because the path of the empty folder gets concatenated to the return e.g. /storage/usbotg/usbotg I think. You should check whether a path can be accessed and remove or disable it from the list if it can't be.

Doesn't work on Build.VERSION_CODES.Q

No folders or file shows up on API Level 29.


2020-03-12 22:52:41.448 28903-28903/in.navigus.phonesync W/System.err: java.lang.NullPointerException: Attempt to get length of null array
2020-03-12 22:52:41.448 28903-28903/in.navigus.phonesync W/System.err:     at lib.folderpicker.FolderPicker.loadLists(FolderPicker.java:107)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at lib.folderpicker.FolderPicker.goBack(FolderPicker.java:192)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.view.View$DeclaredOnClickListener.onClick(View.java:6028)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.view.View.performClick(View.java:7192)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.view.View.performClickInternal(View.java:7166)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.view.View.access$3500(View.java:824)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.view.View$PerformClick.run(View.java:27592)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.os.Handler.handleCallback(Handler.java:888)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:100)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.os.Looper.loop(Looper.java:213)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:8178)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
2020-03-12 22:52:41.449 28903-28903/in.navigus.phonesync W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

Incorrect requestCode

By some reason onActivityResult gets incorrect requestCode (65869) instead of passed to startActivityForResult (333), resultCode is OK (-1).
The only difference with the example is that I called 'startActivityForResult' from the Fragment.
BTW, related 'onActivityResult' is called with correct "data" in returned 'intent'.

P.S. never mind, my bad, I should've call getActivity().startActivityForResult...

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.