├── .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 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
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 |
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 |
20 |
29 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/file_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #009688
4 | #004b44
5 | #009688
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FileChooser
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/in/arjsna/filechooser/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test public void addition_isCorrect() throws Exception {
14 | assertEquals(4, 2 + 2);
15 | }
16 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/filechooser/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/filechooser/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | ext {
24 | supportLibraryVerion = "25.3.1"
25 | rxAndroidVersion = "2.0.1"
26 | rxJavaVersion = "2.1.0"
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
32 | exclude group: 'com.android.support', module: 'support-annotations'
33 | })
34 | compile "com.android.support:appcompat-v7:${supportLibraryVerion}"
35 | compile "com.android.support:recyclerview-v7:${supportLibraryVerion}"
36 | compile "com.android.support:design:${supportLibraryVerion}"
37 | compile "com.android.support:cardview-v7:${supportLibraryVerion}"
38 |
39 | compile "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"
40 | compile "io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
41 |
42 | compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
43 | testCompile 'junit:junit:4.12'
44 | }
45 |
--------------------------------------------------------------------------------
/filechooser/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 |
--------------------------------------------------------------------------------
/filechooser/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/Bucket.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | /**
4 | * Created by arjun on 16/2/16.
5 | */
6 | public class Bucket {
7 | public String bucketName;
8 | public String bucketId;
9 | public String bucketCoverImageFilePath;
10 | public int bucketContentCount;
11 | public int fileType;
12 | }
13 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/BucketListAdapter.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
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.ImageView;
9 | import android.widget.TextView;
10 | import com.bumptech.glide.Glide;
11 | import java.io.File;
12 | import java.util.ArrayList;
13 |
14 | /**
15 | * Created by arjun on 16/2/16.
16 | */
17 | public class BucketListAdapter extends RecyclerView.Adapter {
18 | private final Context context;
19 | private final ArrayList buckets;
20 | private LayoutInflater layoutInflater;
21 |
22 | public BucketListAdapter(Context context, ArrayList buckets) {
23 | this.context = context;
24 | this.buckets = buckets;
25 | layoutInflater = LayoutInflater.from(context);
26 | }
27 |
28 | @Override
29 | public BucketListAdapter.ListItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
30 | View view = layoutInflater.inflate(R.layout.bucket_list_item, parent, false);
31 | return new ListItemViewHolder(view);
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(BucketListAdapter.ListItemViewHolder holder, int position) {
36 | final Bucket bucket = buckets.get(position);
37 | holder.bucketNameView.setText(bucket.bucketName);
38 | holder.bucketCountCountView.setText(String.valueOf(bucket.bucketContentCount));
39 | Glide.with(holder.bucketCoverImageView.getContext())
40 | .load(new File(bucket.bucketCoverImageFilePath))
41 | .into(holder.bucketCoverImageView);
42 | }
43 |
44 | @Override public int getItemCount() {
45 | return buckets.size();
46 | }
47 |
48 | public void addAllAndNotify(ArrayList buckets) {
49 | this.buckets.addAll(buckets);
50 | notifyDataSetChanged();
51 | }
52 |
53 | public class ListItemViewHolder extends RecyclerView.ViewHolder {
54 | TextView bucketNameView;
55 | TextView bucketCountCountView;
56 | ImageView bucketCoverImageView;
57 |
58 | public ListItemViewHolder(View itemView) {
59 | super(itemView);
60 | bucketNameView = (TextView) itemView.findViewById(R.id.bucket_name_view);
61 | bucketCountCountView = (TextView) itemView.findViewById(R.id.bucket_content_count_view);
62 | bucketCoverImageView = (ImageView) itemView.findViewById(R.id.bucket_cover_iv);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FileBucketsListFragment.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import android.Manifest;
4 | import android.content.pm.PackageManager;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v7.widget.GridLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.support.v7.widget.Toolbar;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.MotionEvent;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.view.animation.Animation;
18 | import android.view.animation.AnimationUtils;
19 | import android.widget.ProgressBar;
20 | import android.widget.TextView;
21 | import io.reactivex.Single;
22 | import io.reactivex.SingleObserver;
23 | import io.reactivex.android.schedulers.AndroidSchedulers;
24 | import io.reactivex.annotations.NonNull;
25 | import io.reactivex.disposables.Disposable;
26 | import io.reactivex.schedulers.Schedulers;
27 | import java.util.ArrayList;
28 | import java.util.concurrent.Callable;
29 |
30 | /**
31 | * Created by arjun on 6/4/16.
32 | */
33 | public class FileBucketsListFragment extends Fragment {
34 | private static final int STORAGE_PERM_REQ = 200;
35 | private View mRootView;
36 | private RecyclerView mBucketListView;
37 | private BucketListAdapter mBucketListAdapter;
38 | private ArrayList buckets = new ArrayList<>();
39 |
40 | private static final int REQUEST_CODE = 321;
41 |
42 | private final float SCROLL_THRESHOLD = 10;
43 | private boolean isOnClick;
44 | private float mDownX;
45 | private float mDownY;
46 | private int currentViewingIdx;
47 | private Animation scaleDownAnim;
48 | private Animation scaleUpAnim;
49 | private int mFileTypeToChoose;
50 | private ProgressBar mProgressBar;
51 |
52 | public FileBucketsListFragment() {
53 | setRetainInstance(true);
54 | }
55 |
56 | @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
57 | Bundle savedInstanceState) {
58 | mRootView = inflater.inflate(R.layout.fragment_file_buckets, container, false);
59 | mFileTypeToChoose =
60 | getArguments().getInt(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_IMAGES);
61 | setUpActionBar();
62 | initialiseViews();
63 | bindEvents();
64 | if (buckets.size() < 1 && getPermissions()) {
65 | fetchBuckets();
66 | }
67 | return mRootView;
68 | }
69 |
70 | private boolean getPermissions() {
71 | if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECEIVE_SMS)
72 | != PackageManager.PERMISSION_GRANTED) {
73 | requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, STORAGE_PERM_REQ);
74 | return false;
75 | }
76 | return true;
77 | }
78 |
79 | @Override public void onRequestPermissionsResult(int requestCode, @android.support.annotation.NonNull
80 | String[] permissions,
81 | @android.support.annotation.NonNull int[] grantResults) {
82 | if (requestCode != STORAGE_PERM_REQ) {
83 | return;
84 | }
85 | if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
86 | fetchBuckets();
87 | } else {
88 | getActivity().finish();
89 | }
90 | }
91 |
92 | private void setUpActionBar() {
93 | Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.file_chooser_toolbar);
94 | TextView titleView = (TextView) toolbar.findViewById(R.id.file_chooser_toolBarTitle);
95 | titleView.setText(FileLibUtils.titleMap.get(mFileTypeToChoose));
96 | }
97 |
98 | private void bindEvents() {
99 | mBucketListView.setOnTouchListener(new View.OnTouchListener() {
100 | @Override public boolean onTouch(View v, MotionEvent event) {
101 | switch (event.getAction() & MotionEvent.ACTION_MASK) {
102 | case MotionEvent.ACTION_DOWN:
103 | mDownX = event.getX();
104 | mDownY = event.getY();
105 | View view = mBucketListView.findChildViewUnder(event.getX(), event.getY());
106 | if (view != null) {
107 | view.startAnimation(
108 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down_anim));
109 | }
110 | isOnClick = true;
111 | break;
112 | case MotionEvent.ACTION_UP:
113 | case MotionEvent.ACTION_CANCEL:
114 | if (isOnClick) {
115 | final View viewup = mBucketListView.findChildViewUnder(event.getX(), event.getY());
116 | if (viewup != null) {
117 | Animation animation =
118 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_anim);
119 | animation.setAnimationListener(new Animation.AnimationListener() {
120 | @Override public void onAnimationStart(Animation animation) {
121 |
122 | }
123 |
124 | @Override public void onAnimationEnd(Animation animation) {
125 | currentViewingIdx = mBucketListView.getChildAdapterPosition(viewup);
126 | Bucket bucket = buckets.get(currentViewingIdx);
127 | Bundle bundle = new Bundle();
128 | bundle.putString(FileSelectFragment.BUCKET_ID, bucket.bucketId);
129 | bundle.putString(FileSelectFragment.BUCKET_NAME, bucket.bucketName);
130 | bundle.putInt(FileSelectFragment.BUCKET_CONTENT_COUNT,
131 | bucket.bucketContentCount);
132 | bundle.putInt(FileLibUtils.FILE_TYPE_TO_CHOOSE, bucket.fileType);
133 | FileSelectFragment fileSelectFragment = new FileSelectFragment();
134 | fileSelectFragment.setArguments(bundle);
135 | getActivity().getSupportFragmentManager()
136 | .beginTransaction()
137 | .replace(R.id.files_selection_container, fileSelectFragment)
138 | .addToBackStack("File selection")
139 | .commit();
140 | }
141 |
142 | @Override public void onAnimationRepeat(Animation animation) {
143 |
144 | }
145 | });
146 | viewup.startAnimation(animation);
147 | }
148 | }
149 | break;
150 | case MotionEvent.ACTION_MOVE:
151 | if (isOnClick && (Math.abs(mDownX - event.getX()) > SCROLL_THRESHOLD
152 | || Math.abs(mDownY - event.getY()) > SCROLL_THRESHOLD)) {
153 | View viewup = mBucketListView.findChildViewUnder(event.getX(), event.getY());
154 | if (viewup != null) {
155 | viewup.startAnimation(
156 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_anim));
157 | }
158 | isOnClick = false;
159 | }
160 | break;
161 | }
162 | return false;
163 | }
164 | });
165 | }
166 |
167 | private void loadAnimations() {
168 | scaleDownAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down_anim);
169 | scaleUpAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_anim);
170 | }
171 |
172 | private void fetchBuckets() {
173 | Single> bucketFetch = Single.fromCallable(new Callable>() {
174 | @Override public ArrayList call() throws Exception {
175 | return FileLibUtils.fetchLocalBuckets(getActivity(), mFileTypeToChoose);
176 | }
177 | });
178 | bucketFetch.subscribeOn(Schedulers.io())
179 | .observeOn(AndroidSchedulers.mainThread())
180 | .subscribe(new SingleObserver>() {
181 | @Override public void onSubscribe(@NonNull Disposable d) {
182 | mProgressBar.setVisibility(View.VISIBLE);
183 | mBucketListView.setVisibility(View.GONE);
184 | }
185 |
186 | @Override public void onSuccess(@NonNull ArrayList buckets) {
187 | mBucketListAdapter.addAllAndNotify(buckets);
188 | mProgressBar.setVisibility(View.GONE);
189 | mBucketListView.setVisibility(View.VISIBLE);
190 | }
191 |
192 | @Override public void onError(@NonNull Throwable e) {
193 | Log.e("Error loading buckets", e.getMessage());
194 | }
195 | });
196 | }
197 |
198 | private void initialiseViews() {
199 | mProgressBar = (ProgressBar) mRootView.findViewById(R.id.fetch_bucket_progress);
200 | mBucketListView = (RecyclerView) mRootView.findViewById(R.id.buckets_list);
201 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
202 | mBucketListView.setLayoutManager(gridLayoutManager);
203 | mBucketListAdapter = new BucketListAdapter(getActivity(), buckets);
204 | mBucketListView.setAdapter(mBucketListAdapter);
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FileChooseHelperActivity.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import java.io.File;
9 |
10 | public class FileChooseHelperActivity extends AppCompatActivity {
11 |
12 | private File tempPhoto;
13 | private int mFileTypeToChoose;
14 |
15 | @Override protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_files_choose_helper);
18 | mFileTypeToChoose =
19 | getIntent().getIntExtra(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_IMAGES);
20 | setUpActionBar();
21 | if (savedInstanceState == null) {
22 | FileBucketsListFragment bucketsListFragment = new FileBucketsListFragment();
23 | Bundle bundle = new Bundle();
24 | bundle.putInt(FileLibUtils.FILE_TYPE_TO_CHOOSE, mFileTypeToChoose);
25 | bucketsListFragment.setArguments(bundle);
26 | getSupportFragmentManager().beginTransaction()
27 | .add(R.id.files_selection_container, bucketsListFragment)
28 | .commit();
29 | }
30 | }
31 |
32 | private void setUpActionBar() {
33 | Toolbar toolbar = (Toolbar) findViewById(R.id.file_chooser_toolbar);
34 | toolbar.setTitle("");
35 | toolbar.setNavigationIcon(R.drawable.left_arrow_icon);
36 | setSupportActionBar(toolbar);
37 | }
38 |
39 | @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
40 | super.onActivityResult(requestCode, resultCode, data);
41 | }
42 |
43 | @Override public boolean onOptionsItemSelected(MenuItem item) {
44 | switch (item.getItemId()) {
45 | case android.R.id.home:
46 | onBackPressed();
47 | return true;
48 | }
49 | return super.onOptionsItemSelected(item);
50 | }
51 |
52 | @Override public void onBackPressed() {
53 | super.onBackPressed();
54 | setResult(RESULT_CANCELED);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FileItem.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | /**
4 | * Created by arjun on 16/2/16.
5 | */
6 | public class FileItem {
7 | public String fileId;
8 | public String fileName;
9 | public String filePath;
10 | public String fileSize;
11 | public String fileThumbnailPath;
12 | public int fileType;
13 |
14 | public FileItem(int fileType) {
15 | this.fileType = fileType;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FileLibUtils.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.net.Uri;
6 | import android.provider.MediaStore;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.Map;
10 |
11 | /**
12 | * Created by arjun on 6/1/16.
13 | */
14 | public class FileLibUtils {
15 | //public final static int FILE_TYPE_ALL = 500;
16 | public final static int FILE_TYPE_IMAGES = 501;
17 | public final static int FILE_TYPE_VIDEOS = 502;
18 | //public final static int FILE_TYPE_AUDIO = 503;
19 | //public final static int TAKE_PICTURE = 504;
20 | //public final static int TAKE_VIDEO = 505;
21 |
22 | public final static Map titleMap = new HashMap() {
23 | {
24 | //put(FILE_TYPE_ALL, "All files");
25 | put(FILE_TYPE_IMAGES, "All Images");
26 | put(FILE_TYPE_VIDEOS, "All Videos");
27 | //put(FILE_TYPE_AUDIO, "All Audios");
28 | }
29 | };
30 |
31 | public final static Map uriMap = new HashMap() {
32 | {
33 | // put(FILE_TYPE_ALL, "All files");
34 | put(FILE_TYPE_IMAGES, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
35 | put(FILE_TYPE_VIDEOS, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
36 | //put(FILE_TYPE_AUDIO, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
37 | }
38 | };
39 |
40 | public final static String FILE_TYPE_TO_CHOOSE = "in.arj.fileselectionlib.FILE_TYPE_TO_CHOOSE";
41 | public static final String SELECTED_FILES = "selected_files";
42 |
43 | public static ArrayList fetchLocalBuckets(Context context, int mFileTypeToChoose) {
44 | ArrayList buckets = new ArrayList<>();
45 | Map bucketFileCountMap = new HashMap<>();
46 | String[] projection = getBucketProjection(mFileTypeToChoose);
47 | Uri queryUri = uriMap.get(mFileTypeToChoose);
48 | // Create the cursor pointing to the SDCard
49 | Cursor cursor =
50 | context.getContentResolver().query(queryUri, projection, // Which columns to return
51 | null, // Return all rows
52 | null, MediaStore.MediaColumns.DATE_ADDED + " DESC");
53 | int columnIndexBucketId = cursor.getColumnIndexOrThrow(projection[0]);
54 | int columnIndexBucketName = cursor.getColumnIndexOrThrow(projection[1]);
55 | int columnIndexFilePath = cursor.getColumnIndexOrThrow(projection[2]);
56 | while (cursor.moveToNext()) {
57 | // Log.i("BUCKET_DISPLAY_NAME ", cursor.getString(columnIndexBucketName) + " " + cursor.getString(columnIndexBucketId));
58 | String bucketId = cursor.getString(columnIndexBucketId);
59 | if (bucketFileCountMap.containsKey(bucketId)) {
60 | bucketFileCountMap.put(bucketId, bucketFileCountMap.get(bucketId) + 1);
61 | } else {
62 | Bucket bucket = new Bucket();
63 | bucket.bucketId = bucketId;
64 | bucket.bucketName = cursor.getString(columnIndexBucketName);
65 | bucket.bucketCoverImageFilePath = cursor.getString(columnIndexFilePath);
66 | bucket.fileType = mFileTypeToChoose;
67 | buckets.add(bucket);
68 | bucketFileCountMap.put(bucketId, 1);
69 | }
70 | }
71 | for (Bucket bucket : buckets) {
72 | bucket.bucketContentCount = bucketFileCountMap.get(bucket.bucketId);
73 | }
74 | cursor.close();
75 | return buckets;
76 | }
77 |
78 | private static String[] getBucketProjection(int fileType) {
79 | if (fileType == FILE_TYPE_IMAGES) {
80 | return new String[] {
81 | MediaStore.Images.Media.BUCKET_ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
82 | MediaStore.Images.Media.DATA
83 | };
84 | } else if (fileType == FILE_TYPE_VIDEOS) {
85 | return new String[] {
86 | MediaStore.Video.Media.BUCKET_ID, MediaStore.Video.Media.BUCKET_DISPLAY_NAME,
87 | MediaStore.Video.Media.DATA
88 | };
89 | } else {
90 | return new String[] {
91 | MediaStore.Audio.Media.ALBUM_ID, MediaStore.Audio.AudioColumns.ALBUM,
92 | MediaStore.Audio.Media.DATA
93 | };
94 | }
95 | }
96 |
97 | public static ArrayList getFilesInBucket(Context context, String bucketId,
98 | int fileType) {
99 | ArrayList fileItems = new ArrayList<>();
100 | String[] projection = getFileProjection(fileType);
101 | Uri queryUri = uriMap.get(fileType);
102 | // Create the cursor pointing to the SDCard
103 | Cursor cursor =
104 | context.getContentResolver().query(queryUri, projection, // Which columns to return
105 | projection[4] + " = '" + bucketId + "'", // Return all rows
106 | null, MediaStore.MediaColumns.DATE_ADDED + " DESC");
107 | int columnIndexFileId = cursor.getColumnIndexOrThrow(projection[0]);
108 | int columnIndexFileName = cursor.getColumnIndexOrThrow(projection[1]);
109 | int columnIndexFileSize = cursor.getColumnIndexOrThrow(projection[2]);
110 | int columnIndexFilePath = cursor.getColumnIndexOrThrow(projection[3]);
111 | int columnIndexFileThumbPath = cursor.getColumnIndexOrThrow(projection[5]);
112 | while (cursor.moveToNext()) {
113 | FileItem fileItem = new FileItem(fileType);
114 | fileItem.fileId = cursor.getString(columnIndexFileId);
115 | fileItem.fileName = cursor.getString(columnIndexFileName);
116 | fileItem.filePath = cursor.getString(columnIndexFilePath);
117 | fileItem.fileSize = cursor.getString(columnIndexFileSize);
118 | fileItem.fileThumbnailPath = cursor.getString(columnIndexFileThumbPath);
119 | fileItems.add(fileItem);
120 | }
121 | cursor.close();
122 | return fileItems;
123 | }
124 |
125 | private static String[] getFileProjection(int fileType) {
126 | switch (fileType) {
127 | default:
128 | case FILE_TYPE_IMAGES:
129 | return new String[] {
130 | MediaStore.Images.Media._ID, MediaStore.Images.Media.DISPLAY_NAME,
131 | MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATA,
132 | MediaStore.Images.Media.BUCKET_ID, MediaStore.Images.Thumbnails.DATA
133 | };
134 | case FILE_TYPE_VIDEOS:
135 | return new String[] {
136 | MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME,
137 | MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DATA,
138 | MediaStore.Video.Media.BUCKET_ID, MediaStore.Video.Thumbnails.DATA
139 | };
140 | //case FILE_TYPE_AUDIO:
141 | // return new String[] {
142 | // MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DISPLAY_NAME,
143 | // MediaStore.Audio.Media.SIZE, MediaStore.Audio.Media.DATA,
144 | // MediaStore.Audio.Media.SIZE, MediaStore.Audio.Media.SIZE
145 | // };
146 | }
147 | }
148 | }
149 |
150 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FileSelectFragment.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v7.widget.GridLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.support.v7.widget.Toolbar;
11 | import android.util.Log;
12 | import android.view.GestureDetector;
13 | import android.view.LayoutInflater;
14 | import android.view.MotionEvent;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.view.animation.AnimationUtils;
18 | import android.widget.ProgressBar;
19 | import android.widget.TextView;
20 | import io.reactivex.Single;
21 | import io.reactivex.SingleObserver;
22 | import io.reactivex.android.schedulers.AndroidSchedulers;
23 | import io.reactivex.annotations.NonNull;
24 | import io.reactivex.disposables.Disposable;
25 | import io.reactivex.schedulers.Schedulers;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import java.util.concurrent.Callable;
29 |
30 | /**
31 | * Created by arjun on 16/2/16.
32 | */
33 | public class FileSelectFragment extends Fragment implements GestureDetector.OnGestureListener {
34 | public static final String BUCKET_NAME = "in.arjsna.fileselectionlib.BUCKET_NAME";
35 | public static final String BUCKET_ID = "in.arjsna.fileselectionlib.BUCKET_ID";
36 | public static final String BUCKET_CONTENT_COUNT =
37 | "in.arjsna.fileselectionlib.BUCKET_CONTENT_COUNT";
38 | private static final float SCROLL_THRESHOLD = 10;
39 | private String bucketName;
40 | private String bucketId;
41 | private RecyclerView mFilesListView;
42 | private ArrayList files = new ArrayList<>();
43 | private FilesListAdapter mFilesListAdapter;
44 | private int fileType;
45 | private float mDownX;
46 | private float mDownY;
47 | private boolean isOnClick;
48 | private int bucketContentCount;
49 | private TextView titleView;
50 | private TextView mAdddFilesButton;
51 | private View mRootView;
52 | private ProgressBar mProgressBar;
53 |
54 | @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
55 | Bundle savedInstanceState) {
56 | mRootView = inflater.inflate(R.layout.fragment_file_select, container, false);
57 | bucketName = getArguments().getString(BUCKET_NAME);
58 | bucketId = getArguments().getString(BUCKET_ID);
59 | bucketContentCount = getArguments().getInt(BUCKET_CONTENT_COUNT, 0);
60 | fileType =
61 | getArguments().getInt(FileLibUtils.FILE_TYPE_TO_CHOOSE, FileLibUtils.FILE_TYPE_IMAGES);
62 | setUpActionBar();
63 | initialiseViews();
64 | bindEvents();
65 | fetchFiles();
66 | return mRootView;
67 | }
68 |
69 | private void bindEvents() {
70 | mAdddFilesButton.setOnClickListener(new View.OnClickListener() {
71 | @Override public void onClick(View v) {
72 | if (mFilesListAdapter.getSelectedItemCount() > 0) {
73 | ArrayList filePaths = new ArrayList<>();
74 | List selectedItems = mFilesListAdapter.getSelectedItems();
75 | for (Integer idx : selectedItems) {
76 | filePaths.add(files.get(idx).filePath);
77 | }
78 | Intent intent = new Intent();
79 | intent.putStringArrayListExtra(FileLibUtils.SELECTED_FILES, filePaths);
80 | getActivity().setResult(Activity.RESULT_OK, intent);
81 | getActivity().finish();
82 | }
83 | }
84 | });
85 | final GestureDetector gestureDetector =
86 | new GestureDetector(getActivity(), FileSelectFragment.this);
87 | mFilesListView.setOnTouchListener(new View.OnTouchListener() {
88 | @Override public boolean onTouch(View v, MotionEvent event) {
89 | View view = mFilesListView.findChildViewUnder(event.getX(), event.getY());
90 | switch (event.getAction() & MotionEvent.ACTION_MASK) {
91 | case MotionEvent.ACTION_DOWN:
92 | mDownX = event.getX();
93 | mDownY = event.getY();
94 | if (view != null) {
95 | view.startAnimation(
96 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down_anim));
97 | }
98 | isOnClick = true;
99 | break;
100 | case MotionEvent.ACTION_UP:
101 | case MotionEvent.ACTION_CANCEL:
102 | if (isOnClick) {
103 | if (view != null) {
104 | view.startAnimation(
105 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_anim));
106 | int idx = mFilesListView.getChildAdapterPosition(view);
107 | mFilesListAdapter.toggleSelection(idx);
108 | }
109 | }
110 | break;
111 | case MotionEvent.ACTION_MOVE:
112 | if (isOnClick && (Math.abs(mDownX - event.getX()) > SCROLL_THRESHOLD
113 | || Math.abs(mDownY - event.getY()) > SCROLL_THRESHOLD)) {
114 | // View viewup = mFilesListView.findChildViewUnder(event.getX(), event.getY());
115 | if (view != null) {
116 | view.startAnimation(
117 | AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_anim));
118 | }
119 | isOnClick = false;
120 | }
121 | break;
122 | }
123 | return gestureDetector.onTouchEvent(event);
124 | }
125 | });
126 | }
127 |
128 | private void fetchFiles() {
129 | Single fileItems = Single.fromCallable(new Callable() {
130 | @Override public Boolean call() throws Exception {
131 | files.clear();
132 | files.addAll(FileLibUtils.getFilesInBucket(getActivity(), bucketId, fileType));
133 | return true;
134 | }
135 | });
136 | fileItems.subscribeOn(Schedulers.io())
137 | .observeOn(AndroidSchedulers.mainThread())
138 | .subscribe(new SingleObserver() {
139 | @Override public void onSubscribe(@NonNull Disposable d) {
140 | mProgressBar.setVisibility(View.VISIBLE);
141 | mFilesListView.setVisibility(View.GONE);
142 | }
143 |
144 | @Override public void onSuccess(@NonNull Boolean aBoolean) {
145 | titleView.setText(
146 | getResources().getString(R.string.selected_item_count, bucketName, 0, files.size()));
147 | mFilesListAdapter.notifyDataSetChanged();
148 | mProgressBar.setVisibility(View.GONE);
149 | mFilesListView.setVisibility(View.VISIBLE);
150 | }
151 |
152 | @Override public void onError(@NonNull Throwable e) {
153 | Log.e("Error loading file ", e.getMessage());
154 | }
155 | });
156 | }
157 |
158 | private void initialiseViews() {
159 | mProgressBar = (ProgressBar) mRootView.findViewById(R.id.file_load_pb);
160 | mAdddFilesButton = (TextView) mRootView.findViewById(R.id.add_file_button);
161 | mFilesListView = (RecyclerView) mRootView.findViewById(R.id.files_list);
162 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 3);
163 | mFilesListView.setLayoutManager(gridLayoutManager);
164 | mFilesListAdapter = new FilesListAdapter(getActivity(), files, selectedItemChangeListener);
165 | mFilesListView.setAdapter(mFilesListAdapter);
166 | }
167 |
168 | public FilesListAdapter.SelectedItemChangeListener selectedItemChangeListener =
169 | new FilesListAdapter.SelectedItemChangeListener() {
170 | @Override public void onSelectedItemsCountChanged() {
171 | int selectedItemCount = mFilesListAdapter.getSelectedItemCount();
172 | titleView.setText(
173 | getResources().getString(R.string.selected_item_count, bucketName, selectedItemCount,
174 | bucketContentCount));
175 | if (selectedItemCount > 0) {
176 | mAdddFilesButton.setVisibility(View.VISIBLE);
177 | } else {
178 | mAdddFilesButton.setVisibility(View.GONE);
179 | }
180 | }
181 | };
182 |
183 | private void setUpActionBar() {
184 | Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.file_chooser_toolbar);
185 | toolbar.setTitle("");
186 | titleView = (TextView) toolbar.findViewById(R.id.file_chooser_toolBarTitle);
187 | }
188 |
189 | @Override public boolean onDown(MotionEvent e) {
190 | return true;
191 | }
192 |
193 | @Override public void onShowPress(MotionEvent e) {
194 |
195 | }
196 |
197 | @Override public boolean onSingleTapUp(MotionEvent e) {
198 | return false;
199 | }
200 |
201 | @Override
202 | public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
203 | Log.i("Testscroll", "Dis " + distanceY);
204 | if (distanceY > 0 && mAdddFilesButton.getVisibility() == View.VISIBLE) {
205 | mAdddFilesButton.setVisibility(View.GONE);
206 | } else if (distanceY < 0
207 | && mFilesListAdapter.getSelectedItemCount() > 0
208 | && mAdddFilesButton.getVisibility() == View.GONE) {
209 | mAdddFilesButton.setVisibility(View.VISIBLE);
210 | }
211 | return false;
212 | }
213 |
214 | @Override public void onLongPress(MotionEvent e) {
215 | // View view = mFilesListView.findChildViewUnder(e.getX(), e.getY());
216 | // if(view != null) {
217 | // int idx = mFilesListView.getChildAdapterPosition(view);
218 | // mFilesListAdapter.toggleSelection(idx);
219 | // Intent fullViewIntent = new Intent(getActivity(), FullViewActivity.class);
220 | // fullViewIntent.putExtra(FullViewActivity.FILE_PATH, files.get(idx).filePath);
221 | // if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
222 | // ActivityOptions options = ActivityOptions.
223 | // makeSceneTransitionAnimation(getActivity(), view, getResources().getString(R.string.shared_image_view));
224 | // startActivity(fullViewIntent, options.toBundle());
225 | // } else {
226 | // startActivity(fullViewIntent);
227 | // }
228 | // }
229 | }
230 |
231 | @Override
232 | public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
233 | return false;
234 | }
235 |
236 | // @Override
237 | // public void onBackPressed() {
238 | // Intent result = new Intent();
239 | // result.putExtra(BUCKET_ID, bucketId);
240 | // result.putExtra(BUCKET_CONTENT_COUNT, files.size());
241 | // setResult(Activity.RESULT_OK, result);
242 | // super.onBackPressed();
243 | // }
244 | }
245 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/in/arjsna/filechooser/FilesListAdapter.java:
--------------------------------------------------------------------------------
1 | package in.arjsna.filechooser;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.SparseBooleanArray;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.RelativeLayout;
11 | import com.bumptech.glide.Glide;
12 | import java.io.File;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * Created by arjun on 16/2/16.
18 | */
19 | public class FilesListAdapter extends RecyclerView.Adapter {
20 | private final Context context;
21 | private final ArrayList fileItems;
22 | private final LayoutInflater layoutInflater;
23 | private final SelectedItemChangeListener selectedItemChangeListener;
24 |
25 | public FilesListAdapter(Context context, ArrayList files,
26 | SelectedItemChangeListener selectedItemChangeListener) {
27 | this.context = context;
28 | this.fileItems = files;
29 | this.selectedItemChangeListener = selectedItemChangeListener;
30 | layoutInflater = LayoutInflater.from(context);
31 | }
32 |
33 | @Override public ListItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
34 | View view = layoutInflater.inflate(R.layout.file_item_view, parent, false);
35 | return new ListItemViewHolder(view);
36 | }
37 |
38 | @Override public void onBindViewHolder(final ListItemViewHolder holder, final int position) {
39 | FileItem fileItem = fileItems.get(position);
40 | Glide.with(holder.fileImageView.getContext())
41 | .load(new File(fileItem.fileThumbnailPath))
42 | .into(holder.fileImageView);
43 | if (selectedItemsArray.get(position, false)) {
44 | holder.activeStateLayout.setVisibility(View.VISIBLE);
45 | } else {
46 | holder.activeStateLayout.setVisibility(View.GONE);
47 | }
48 | }
49 |
50 | @Override public int getItemCount() {
51 | return fileItems.size();
52 | }
53 |
54 | public class ListItemViewHolder extends RecyclerView.ViewHolder {
55 | ImageView fileImageView;
56 | RelativeLayout activeStateLayout;
57 |
58 | public ListItemViewHolder(View itemView) {
59 | super(itemView);
60 | fileImageView = (ImageView) itemView.findViewById(R.id.file_image_view);
61 | activeStateLayout = (RelativeLayout) itemView.findViewById(R.id.item_active_layout);
62 | }
63 | }
64 |
65 | private SparseBooleanArray selectedItemsArray = new SparseBooleanArray();
66 |
67 | public void toggleSelection(int position) {
68 | if (selectedItemsArray.get(position, false)) {
69 | selectedItemsArray.delete(position);
70 | } else {
71 | selectedItemsArray.put(position, true);
72 | }
73 | selectedItemChangeListener.onSelectedItemsCountChanged();
74 | notifyItemChanged(position);
75 | }
76 |
77 | public void clearSelections() {
78 | selectedItemsArray.clear();
79 | notifyDataSetChanged();
80 | selectedItemChangeListener.onSelectedItemsCountChanged();
81 | }
82 |
83 | public List getSelectedItems() {
84 | List items = new ArrayList<>(selectedItemsArray.size());
85 | for (int i = 0; i < selectedItemsArray.size(); i++) {
86 | items.add(selectedItemsArray.keyAt(i));
87 | }
88 | return items;
89 | }
90 |
91 | public int getSelectedItemCount() {
92 | return selectedItemsArray.size();
93 | }
94 |
95 | public interface SelectedItemChangeListener {
96 | void onSelectedItemsCountChanged();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/anim/scale_down_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
12 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/anim/scale_up_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
12 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-hdpi/check_mark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-hdpi/check_mark.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-hdpi/left_arrow_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-hdpi/left_arrow_icon.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-mdpi/check_mark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-mdpi/check_mark.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-mdpi/left_arrow_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-mdpi/left_arrow_icon.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-xhdpi/check_mark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-xhdpi/check_mark.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-xhdpi/left_arrow_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-xhdpi/left_arrow_icon.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-xxhdpi/check_mark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-xxhdpi/check_mark.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable-xxhdpi/left_arrow_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/filechooser/src/main/res/drawable-xxhdpi/left_arrow_icon.png
--------------------------------------------------------------------------------
/filechooser/src/main/res/drawable/button_bg_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/layout/activity_files_choose_helper.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
18 |
27 |
28 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/layout/bucket_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
24 |
32 |
44 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/layout/file_item_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
23 |
30 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/layout/fragment_file_buckets.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
20 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/layout/fragment_file_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
18 |
32 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #333333
5 | #AAAAAA
6 | #EAEAEA
7 | #D1D4D9
8 | #25a930
9 |
10 | #66000000
11 | #33000000
12 | #707070
13 | #EEEEEE
14 | #E4E4E4
15 |
16 |
--------------------------------------------------------------------------------
/filechooser/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 | Add Files
4 | %1$s (%2$d / %3$d)
5 |
6 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arjun-sna/android-file-chooser/6976df0f675ae83d7fd35968b643878aa8cac14d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 12 10:05:50 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':filechooser'
2 |
--------------------------------------------------------------------------------