├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── in │ │ └── arjsna │ │ └── filechooser │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── in │ │ │ └── arjsna │ │ │ └── filechooserdemo │ │ │ ├── FileListAdaptper.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-hdpi │ │ ├── check_mark.png │ │ └── left_arrow_icon.png │ │ ├── drawable-mdpi │ │ ├── check_mark.png │ │ └── left_arrow_icon.png │ │ ├── drawable-xhdpi │ │ ├── check_mark.png │ │ └── left_arrow_icon.png │ │ ├── drawable-xxhdpi │ │ ├── check_mark.png │ │ └── left_arrow_icon.png │ │ ├── drawable-xxxhdpi │ │ └── left_arrow_icon.png │ │ ├── layout │ │ ├── activity_main.xml │ │ └── file_item.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── in │ └── arjsna │ └── filechooser │ └── ExampleUnitTest.java ├── build.gradle ├── filechooser ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── in │ │ └── arjsna │ │ └── filechooser │ │ ├── Bucket.java │ │ ├── BucketListAdapter.java │ │ ├── FileBucketsListFragment.java │ │ ├── FileChooseHelperActivity.java │ │ ├── FileItem.java │ │ ├── FileLibUtils.java │ │ ├── FileSelectFragment.java │ │ └── FilesListAdapter.java │ └── res │ ├── anim │ ├── scale_down_anim.xml │ └── scale_up_anim.xml │ ├── drawable-hdpi │ ├── check_mark.png │ └── left_arrow_icon.png │ ├── drawable-mdpi │ ├── check_mark.png │ └── left_arrow_icon.png │ ├── drawable-xhdpi │ ├── check_mark.png │ └── left_arrow_icon.png │ ├── drawable-xxhdpi │ ├── check_mark.png │ └── left_arrow_icon.png │ ├── drawable │ └── button_bg_green.xml │ ├── layout │ ├── activity_files_choose_helper.xml │ ├── bucket_list_item.xml │ ├── file_item_view.xml │ ├── fragment_file_buckets.xml │ └── fragment_file_select.xml │ └── values │ ├── colors.xml │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | *.apk -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-file-chooser 2 | Android library to provide chooser for files in External storage 3 | 4 | ## Demo 5 | 6 | GooglePlay Link 7 | 8 | 9 | 10 | ## Installation 11 | * Clone the repository and copy the `filechooser` module to your project 12 | * Modify the layout files under layout folder according to your UI requirement 13 | 14 | ## Usage 15 | 16 | To choose from all image files 17 | 18 | ```java 19 | Intent addPhotosIntent = new Intent(MainActivity.this, FileChooseHelperActivity.class); 20 | addPhotosIntent.putExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_IMAGES); 21 | startActivityForResult(addPhotosIntent, STORAGE_REQUEST_CODE); 22 | ``` 23 | 24 | To choose from all video files 25 | 26 | ```java 27 | Intent addPhotosIntent = new Intent(MainActivity.this, FileChooseHelperActivity.class); 28 | addPhotosIntent.putExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_VIDEOS); 29 | startActivityForResult(addPhotosIntent, STORAGE_REQUEST_CODE); 30 | ``` 31 | 32 | You can get the result of above two request in `onActivityResult()` of the activity 33 | 34 | ```java 35 | @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { 36 | super.onActivityResult(requestCode, resultCode, data); 37 | if (requestCode == STORAGE_REQUEST_CODE && resultCode == RESULT_OK) { 38 | ArrayList stringArrayExtra = data.getStringArrayListExtra(FileLibUtils.SELECTED_FILES); 39 | //the ArrayList will contain the absolute paths of selected files 40 | .... 41 | 42 | 43 | .... 44 | } 45 | } 46 | ``` 47 | 48 | You can also use the below method to get Folder and File lists 49 | 50 | ```java 51 | ArrayList buckets = 52 | FileLibUtils.fetchLocalBuckets(MainActivity.this, FileLibUtils.FILE_TYPE_IMAGES); 53 | ArrayList filesInBucket = 54 | FileLibUtils.getFilesInBucket(MainActivity.this, buckets.get(0).bucketId, 55 | FileLibUtils.FILE_TYPE_IMAGES); 56 | ``` 57 | 58 | 59 | 60 | 61 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. 62 | You may obtain a copy of the License in the LICENSE file, or at: 63 | 64 | http://www.apache.org/licenses/LICENSE-2.0 65 | 66 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 67 | 68 | 69 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "in.arjsna.filechooserdemo" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | 30 | compile project(':filechooser') 31 | compile "com.android.support:recyclerview-v7:25.3.1" 32 | 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/arjun/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/in/arjsna/filechooser/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package in.arjsna.filechooser; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | import static org.junit.Assert.assertEquals; 10 | 11 | /** 12 | * Instrumentation test, which will execute on an Android device. 13 | * 14 | * @see Testing documentation 15 | */ 16 | @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { 17 | @Test public void useAppContext() throws Exception { 18 | // Context of the app under test. 19 | Context appContext = InstrumentationRegistry.getTargetContext(); 20 | 21 | assertEquals("in.arjsna.filechooser", appContext.getPackageName()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/in/arjsna/filechooserdemo/FileListAdaptper.java: -------------------------------------------------------------------------------- 1 | package in.arjsna.filechooserdemo; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * Created by arjun on 12/6/17. 13 | */ 14 | 15 | public class FileListAdaptper extends RecyclerView.Adapter { 16 | 17 | private final Context context; 18 | private final ArrayList filePaths; 19 | 20 | public FileListAdaptper(Context context, ArrayList files) { 21 | this.context = context; 22 | this.filePaths = files; 23 | } 24 | 25 | @Override public FileListAdaptper.ListVH onCreateViewHolder(ViewGroup parent, int viewType) { 26 | return new ListVH(LayoutInflater.from(context).inflate(R.layout.file_item, parent, false)); 27 | } 28 | 29 | @Override public void onBindViewHolder(FileListAdaptper.ListVH holder, int position) { 30 | holder.textView.setText(filePaths.get(position)); 31 | } 32 | 33 | @Override public int getItemCount() { 34 | return filePaths.size(); 35 | } 36 | 37 | static class ListVH extends RecyclerView.ViewHolder { 38 | public TextView textView; 39 | 40 | public ListVH(View itemView) { 41 | super(itemView); 42 | textView = (TextView) itemView.findViewById(R.id.file_item_text); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/in/arjsna/filechooserdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package in.arjsna.filechooserdemo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.DividerItemDecoration; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.View; 10 | import in.arjsna.filechooser.FileChooseHelperActivity; 11 | import in.arjsna.filechooser.FileLibUtils; 12 | import java.util.ArrayList; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | private static final int STORAGE_REQUEST_CODE = 100; 17 | RecyclerView recyclerView; 18 | @Override protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | recyclerView = (RecyclerView) findViewById(R.id.selected_file_list); 22 | LinearLayoutManager layoutManager = new LinearLayoutManager(MainActivity.this); 23 | recyclerView.setLayoutManager(layoutManager); 24 | recyclerView.addItemDecoration(new DividerItemDecoration(MainActivity.this, layoutManager.getOrientation())); 25 | findViewById(R.id.filechoose_btn).setOnClickListener(new View.OnClickListener() { 26 | @Override public void onClick(View v) { 27 | Intent addPhotosIntent = new Intent(MainActivity.this, FileChooseHelperActivity.class); 28 | addPhotosIntent.putExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_IMAGES); 29 | startActivityForResult(addPhotosIntent, STORAGE_REQUEST_CODE); 30 | } 31 | }); 32 | findViewById(R.id.filechoose_btn_video).setOnClickListener(new View.OnClickListener() { 33 | @Override public void onClick(View v) { 34 | Intent addPhotosIntent = new Intent(MainActivity.this, FileChooseHelperActivity.class); 35 | addPhotosIntent.putExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_VIDEOS); 36 | startActivityForResult(addPhotosIntent, STORAGE_REQUEST_CODE); 37 | } 38 | }); 39 | //findViewById(R.id.filechoose_btn_audio).setOnClickListener(new View.OnClickListener() { 40 | // @Override public void onClick(View v) { 41 | // Intent addPhotosIntent = new Intent(MainActivity.this, FileChooseHelperActivity.class); 42 | // addPhotosIntent.putExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_AUDIO); 43 | // startActivityForResult(addPhotosIntent, STORAGE_REQUEST_CODE); 44 | // } 45 | //}); 46 | } 47 | 48 | @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { 49 | super.onActivityResult(requestCode, resultCode, data); 50 | if (requestCode == STORAGE_REQUEST_CODE && resultCode == RESULT_OK) { 51 | ArrayList stringArrayExtra = data.getStringArrayListExtra(FileLibUtils.SELECTED_FILES); 52 | FileListAdaptper fileListAdaptper = new FileListAdaptper(MainActivity.this, stringArrayExtra); 53 | recyclerView.setAdapter(fileListAdaptper); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/check_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-hdpi/check_mark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/left_arrow_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-hdpi/left_arrow_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/check_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-mdpi/check_mark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/left_arrow_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-mdpi/left_arrow_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/check_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-xhdpi/check_mark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/left_arrow_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-xhdpi/left_arrow_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/check_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-xxhdpi/check_mark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/left_arrow_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-xxhdpi/left_arrow_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/left_arrow_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/drawable-xxxhdpi/left_arrow_icon.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 |