Git Product home page Git Product logo

exfilepicker's Introduction

ExFilePicker

ExFilePicker is an open source android library that allows developers to easily implement choosing files and directories in application.

Screenshotes:

Screenshot Screenshot Screenshot

Features

It can:

  • Choose one file
  • Choose one directory
  • Choose few files and/or directories
  • Filter by file extension
  • Sorting
  • Creating directories

Download

  • Gradle:
repositories {
    jcenter()
}

dependencies {
    compile 'ru.bartwell:exfilepicker:2.1'
}
  • AAR:

Download AAR

Usage

1. Add ExFilePicker library as a dependency to your project

2. Use methods from ExFilePicker class to launch picker activity and receive result in onActivityResult():

	private static final int EX_FILE_PICKER_RESULT = 0;

	// ...
	
		ExFilePicker exFilePicker = new ExFilePicker();
        exFilePicker.start(this, EX_FILE_PICKER_RESULT);

	// ...
	
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == EX_FILE_PICKER_RESULT) {
		    ExFilePickerResult result = ExFilePickerResult.getFromIntent(data);
			if (result != null && result.getCount() > 0) {
				// Here is object contains selected files names and path
			}
		}
	}

Configuration

Class ExFilePicker have following methods for configuration:

  • setCanChooseOnlyOneItem() - if true, user can select only one item. False by default.

  • setShowOnlyExtensions() - only files with this extensions will showed.

  • setExceptExtensions() - files with this extensions will excluded.

  • setChoiceType() - one of value from ChoiceType. Set what user can select - only files, only directories or both. Both by default.

  • setStartDirectory() - This path will be open when ExFilePicker activity will called.

  • setNewFolderButtonDisabled() - if true, button "New folder" will not showing. You can also remove WRITE_EXTERNAL_STORAGE permission in this case.

  • setSortButtonDisabled() - if true, button "Sort" will not showing.

  • setQuitButtonEnabled() - if true, quit button will showing.

  • setSortingType() - one of value from SortingType. Set default sorting. NAME_ASC by default.

  • setUseFirstItemAsUpEnabled() - enable link to the parent directory as first item in list.

Feel free to look sample.

Customization

ExFilePicker library provide two themes for ExFilePicker's activity: dark and light (ExFilePickerThemeDark and ExFilePickerThemeLight respectively). If you need to customize ExFilePicker's activity view, you can extend your own theme from any ExFilePicker's theme and override needed options. To set theme you need specify activity in Manifest:

<activity
    android:name="ru.bartwell.exfilepicker.ui.activity.ExFilePickerActivity"
    android:theme="@style/ExFilePickerThemeDark"
    tools:replace="android:theme"/>

Sample Application

Sample application is no more available on Google Play: account 'bartwell' was banned and all appeals was declined or ignored. To see how it works you can download debug version here.

License

The MIT License (MIT)

Copyright (c) 2013 Artem Bazhanov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

exfilepicker's People

Contributors

andreykunitsky avatar bartwell avatar npes87184 avatar pylersm 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

exfilepicker's Issues

Missing com.bumptech.glide.Glide?

I use library-release.aar.
And when I enter some directory it will crash and the stack as follow:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.npes87184.s2tdroid, PID: 30809
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/Glide;
at ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder.bind(FileFilesListHolder.java:44)
at ru.bartwell.exfilepicker.ui.adapter.FilesListAdapter.onBindViewHolder(FilesListAdapter.java:87)
at ru.bartwell.exfilepicker.ui.adapter.FilesListAdapter.onBindViewHolder(FilesListAdapter.java:29)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6310)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6343)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5289)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5552)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5394)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5390)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2149)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1533)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1496)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:593)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3537)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3266)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3798)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:752)
at android.view.View.layout(View.java:17747)
at android.view.ViewGroup.layout(ViewGroup.java:5596)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2477)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2178)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1328)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6599)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:890)
at android.view.Choreographer.doCallbacks(Choreographer.java:692)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:876)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
07-09 09:21:19.795 30809-30809/com.npes87184.s2tdroid E/AndroidRuntime: at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6519)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:849)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.Glide" on path: DexPathList[[zip file "/data/app/com.npes87184.s2tdroid-1/base.apk"],nativeLibraryDirectories=[/data/app/com.npes87184.s2tdroid-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 59 more

Missing com.bumptech.glide.Glide?

related to #26.

I have tried and setup the glide, but will get the same result.

I add

compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
compile 'com.android.support:support-v4:25.3.1'

in gradle.

And add

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}

in proguard-rules.pro.

Also, I find it will happen when I use select file mode.

Fragment receives no result

Fragments have a method onActivityResult(). This is not called, when you call

ExFilePicker exFilePicker = new ExFilePicker();
exFilePicker.start(getActivity(), REQUEST_CODE_EXPORT_FILE);

inside the Fragment. Instead, only the Activity receives the onActivityResult(). You should provide a seperate overload of the start method, that takes a Fragment, instead of an Activity.

https://stackoverflow.com/questions/6147884/onactivityresult-is-not-being-called-in-fragment

Here is the fix:

public void start(@NonNull Fragment fragment, int requestCode) {
        Intent intent = new Intent(fragment.getActivity(), ExFilePickerActivity.class);
        intent.putExtra(ExFilePickerActivity.EXTRA_CAN_CHOOSE_ONLY_ONE_ITEM, mCanChooseOnlyOneItem);
        intent.putExtra(ExFilePickerActivity.EXTRA_SHOW_ONLY_EXTENSIONS, mShowOnlyExtensions);
        intent.putExtra(ExFilePickerActivity.EXTRA_EXCEPT_EXTENSIONS, mExceptExtensions);
        intent.putExtra(ExFilePickerActivity.EXTRA_IS_NEW_FOLDER_BUTTON_DISABLED, mIsNewFolderButtonDisabled);
        intent.putExtra(ExFilePickerActivity.EXTRA_IS_SORT_BUTTON_DISABLED, mIsSortButtonDisabled);
        intent.putExtra(ExFilePickerActivity.EXTRA_IS_QUIT_BUTTON_ENABLED, mIsQuitButtonEnabled);
        intent.putExtra(ExFilePickerActivity.EXTRA_CHOICE_TYPE, mChoiceType);
        intent.putExtra(ExFilePickerActivity.EXTRA_SORTING_TYPE, mSortingType);
        intent.putExtra(ExFilePickerActivity.EXTRA_START_DIRECTORY, mStartDirectory);
        intent.putExtra(ExFilePickerActivity.EXTRA_USE_FIRST_ITEM_AS_UP_ENABLED, mUseFirstItemAsUpEnabled);
        intent.putExtra(ExFilePickerActivity.EXTRA_HIDE_HIDDEN_FILES, mHideHiddenFilesEnabled);
        fragment.startActivityForResult(intent, requestCode);
    }

java.lang.OutOfMemoryError

java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3436)
at android.content.res.Resources.getDrawable(Resources.java:1909)
at android.widget.ImageView.resolveUri(ImageView.java:648)
at android.widget.ImageView.setImageResource(ImageView.java:377)
at ru.bartwell.exfilepicker.ExFilePickerActivity$FilesListAdapter$ThumbnailLoader.onPostExecute(ExFilePickerActivity.java:709)
at ru.bartwell.exfilepicker.ExFilePickerActivity$FilesListAdapter$ThumbnailLoader.onPostExecute(ExFilePickerActivity.java:650)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

# http://www.gnu.org/software/automake Makefile.in /ar-lib /mdate-sh /py-compile /test-driver /ylwrap .deps/ .dirstamp # http://www.gnu.org/software/autoconf autom4te.cache /autoscan.log /autoscan-*.log /aclocal.m4 /compile /config.cache /config.guess /config.h.in /config.log /config.status /config.sub /configure /configure.scan /depcomp /install-sh /missing /stamp-h1 # https://www.gnu.org/software/libtool/ /ltmain.sh # http://www.gnu.org/software/texinfo /texinfo.tex # http://www.gnu.org/software/m4/ m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 # Generated Makefile # (meta build system like autotools, # can automatically generate from config.status script # (which is called by configure script)) Makefile

Move up one directory

In root browser and es file explorer there are either breadcrumbs at the top of the screen, a parent directory listing as the first item in directory list/back arrow on top, or both. Although we can move up with the back button, it would be awesome to just include a parent directory link as the first item in the directory list like root browser.

This directory is empty issue

I'm using this library in my project, but when the file chooser activity is launched in its root directory (which in my case it is: '/storage/emulated/0/') I get the following error:
"This directory is empty" message.

Filter by extension error

Error in line 337 of ExFilePickerActivity.java: "!" is missing before s_filterByType.contains(getFileExtension(files[i].getName()))

Thumbnails for images not displaying

First of all, excellent work with the library. Very easy to use and extend. Perfectly what I require for my project. Thank you very much.

My only issue is that while I'm accessing the file system using the library in my own application, the preview thumbnails for the images are not showing up, whereas they are when I try the sample project attached.

Any idea why this is happening? Any help would be much appreciated.

(Update - It's a non-issue. I just set the starting directory to the base of my file-system instead of just "/", and it worked. Thanks anyway.)

feature enhancement?

hi,
That is a great lib!
Two suggestions:

  1. Add an exit button (user may want to cancel)
  2. When pressing return button, go to the position of selected folder. (i.e. u scroll to 107th folder, but u press 108th folder, then u press return button, and then u have to scroll to 107th folder from 1st folder again.)

But anyway, it works very well already, nice work!

Can not open my file

    Just open recently file ,It's my code :

val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_DEFAULT)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

        val contentUri = FileProvider.getUriForFile(this@TalentReportActivity, "com.gkzy.im.fileprovider", file)
        intent.setData(contentUri)
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
        intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri)
        startActivity(intent)
		}else{
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        intent.setDataAndType(Uri.fromFile(file),"*/*")
        startActivity(intent)
		}

How can I resove this problem?

Hide hidden files\folder

Can hidden files be not shown in the default theme. i.e. files and folders starting with "." Ex: .nomedia , .backups/

Больше иконок :3

Добавь иконки для книг, архивов, видео, музыки и apk-файлов. А то как-то уныло)

P.S. Да, знаю, глуповато, но сразу как-то красочнее станет)

Show/hide hidden files

Hello,

can you provide API to show/hide hidden files/dirs when browsing file system?

Thanks

where i can see the proguard rules ?

i'm facing problem when i produce release apk with proguard

Warning:ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder: can't find referenced method 'com.bumptech.glide.DrawableTypeRequest load(java.io.File)' in program class com.bumptech.glide.RequestManager Warning:ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder: can't find referenced class com.bumptech.glide.DrawableTypeRequest Warning:ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder: can't find referenced class com.bumptech.glide.DrawableTypeRequest Warning:ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder: can't find referenced class com.bumptech.glide.DrawableRequestBuilder Warning:ru.bartwell.exfilepicker.ui.adapter.holder.FileFilesListHolder: can't find referenced class com.bumptech.glide.DrawableRequestBuilder

how can solve this ?

Extension filter working incorrectly

I using this library to allow users to pick apk and jar files from the sdcard. So, I use the below line to configure ExFilePicker

intent.putExtra(ExFilePicker.SET_FILTER_BY_EXTENSION,new String[] { "apk", "jar" });

The problem is, now none of the apk (or) jar files are listed in the picker (all other extensions are displayed properly) . What has gone wrong here ?

Why changing from ActionBarSherlock

I noticed that in the latest version, you changed from ActionBarSherlock to ActionBarCompat. I understand that you didn't want to depend on other libraries, but in this case, tha ActionBarSherlock provides much better functionality in my opinion, especially in older, 2.x devices. Just look at these screenshots (it's from an Android 2.3.7 emulator)

New version with Compat:
sshot1

Older version with Sherlock:
sshot2

But even on a Samsung Galaxy Nexus with Android 4.2:
With Compat:
device-2014-02-01-195955

With Sherlock:
device-2014-02-01-200859

There should be a way to exit the file picker

It would be great if the file picker could be exited instantly without navigating back to the storage root. Maybe it could be implemented with Android "Up navigation" on the left top corner.

Configuration didn't take effect

This function 'setNewFolderButtonDisabled()','setSortButtonDisabled()' didn't take effect when I set the value ‘true’,the button is still on the toolbar. how to solve this problem? Thank u!

Ошибка "Эта папка пуста"

Проблема, описанная тут - #19, актуальна и версии 2.3.
При выходе из /storage/emulated/0 и повтором входе туда же пишет "Эта папка пуста".

stackoverflow on backpressed

Hello,
I have integrated your library in my application and some users (galaxy s4 users for example) have a stackoverflow exception when they press on back button.
I have tried to solve the issue but I can't.
Do you have any idea?
Best regards,

Vincent

Configuration

Hello,

Your project is very good and was very helpful for me to learn many new things.
But I could not configure the ExFilePicker as per my requirement. It always runs in the default settings.
Can you please share an example of how to configure it as per the requirement? It would be easy for me to understand.

Thank you,

Regards,
Prerak

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.