├── .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
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── isabsent
│ │ └── filepickerdemo
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable-xxxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── activity_main.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── filepicker
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── isabsent
│ │ └── filepicker
│ │ ├── SimpleFilePickerDialog.java
│ │ ├── comparator
│ │ ├── FileComparator.java
│ │ └── FileNameComparator.java
│ │ └── entity
│ │ ├── Item.java
│ │ ├── ItemViewHolder.java
│ │ └── SimpleFilePickerItem.java
│ └── res
│ ├── layout-v17
│ ├── simple_list_item_1.xml
│ ├── simple_list_item_multiple_choice.xml
│ └── simple_list_item_single_choice.xml
│ ├── layout
│ ├── simple_list_item_1.xml
│ ├── simple_list_item_multiple_choice.xml
│ └── simple_list_item_single_choice.xml
│ ├── mipmap-hdpi
│ ├── ic_folder_black_24dp.png
│ └── ic_insert_drive_file_black_24dp.png
│ ├── mipmap-mdpi
│ ├── ic_folder_black_24dp.png
│ └── ic_insert_drive_file_black_24dp.png
│ ├── mipmap-xhdpi
│ ├── ic_folder_black_24dp.png
│ └── ic_insert_drive_file_black_24dp.png
│ ├── mipmap-xxhdpi
│ ├── ic_folder_black_24dp.png
│ └── ic_insert_drive_file_black_24dp.png
│ ├── mipmap-xxxhdpi
│ ├── ic_folder_black_24dp.png
│ └── ic_insert_drive_file_black_24dp.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot
├── Screenshot_01.png
├── Screenshot_02.png
└── Screenshot_03.png
└── 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 |
--------------------------------------------------------------------------------
/.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 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.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 | # FilePicker
2 | File and folder picker dialog
3 |
4 | ## Gradle:
5 |
6 | dependencies {
7 | compile 'com.github.isabsent:filepicker:1.1.01'
8 | }
9 |
10 | ## Maven:
11 |
12 |
13 | com.github.isabsent
14 | filepicker
15 | 1.1.01
16 | pom
17 |
18 |
19 | 
20 | 
21 | 
22 |
23 | You can explore **internal memory file system** with any of 12 modes:
24 |
25 | FILE_ONLY_SINGLE_CHOICE
26 | FILE_ONLY_MULTI_CHOICE
27 | FILE_ONLY_DIRECT_CHOICE_IMMEDIATE
28 | FILE_ONLY_DIRECT_CHOICE_SELECTION
29 |
30 | FOLDER_ONLY_SINGLE_CHOICE
31 | FOLDER_ONLY_MULTI_CHOICE
32 | FOLDER_ONLY_DIRECT_CHOICE_IMMEDIATE
33 | FOLDER_ONLY_DIRECT_CHOICE_SELECTION
34 |
35 | FILE_OR_FOLDER_SINGLE_CHOICE
36 | FILE_AND_FOLDER_MULTI_CHOICE
37 | FILE_OR_FOLDER_DIRECT_CHOICE_IMMEDIATE
38 | FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION
39 |
40 |
41 | To use this library in your Activity class you have to realize `SimpleFilePickerDialog.InteractionListenerInt` interface if you are defying dialog title as an `int` resource ID:
42 |
43 | @Override
44 | public void showListItemDialog(int titleResId, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag){
45 | SimpleFilePickerDialog.build(folderPath, mode)
46 | .title(titleResId)
47 | .show(this, dialogTag);
48 | }
49 |
50 | or `SimpleFilePickerDialog.InteractionListenerString` interface if you are defying dialog title as a `String`:
51 |
52 | @Override
53 | public void showListItemDialog(String title, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag){
54 | SimpleFilePickerDialog.build(folderPath, mode)
55 | .title(title)
56 | .show(this, dialogTag);
57 | }
58 | or any of two above if you are not specifying a dialog title. A result of selection is available in `onResult` callback:
59 |
60 | @Override
61 | public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
62 | switch (dialogTag) {
63 | case PICK_DIALOG:
64 | if (extras.containsKey(SimpleFilePickerDialog.SELECTED_SINGLE_PATH))
65 | //Do what you want with single selection
66 | else if (extras.containsKey(SimpleFilePickerDialog.SELECTED_PATHS))
67 | //Do what you want with multiple selection
68 | break;
69 | }
70 | return false;
71 | }
72 |
73 | [The example of usage](https://github.com/isabsent/FilePicker/blob/master/app/src/main/java/com/github/isabsent/filepickerdemo/MainActivity.java)
74 |
75 | This library is an extension of [**SimpleDialogFragments**](https://github.com/eltos/SimpleDialogFragments)
76 |
77 | ## License
78 |
79 | Copyright 2018 Lev Popovich (github.com/isabsent)
80 |
81 | Licensed under the Apache License 2.0
82 |
83 | You may only use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software in compliance with the License. For more information visit http://www.apache.org/licenses/LICENSE-2.0
84 | The above copyright notice alongside a copy of the Apache License shall be included in all copies or substantial portions of the Software not only in source code but also in a license listing accessible by the user.
85 |
86 | I would appreciate being notified when you release an application that uses this library. Thanks!
87 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "com.github.isabsent.filepickerdemo"
8 | minSdkVersion 14
9 | targetSdkVersion 22
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 | compile 'com.android.support:appcompat-v7:25.+'
25 | compile 'com.android.support:design:25.+'
26 | compile project(':filepicker')
27 | }
28 |
--------------------------------------------------------------------------------
/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 C:\Users\1\AppData\Local\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/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/isabsent/filepickerdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepickerdemo;
2 |
3 | import android.os.Environment;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Toast;
9 |
10 | import com.github.isabsent.filepicker.SimpleFilePickerDialog;
11 |
12 | import java.util.List;
13 |
14 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_AND_FOLDER_MULTI_CHOICE;
15 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_ONLY_DIRECT_CHOICE_IMMEDIATE;
16 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_ONLY_DIRECT_CHOICE_SELECTION;
17 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_ONLY_MULTI_CHOICE;
18 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_ONLY_SINGLE_CHOICE;
19 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_OR_FOLDER_DIRECT_CHOICE_IMMEDIATE;
20 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION;
21 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_OR_FOLDER_SINGLE_CHOICE;
22 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FOLDER_ONLY_DIRECT_CHOICE_IMMEDIATE;
23 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FOLDER_ONLY_DIRECT_CHOICE_SELECTION;
24 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FOLDER_ONLY_MULTI_CHOICE;
25 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FOLDER_ONLY_SINGLE_CHOICE;
26 |
27 | public class MainActivity extends AppCompatActivity implements
28 | SimpleFilePickerDialog.InteractionListenerString,
29 | SimpleFilePickerDialog.InteractionListenerInt {
30 |
31 | private static final String //If you need to show a few different mode pickers in one activity,
32 | PICK_DIALOG = "PICK_DIALOG"; //you can distinguish them by this tag in onResult callback.
33 |
34 | @Override
35 | public void showListItemDialog(int titleResId, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag){
36 | SimpleFilePickerDialog.build(folderPath, mode)
37 | .title(titleResId)
38 | // .neut("hoch") //Some customization if you need
39 | // .neg("eröffnen")
40 | // .pos("wählen")
41 | // .choiceMin(1);
42 | // .filterable(true, true)
43 | .show(this, dialogTag);
44 | }
45 |
46 | @Override
47 | public void showListItemDialog(String title, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag){
48 | SimpleFilePickerDialog.build(folderPath, mode)
49 | .title(title)
50 | // .neut("hoch") //Some customization if you need
51 | // .neg("eröffnen")
52 | // .pos("wählen")
53 | // .choiceMin(1);
54 | // .filterable(true, true)
55 | .show(this, dialogTag);
56 | }
57 |
58 | @Override
59 | public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
60 | switch (dialogTag) {
61 | case PICK_DIALOG:
62 | if (extras.containsKey(SimpleFilePickerDialog.SELECTED_SINGLE_PATH)) {
63 | String selectedSinglePath = extras.getString(SimpleFilePickerDialog.SELECTED_SINGLE_PATH);
64 | Toast.makeText(this, "Path selected:\n" + selectedSinglePath, Toast.LENGTH_LONG).show();
65 | } else if (extras.containsKey(SimpleFilePickerDialog.SELECTED_PATHS)){
66 | List selectedPaths = extras.getStringArrayList(SimpleFilePickerDialog.SELECTED_PATHS);
67 | showSelectedPathsToast(selectedPaths);
68 | }
69 | break;
70 | // case PICK_DIALOG_OTHER:
71 | // //Do what you want here
72 | // break;
73 | }
74 | return false;
75 | }
76 |
77 | @Override
78 | protected void onCreate(Bundle savedInstanceState) {
79 | super.onCreate(savedInstanceState);
80 | setContentView(R.layout.activity_main);
81 |
82 | final String rootPath = Environment.getExternalStorageDirectory().getAbsolutePath();
83 |
84 | //Button clicks with all available modes as an usage example:
85 |
86 | //File picker modes
87 | findViewById(R.id.file_single).setOnClickListener(new View.OnClickListener() {
88 | @Override
89 | public void onClick(View view) {
90 | showListItemDialog(R.string.dialog_title_pick_file, rootPath, FILE_ONLY_SINGLE_CHOICE, PICK_DIALOG);
91 | }
92 | });
93 |
94 | findViewById(R.id.file_multi).setOnClickListener(new View.OnClickListener() {
95 | @Override
96 | public void onClick(View view) {
97 | showListItemDialog(getString(R.string.dialog_title_pick_files), rootPath, FILE_ONLY_MULTI_CHOICE, PICK_DIALOG);
98 | }
99 | });
100 |
101 | findViewById(R.id.file_direct_immediate).setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View view) {
104 | showListItemDialog(R.string.dialog_title_pick_file, rootPath, FILE_ONLY_DIRECT_CHOICE_IMMEDIATE, PICK_DIALOG);
105 | }
106 | });
107 |
108 | findViewById(R.id.file_direct_postponed).setOnClickListener(new View.OnClickListener() {
109 | @Override
110 | public void onClick(View view) {
111 | showListItemDialog(R.string.dialog_title_pick_file, rootPath, FILE_ONLY_DIRECT_CHOICE_SELECTION, PICK_DIALOG);
112 | }
113 | });
114 |
115 | //Folder picker modes
116 | findViewById(R.id.folder_single).setOnClickListener(new View.OnClickListener() {
117 | @Override
118 | public void onClick(View view) {
119 | showListItemDialog(getString(R.string.dialog_title_pick_folder), rootPath, FOLDER_ONLY_SINGLE_CHOICE, PICK_DIALOG);
120 | }
121 | });
122 |
123 | findViewById(R.id.folder_multi).setOnClickListener(new View.OnClickListener() {
124 | @Override
125 | public void onClick(View view) {
126 | showListItemDialog(R.string.dialog_title_pick_folders, rootPath, FOLDER_ONLY_MULTI_CHOICE, PICK_DIALOG);
127 | }
128 | });
129 |
130 | findViewById(R.id.folder_direct_immediate).setOnClickListener(new View.OnClickListener() {
131 | @Override
132 | public void onClick(View view) {
133 | showListItemDialog(getString(R.string.dialog_title_pick_folder), rootPath, FOLDER_ONLY_DIRECT_CHOICE_IMMEDIATE, PICK_DIALOG);
134 | }
135 | });
136 |
137 | findViewById(R.id.folder_direct_postponed).setOnClickListener(new View.OnClickListener() {
138 | @Override
139 | public void onClick(View view) {
140 | showListItemDialog(getString(R.string.dialog_title_pick_folder), rootPath, FOLDER_ONLY_DIRECT_CHOICE_SELECTION, PICK_DIALOG);
141 | }
142 | });
143 |
144 | //Mixed picker modes
145 | findViewById(R.id.file_or_folder_single).setOnClickListener(new View.OnClickListener() {
146 | @Override
147 | public void onClick(View view) {
148 | showListItemDialog(R.string.dialog_title_pick_file_or_folder, rootPath, FILE_OR_FOLDER_SINGLE_CHOICE, PICK_DIALOG);
149 | }
150 | });
151 |
152 | findViewById(R.id.file_and_folder_multi).setOnClickListener(new View.OnClickListener() {
153 | @Override
154 | public void onClick(View view) {
155 | showListItemDialog(getString(R.string.dialog_title_pick_files_and_folders), rootPath, FILE_AND_FOLDER_MULTI_CHOICE, PICK_DIALOG);
156 | }
157 | });
158 |
159 | findViewById(R.id.file_or_folder_direct_immediate).setOnClickListener(new View.OnClickListener() {
160 | @Override
161 | public void onClick(View view) {
162 | showListItemDialog(R.string.dialog_title_pick_file_or_folder, rootPath, FILE_OR_FOLDER_DIRECT_CHOICE_IMMEDIATE, PICK_DIALOG);
163 | }
164 | });
165 |
166 | findViewById(R.id.file_or_folder_direct_postponed).setOnClickListener(new View.OnClickListener() {
167 | @Override
168 | public void onClick(View view) {
169 | showListItemDialog(R.string.dialog_title_pick_file_or_folder, rootPath, FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION, PICK_DIALOG);
170 | }
171 | });
172 | }
173 |
174 | private void showSelectedPathsToast(List selectedPaths){
175 | if (selectedPaths != null && !selectedPaths.isEmpty()){
176 | String selectedPathsString = "\n";
177 | for (String path : selectedPaths)
178 | selectedPathsString += path + "\n";
179 | Toast.makeText(this, "Paths selected:" + selectedPathsString, Toast.LENGTH_LONG).show();
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/app/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
21 |
22 |
28 |
29 |
35 |
36 |
42 |
43 |
44 |
50 |
56 |
62 |
63 |
64 |
72 |
73 |
79 |
80 |
86 |
87 |
93 |
94 |
95 |
101 |
107 |
113 |
114 |
115 |
123 |
124 |
130 |
136 |
142 |
143 |
144 |
150 |
156 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FilePicker
3 |
4 | Pick folder
5 | Pick folders
6 | Pick file
7 | Pick files
8 | Pick file or folder
9 | Pick files or folders
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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.3'
9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | // maven {//https://stackoverflow.com/a/45397095/753575
21 | // url "https://maven.google.com"
22 | // }
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/filepicker/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/filepicker/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'filepicker'
6 |
7 | publishedGroupId = 'com.github.isabsent'
8 | libraryName = 'FielePicker'
9 | artifact = 'filepicker'
10 |
11 | libraryDescription = 'A file or folder picker dialog'
12 |
13 | siteUrl = 'https://github.com/isabsent/FilePicker'
14 | gitUrl = 'https://github.com/isabsent/FilePicker.git'
15 |
16 |
17 | libraryVersion = '1.1.01'
18 |
19 | developerId = 'isabsent'
20 | developerName = 'Lev Popovich'
21 | developerEmail = 'isabsent@gmail.com'
22 |
23 | licenseName = 'The Apache Software License, Version 2.0'
24 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
25 | allLicenses = ["Apache-2.0"]
26 | }
27 |
28 | android {
29 | compileSdkVersion 25
30 | buildToolsVersion "25.0.3"
31 |
32 | defaultConfig {
33 | minSdkVersion 14
34 | targetSdkVersion 22
35 | versionCode 1
36 | versionName "1.1.01"
37 |
38 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
39 |
40 | }
41 | buildTypes {
42 | release {
43 | minifyEnabled false
44 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
45 | }
46 | }
47 | }
48 |
49 | dependencies {
50 | compile fileTree(dir: 'libs', include: ['*.jar'])
51 | compile 'com.android.support:appcompat-v7:25.3.1'
52 | compile 'com.github.eltos:simpledialogfragment:2.2'
53 | compile 'commons-io:commons-io:2.6'
54 | }
55 |
56 | //https://android-tools.ru/coding/kak-sozdat-svoyu-sobstvennuyu-biblioteku-android-cherez-jcenter-i-maven-central/
57 | //https://github.com/danielemaddaluno/gradle-jcenter-publish
58 | //https://antoniocappiello.com/2015/11/11/publish-your-library-to-jcenter-in-3-steps/
59 |
60 | //gradlew install
61 | //gradlew bintrayUpload
62 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
63 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
64 |
--------------------------------------------------------------------------------
/filepicker/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 C:\Users\1\AppData\Local\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 |
--------------------------------------------------------------------------------
/filepicker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/SimpleFilePickerDialog.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.os.Environment;
8 | import android.support.annotation.LayoutRes;
9 | import android.support.annotation.NonNull;
10 | import android.support.v4.util.Pair;
11 | import android.support.v7.app.AlertDialog;
12 | import android.text.Spannable;
13 | import android.text.SpannableString;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.Button;
18 |
19 | import com.github.isabsent.filepicker.comparator.FileNameComparator;
20 | import com.github.isabsent.filepicker.entity.Item;
21 | import com.github.isabsent.filepicker.entity.ItemViewHolder;
22 | import com.github.isabsent.filepicker.entity.SimpleFilePickerItem;
23 |
24 | import org.apache.commons.io.FilenameUtils;
25 |
26 | import java.io.File;
27 | import java.io.FileFilter;
28 | import java.util.ArrayList;
29 | import java.util.Arrays;
30 | import java.util.Collections;
31 | import java.util.List;
32 |
33 | import eltos.simpledialogfragment.SimpleDialog;
34 | import eltos.simpledialogfragment.color.SimpleColorDialog;
35 | import eltos.simpledialogfragment.list.AdvancedAdapter;
36 | import eltos.simpledialogfragment.list.CustomListDialog;
37 |
38 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.CompositeMode.FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION;
39 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.ItemMode.ITEM_FILE_FOLDER;
40 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.ItemMode.ITEM_FILE_ONLY;
41 | import static com.github.isabsent.filepicker.SimpleFilePickerDialog.ItemMode.ITEM_FOLDER_ONLY;
42 | import static eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener.BUTTON_NEGATIVE;
43 | import static eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener.BUTTON_NEUTRAL;
44 | import static eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener.BUTTON_POSITIVE;
45 |
46 | public class SimpleFilePickerDialog extends CustomListDialog {
47 | private static final String
48 | TAG = "simpleListDialog",
49 | COMPOSITE_MODE = TAG + "compositeMode",
50 | PATH_ARRAY = TAG + "pathArray",
51 | FOLDER_PATH = TAG + "folderPath",
52 | BUTTONS_ENABLED = TAG + "buttonsEnabled";
53 |
54 | protected final static String DATA_SET = TAG + "data_set";
55 |
56 | /**
57 | * Key for an ArrayList<String> returned by {@link SimpleFilePickerDialog#onResult}
58 | */
59 | public static final String
60 | SELECTED_LABELS = TAG + "selectedLabels",
61 | SELECTED_PATHS = TAG + "selectedPaths";
62 |
63 | /**
64 | * Key for a String returned by {@link SimpleFilePickerDialog#onResult} in single choice mode
65 | */
66 | public static final String
67 | SELECTED_SINGLE_LABEL = TAG + "selectedSingleLabel",
68 | SELECTED_SINGLE_PATH = TAG + "selectedSinglePath",
69 | HIGHLIGHT = TAG + "highlight";
70 |
71 | private ArrayList mData;
72 | private Button openButton, upButton, selectButton;
73 | private CompositeMode mode;
74 | private int choiceMode;
75 | private String folderPath;
76 | private InteractionListenerString mListenerString;
77 | private InteractionListenerInt mListenerInt;
78 |
79 | public static SimpleFilePickerDialog build(String folderPath, CompositeMode mode){
80 | if (folderPath == null)
81 | folderPath = Environment.getExternalStorageDirectory().getAbsolutePath();
82 | if (mode == null)
83 | mode = FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION;
84 |
85 | return new SimpleFilePickerDialog()
86 | .path(folderPath, mode)
87 | .choiceMin(1)
88 | .neut(R.string.button_up)
89 | .neg(R.string.button_open)
90 | .pos(R.string.button_select);
91 | }
92 |
93 | /**
94 | * If set to true, show an input field at the to of the list and allow the user
95 | * to filter the list
96 | *
97 | * @param enabled weather to allow filtering or not
98 | * @param highlight weather to highlight the text filtered
99 | */
100 | public SimpleFilePickerDialog filterable(boolean enabled, boolean highlight) {
101 | setArg(HIGHLIGHT, highlight);
102 | return super.filterable(enabled);
103 | }
104 |
105 | @Override
106 | public void onCreate(Bundle savedInstanceState) {
107 | super.onCreate(savedInstanceState);
108 | if (getArguments() != null) {
109 | folderPath = getArguments().getString(FOLDER_PATH);
110 | mode = CompositeMode.values()[getArguments().getInt(COMPOSITE_MODE)];
111 | choiceMode = getArguments().getInt(CHOICE_MODE);
112 | }
113 | }
114 |
115 | @Override
116 | protected SimpleFilePickerAdapter onCreateAdapter() {
117 | int layout;
118 |
119 | switch (choiceMode) {
120 | case SINGLE_CHOICE:
121 | layout = R.layout.simple_list_item_single_choice;
122 | break;
123 | case MULTI_CHOICE:
124 | layout = R.layout.simple_list_item_multiple_choice;
125 | break;
126 | case NO_CHOICE:
127 | case SINGLE_CHOICE_DIRECT:
128 | default:
129 | layout = R.layout.simple_list_item_1;
130 | break;
131 | }
132 |
133 | if (getArguments() != null) {
134 | mData = getArguments().getParcelableArrayList(DATA_SET);
135 | if (mData == null)
136 | mData = new ArrayList<>(0);
137 | }
138 | return new SimpleFilePickerAdapter(layout, mData, this);
139 | }
140 |
141 | public void onActivityCreated(Bundle savedInstanceState) { //Restore the fragment's state here
142 | super.onActivityCreated(savedInstanceState);
143 | if (savedInstanceState != null) {
144 | folderPath = savedInstanceState.getString(FOLDER_PATH);
145 | mode = CompositeMode.values()[savedInstanceState.getInt(COMPOSITE_MODE)];
146 | buttonsEnabled = savedInstanceState.getBooleanArray(BUTTONS_ENABLED);
147 | }
148 | }
149 |
150 | private boolean[] buttonsEnabled;
151 |
152 | @Override
153 | public void onSaveInstanceState(Bundle outState) { //Save the fragment's state here
154 | super.onSaveInstanceState(outState);
155 | outState.putString(FOLDER_PATH, folderPath);
156 | outState.putInt(COMPOSITE_MODE, mode.ordinal());
157 | buttonsEnabled = new boolean[]{upButton.isEnabled(), openButton.isEnabled(), selectButton.isEnabled()};
158 | outState.putBooleanArray(BUTTONS_ENABLED, buttonsEnabled);
159 | }
160 |
161 | @Override
162 | public void onStart() {
163 | super.onStart();
164 | AlertDialog alertDialog = (AlertDialog) getDialog();
165 | if (alertDialog != null) {
166 | upButton = alertDialog.getButton(Dialog.BUTTON_NEUTRAL);//Up
167 | if (isExternalStorageRoot(folderPath))
168 | upButton.setEnabled(false);
169 |
170 | openButton = alertDialog.getButton(Dialog.BUTTON_NEGATIVE);//Open
171 | openButton.setEnabled(false);
172 |
173 | selectButton = alertDialog.getButton(Dialog.BUTTON_POSITIVE);//Select
174 | if (ITEM_FILE_ONLY.equals(mode.getItemMode()))
175 | selectButton.setEnabled(false);
176 | }
177 | }
178 |
179 | @Override
180 | public void onResume() {
181 | super.onResume();
182 | if (buttonsEnabled != null) {
183 | upButton.setEnabled(buttonsEnabled[0]);
184 | openButton.setEnabled(buttonsEnabled[1]);
185 | selectButton.setEnabled(buttonsEnabled[2]);
186 | }
187 | }
188 |
189 | @Override
190 | protected Bundle onResult(int which) {
191 | Bundle result = super.onResult(which);
192 | if (result != null) {
193 | switch (which) {
194 | case BUTTON_NEUTRAL://Up
195 | showListItemDialog(new File(folderPath).getParent());
196 | return result;
197 | case BUTTON_NEGATIVE://Open
198 | String selectedPath = getPathToOpen(result);
199 | if (selectedPath != null) {
200 | showListItemDialog(selectedPath);
201 | return result;
202 | }
203 | break;
204 | case BUTTON_POSITIVE: //Select
205 | if (isSelectionEmpty(result)) {//Choosing a parent folder
206 | String[] paths = getArguments().getStringArray(PATH_ARRAY);
207 | if (paths != null) {
208 | result.putString(SELECTED_SINGLE_LABEL, FilenameUtils.getName(folderPath));
209 | result.putString(SELECTED_SINGLE_PATH, folderPath);
210 | }
211 | return result;
212 | }
213 | break;
214 | }
215 |
216 | ArrayList positions = result.getIntegerArrayList(SELECTED_POSITIONS);
217 |
218 | if (positions != null && positions.isEmpty() && !result.containsKey(SELECTED_SINGLE_POSITION) && which == BUTTON_NEGATIVE) {//Select
219 | result.putString(SELECTED_SINGLE_PATH, folderPath);
220 | return result;
221 | }
222 |
223 | if (positions != null && !positions.isEmpty() && getArguments() != null) {
224 | String[] paths = getArguments().getStringArray(PATH_ARRAY);
225 | if (paths != null) {
226 | ArrayList labels = new ArrayList<>(positions.size());
227 | ArrayList selectedPaths = new ArrayList<>(positions.size());
228 | for (Integer pos : positions) {
229 | labels.add(mData.get(pos).toString());
230 | selectedPaths.add(paths[pos]);
231 | }
232 | result.putStringArrayList(SELECTED_LABELS, labels);
233 | result.putStringArrayList(SELECTED_PATHS, selectedPaths);
234 | }
235 | }
236 |
237 | if (result.containsKey(SELECTED_SINGLE_POSITION) && getArguments() != null) {
238 | String[] paths = getArguments().getStringArray(PATH_ARRAY);
239 | if (paths != null) {
240 | int selectedPosition = result.getInt(SELECTED_SINGLE_POSITION);
241 | SimpleFilePickerItem simpleFilePickerItem = mData.get(selectedPosition);
242 | String selectedLabel = simpleFilePickerItem.toString();
243 | result.putString(SELECTED_SINGLE_LABEL, selectedLabel);
244 | result.putString(SELECTED_SINGLE_PATH, paths[selectedPosition]);
245 | }
246 | }
247 | }
248 | return result;
249 | }
250 |
251 | private boolean isSelectionEmpty(Bundle result) {
252 | return !result.containsKey(SELECTED_SINGLE_POSITION) && (!result.containsKey(SELECTED_POSITIONS) || result.getIntegerArrayList(SELECTED_POSITIONS).isEmpty());
253 | }
254 |
255 | private String getPathToOpen(Bundle extras){
256 | if (getArguments() != null) {
257 | String[] paths = getArguments().getStringArray(PATH_ARRAY);
258 | if (paths != null) {
259 | int selectedPathPosition = extras.getInt(SimpleColorDialog.SELECTED_SINGLE_POSITION, -1);
260 | if (selectedPathPosition < 0) {
261 | List selectedPathPositions = extras.getIntegerArrayList(SimpleColorDialog.SELECTED_POSITIONS);
262 | if (selectedPathPositions != null && !selectedPathPositions.isEmpty()) {
263 | if (selectedPathPositions.size() == 1)
264 | selectedPathPosition = selectedPathPositions.iterator().next();
265 | else {
266 | for (Integer position : selectedPathPositions)
267 | if (!new File(paths[position]).isFile()) {
268 | if (selectedPathPosition >= 0) {
269 | selectedPathPosition = -1;
270 | break;
271 | } else
272 | selectedPathPosition = position;
273 | }
274 | }
275 | }
276 | }
277 | if (selectedPathPosition >= 0 && !new File(paths[selectedPathPosition]).isFile())
278 | return paths[selectedPathPosition];
279 | }
280 | }
281 | return null;
282 | }
283 |
284 | private void showListItemDialog(String path){
285 | int titleResId = 0;
286 | String title = null;
287 | if (getArguments() != null) {
288 | Object value = getArguments().get(SimpleDialog.TITLE);
289 | if (value instanceof String)
290 | title = (String) value;
291 | else if (value instanceof Integer)
292 | titleResId = (Integer) value;
293 |
294 | if (isPathAcceptable(path)) {
295 | if (title != null && mListenerString != null)
296 | mListenerString.showListItemDialog(title, path, mode, getTag());
297 | else if (titleResId > 0 && mListenerInt != null )
298 | mListenerInt.showListItemDialog(titleResId, path, mode, getTag());
299 | else if (title == null && titleResId == 0)
300 | mListenerString.showListItemDialog(null, path, mode, getTag());
301 | }
302 | }
303 | }
304 |
305 | private static boolean isPathAcceptable(String path){
306 | String rootExternalStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
307 | return path.startsWith(rootExternalStoragePath);
308 | }
309 |
310 | public SimpleFilePickerDialog path(String folderPath, final CompositeMode mode) {
311 | choiceMode(mode.getChoiceMode());
312 | setArg(COMPOSITE_MODE, mode.ordinal());
313 | setArg(FOLDER_PATH, folderPath);
314 | if (getArguments() != null) {
315 | final ItemMode itemMode = mode.getItemMode();
316 | File[] items = new File(folderPath).listFiles(new FileFilter() {
317 |
318 | @Override
319 | public boolean accept(File file) {
320 | return ITEM_FILE_FOLDER.equals(itemMode) || ITEM_FILE_ONLY.equals(itemMode) || file.isDirectory();
321 | }
322 | });
323 | // if (items.length == 0)
324 | emptyText("List is empty!");
325 | // else {
326 | List itemsList = Arrays.asList(items);
327 | Collections.sort(itemsList, new FileNameComparator(true));
328 |
329 | ArrayList list = new ArrayList<>(items.length);
330 | int i = 0;
331 | String[] itemPaths = new String[items.length];
332 | String[] itemNames = new String[items.length];
333 | boolean[] isFiles = new boolean[items.length];
334 | for (File file : itemsList) {
335 | itemPaths[i] = file.getAbsolutePath();
336 | itemNames[i] = file.getName();
337 | isFiles[i] = file.isFile();
338 | list.add(new SimpleFilePickerItem(new Item(itemNames[i], isFiles[i]), itemNames[i].hashCode()));
339 | i++;
340 | }
341 | getArguments().putParcelableArrayList(DATA_SET, list);
342 | getArguments().putStringArray(PATH_ARRAY, itemPaths);
343 | // }
344 | }
345 | return this;
346 | }
347 |
348 | public static class SimpleFilePickerAdapter extends AdvancedAdapter- {
349 | private SimpleFilePickerDialog mDialog;
350 | private int mLayout;
351 | private int choiceMode;
352 | private ItemMode itemMode;
353 | private CompositeMode mode;
354 |
355 | public SimpleFilePickerAdapter(@LayoutRes int layout, ArrayList data, SimpleFilePickerDialog dialog){
356 | mLayout = layout;
357 | mDialog = dialog;
358 | choiceMode = mDialog.getArguments().getInt(CHOICE_MODE);
359 | mode = CompositeMode.values()[mDialog.getArguments().getInt(COMPOSITE_MODE)];
360 | itemMode = mode.getItemMode();
361 |
362 | ArrayList> dataAndIds = new ArrayList<>(data.size());
363 | for (SimpleFilePickerItem simpleFilePickerItem : data)
364 | dataAndIds.add(new Pair<>(simpleFilePickerItem.getItem(), simpleFilePickerItem.getId()));
365 |
366 | setDataAndIds(dataAndIds);
367 | }
368 |
369 | private AdvancedFilter mFilter = new AdvancedFilter(true, true){
370 |
371 | @Override
372 | protected boolean matches(Item object, @NonNull CharSequence constraint) {
373 | return matches(object.toString());
374 | }
375 | };
376 |
377 | @Override
378 | public AdvancedFilter getFilter() {
379 | return mFilter;
380 | }
381 |
382 | @Override
383 | public View getView(final int position, View convertView, ViewGroup parent) {
384 | ItemViewHolder viewHolder;
385 | if (convertView == null) {
386 | convertView = LayoutInflater.from(mDialog.getContext()).inflate(mLayout, parent, false);
387 | viewHolder = new ItemViewHolder(convertView);
388 | convertView.setTag(viewHolder);
389 | } else
390 | viewHolder = (ItemViewHolder) convertView.getTag();
391 |
392 | Item item = getItem(position);
393 | boolean isItemChecked = isItemChecked(position);
394 | Spannable text;
395 | if (mDialog.getArguments().getBoolean(HIGHLIGHT))
396 | text = highlight(item.toString(), mDialog.getContext());
397 | else
398 | text = new SpannableString(item.toString());
399 | viewHolder.bind(item, mode, isItemChecked, text);
400 | convertView.setOnClickListener(new View.OnClickListener() {
401 |
402 | @Override
403 | public void onClick(View view) {
404 | toggleChecked(position);
405 | notifyDataSetChanged();
406 |
407 | List
- checkedItems = getCheckedItems();
408 | List
- checkedFolders = null;
409 | List
- checkedFiles = null;
410 | if (!checkedItems.isEmpty()) {
411 | checkedFolders = new ArrayList<>();
412 | checkedFiles = new ArrayList<>();
413 | for (Item checkedItem : checkedItems){
414 | if (checkedItem.isFile())
415 | checkedFiles.add(checkedItem);
416 | else
417 | checkedFolders.add(checkedItem);
418 | }
419 | }
420 |
421 | boolean isDirectChoiceMode = choiceMode == SINGLE_CHOICE_DIRECT;
422 | boolean isSelectEnabled = false;
423 | if (!isDirectChoiceMode) {
424 | boolean areItemsChecked = checkedItems.size() > 0;
425 | if (ITEM_FILE_ONLY.equals(itemMode)) {
426 | boolean areFoldersChecked = checkedFolders != null && checkedFolders.size() > 0;
427 | isSelectEnabled = !areFoldersChecked && areItemsChecked;
428 | } else {
429 | isSelectEnabled = areItemsChecked;
430 | }
431 | }
432 |
433 | boolean isSingleFolderChecked = checkedFolders != null && checkedFolders.size() == 1;
434 | if (isDirectChoiceMode) {
435 | boolean isSingleItemChecked = checkedItems.size() == 1;
436 | if (CompositeMode.isImmediate(mode)) {
437 | if (isSingleFolderChecked)
438 | mDialog.pressNegativeButton();//Open
439 | else if (isSingleItemChecked)
440 | mDialog.pressPositiveButton();//Select
441 | } else {
442 | if (ITEM_FILE_ONLY.equals(itemMode))
443 | isSelectEnabled = isSingleItemChecked && !isSingleFolderChecked;
444 | else
445 | isSelectEnabled = isSingleItemChecked;
446 | mDialog.setButtons(isSingleFolderChecked, isSelectEnabled);
447 | }
448 | } else {
449 | mDialog.setButtons(isSingleFolderChecked, isSelectEnabled);
450 | }
451 | }
452 | });
453 | return super.getView(position, convertView, parent);
454 | }
455 | }
456 |
457 | protected final void pressNegativeButton(){
458 | // if (acceptsNegativeButtonPress()) {
459 | getDialog().dismiss();
460 | callResultListener(DialogInterface.BUTTON_NEGATIVE, null);
461 | // }
462 | }
463 |
464 | private void setButtons(boolean isOpenEnabled, boolean isSelectEnabled) {
465 | openButton.setEnabled(isOpenEnabled);
466 | selectButton.setEnabled(isSelectEnabled);
467 | }
468 |
469 | private static boolean isExternalStorageRoot(String path) {
470 | String rootExternalStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
471 | return rootExternalStoragePath.equals(path);
472 | }
473 |
474 | @Override
475 | public void onAttach(Context context) {
476 | super.onAttach(context);
477 | if (context instanceof InteractionListenerString)
478 | mListenerString = (InteractionListenerString) context;
479 | if (context instanceof InteractionListenerInt)
480 | mListenerInt = (InteractionListenerInt) context;
481 | if (mListenerString == null && mListenerInt == null)
482 | throw new RuntimeException(context.toString() + " must implement InteractionListenerString or InteractionListenerInt");
483 |
484 | }
485 |
486 | @Override
487 | public void onDetach() {
488 | super.onDetach();
489 | mListenerInt = null;
490 | mListenerString = null;
491 | }
492 |
493 | @Override
494 | protected void onDialogShown() {
495 | super.onDialogShown();
496 | setPositiveButtonEnabled(!ItemMode.ITEM_FILE_ONLY.equals(mode.getItemMode()));
497 | }
498 |
499 | public enum CompositeMode {
500 | FILE_ONLY_SINGLE_CHOICE(ITEM_FILE_ONLY, SINGLE_CHOICE),
501 | FILE_ONLY_MULTI_CHOICE(ITEM_FILE_ONLY, MULTI_CHOICE),
502 | FILE_ONLY_DIRECT_CHOICE_IMMEDIATE(ITEM_FILE_ONLY, SINGLE_CHOICE_DIRECT),
503 | FILE_ONLY_DIRECT_CHOICE_SELECTION(ITEM_FILE_ONLY, SINGLE_CHOICE_DIRECT),
504 |
505 | FOLDER_ONLY_SINGLE_CHOICE(ITEM_FOLDER_ONLY, SINGLE_CHOICE),
506 | FOLDER_ONLY_MULTI_CHOICE(ITEM_FOLDER_ONLY, MULTI_CHOICE),
507 | FOLDER_ONLY_DIRECT_CHOICE_IMMEDIATE(ITEM_FOLDER_ONLY, SINGLE_CHOICE_DIRECT),
508 | FOLDER_ONLY_DIRECT_CHOICE_SELECTION(ITEM_FOLDER_ONLY, SINGLE_CHOICE_DIRECT),
509 |
510 | FILE_OR_FOLDER_SINGLE_CHOICE(ITEM_FILE_FOLDER, SINGLE_CHOICE),
511 | FILE_AND_FOLDER_MULTI_CHOICE(ITEM_FILE_FOLDER, MULTI_CHOICE),
512 | FILE_OR_FOLDER_DIRECT_CHOICE_IMMEDIATE(ITEM_FILE_FOLDER, SINGLE_CHOICE_DIRECT),
513 | FILE_OR_FOLDER_DIRECT_CHOICE_SELECTION(ITEM_FILE_FOLDER, SINGLE_CHOICE_DIRECT);
514 |
515 | private ItemMode itemMode;
516 | private int choiceMode;
517 |
518 | CompositeMode(ItemMode itemMode, int choiceMode) {
519 | this.itemMode = itemMode;
520 | this.choiceMode = choiceMode;
521 | }
522 |
523 | public ItemMode getItemMode() {
524 | return itemMode;
525 | }
526 |
527 | public int getChoiceMode() {
528 | return choiceMode;
529 | }
530 |
531 | public static boolean isImmediate(CompositeMode mode){
532 | return FILE_ONLY_DIRECT_CHOICE_IMMEDIATE.equals(mode)
533 | || FOLDER_ONLY_DIRECT_CHOICE_IMMEDIATE.equals(mode)
534 | || FILE_OR_FOLDER_DIRECT_CHOICE_IMMEDIATE.equals(mode);
535 | }
536 | }
537 |
538 | enum ItemMode{
539 | ITEM_FILE_ONLY, ITEM_FOLDER_ONLY, ITEM_FILE_FOLDER
540 | }
541 |
542 | public interface InteractionListenerString extends OnDialogResultListener {
543 | void showListItemDialog(String title, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag);
544 | }
545 |
546 | public interface InteractionListenerInt extends OnDialogResultListener {
547 | void showListItemDialog(int titleResId, String folderPath, SimpleFilePickerDialog.CompositeMode mode, String dialogTag);
548 | }
549 | }
550 |
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/comparator/FileComparator.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker.comparator;
2 |
3 | import java.io.File;
4 | import java.util.Comparator;
5 |
6 | abstract class FileComparator implements Comparator {
7 | private boolean ascending = true;
8 |
9 | FileComparator(boolean asc){
10 | ascending = asc;
11 | }
12 |
13 | FileComparator(){
14 | this(true);
15 | }
16 |
17 | public int compare(File f1, File f2){
18 | if (f1.isDirectory() && f2.isFile())
19 | return -1;
20 | else if (f1.isFile() && f2.isDirectory())
21 | return 1;
22 | else
23 | return comp((ascending ? f1 : f2), (ascending ? f2 : f1));
24 | }
25 |
26 | protected abstract int comp(File f1, File f2);
27 | }
28 |
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/comparator/FileNameComparator.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker.comparator;
2 |
3 | import java.io.File;
4 | import java.text.Collator;
5 |
6 | public class FileNameComparator extends FileComparator {
7 | public FileNameComparator(boolean asc) {
8 | super(asc);
9 | }
10 |
11 | @Override
12 | protected int comp(File f1, File f2) {
13 | // return f1.getName().toLowerCase().compareTo(f2.getName().toLowerCase());
14 | return compareNatural(f1.getName().toLowerCase(), f2.getName().toLowerCase());
15 | }
16 |
17 | // http://stackoverflow.com/questions/104599/sort-on-a-string-that-may-contain-a-number
18 | // http://www.davekoelle.com/files/AlphanumComparator.java
19 | // http://www.eekboom.com/java/compareNatural/src/com/eekboom/utils/Strings.java
20 | public static int compareNatural(String s, String t) {
21 | return compareNatural(s, t, false, Collator.getInstance());
22 | }
23 |
24 | /**
25 | * @param s first string
26 | * @param t second string
27 | * @param caseSensitive treat characters differing in case only as equal - will be ignored if a collator is given
28 | * @param collator used to compare subwords that aren't numbers - if null, characters will be compared
29 | * individually based on their Unicode value
30 | * @return zero iff
s
and t
are equal,
31 | * a value less than zero iff s
lexicographically precedes t
32 | * and a value larger than zero iff s
lexicographically follows t
33 | */
34 | private static int compareNatural(String s, String t, boolean caseSensitive, Collator collator) {
35 | int sIndex = 0;
36 | int tIndex = 0;
37 |
38 | int sLength = s.length();
39 | int tLength = t.length();
40 |
41 | while(true) {
42 | // both character indices are after a subword (or at zero)
43 |
44 | // Check if one string is at end
45 | if(sIndex == sLength && tIndex == tLength) {
46 | return 0;
47 | }
48 | if(sIndex == sLength) {
49 | return -1;
50 | }
51 | if(tIndex == tLength) {
52 | return 1;
53 | }
54 |
55 | // Compare sub word
56 | char sChar = s.charAt(sIndex);
57 | char tChar = t.charAt(tIndex);
58 |
59 | boolean sCharIsDigit = Character.isDigit(sChar);
60 | boolean tCharIsDigit = Character.isDigit(tChar);
61 |
62 | if(sCharIsDigit && tCharIsDigit) {
63 | // Compare numbers
64 |
65 | // skip leading 0s
66 | int sLeadingZeroCount = 0;
67 | while(sChar == '0') {
68 | ++sLeadingZeroCount;
69 | ++sIndex;
70 | if(sIndex == sLength) {
71 | break;
72 | }
73 | sChar = s.charAt(sIndex);
74 | }
75 | int tLeadingZeroCount = 0;
76 | while(tChar == '0') {
77 | ++tLeadingZeroCount;
78 | ++tIndex;
79 | if(tIndex == tLength) {
80 | break;
81 | }
82 | tChar = t.charAt(tIndex);
83 | }
84 | boolean sAllZero = sIndex == sLength || !Character.isDigit(sChar);
85 | boolean tAllZero = tIndex == tLength || !Character.isDigit(tChar);
86 | if(sAllZero && tAllZero) {
87 | continue;
88 | }
89 | if(sAllZero && !tAllZero) {
90 | return -1;
91 | }
92 | if(tAllZero) {
93 | return 1;
94 | }
95 |
96 | int diff = 0;
97 | do {
98 | if(diff == 0) {
99 | diff = sChar - tChar;
100 | }
101 | ++sIndex;
102 | ++tIndex;
103 | if(sIndex == sLength && tIndex == tLength) {
104 | return diff != 0 ? diff : sLeadingZeroCount - tLeadingZeroCount;
105 | }
106 | if(sIndex == sLength) {
107 | if(diff == 0) {
108 | return -1;
109 | }
110 | return Character.isDigit(t.charAt(tIndex)) ? -1 : diff;
111 | }
112 | if(tIndex == tLength) {
113 | if(diff == 0) {
114 | return 1;
115 | }
116 | return Character.isDigit(s.charAt(sIndex)) ? 1 : diff;
117 | }
118 | sChar = s.charAt(sIndex);
119 | tChar = t.charAt(tIndex);
120 | sCharIsDigit = Character.isDigit(sChar);
121 | tCharIsDigit = Character.isDigit(tChar);
122 | if(!sCharIsDigit && !tCharIsDigit) {
123 | // both number sub words have the same length
124 | if(diff != 0) {
125 | return diff;
126 | }
127 | break;
128 | }
129 | if(!sCharIsDigit) {
130 | return -1;
131 | }
132 | if(!tCharIsDigit) {
133 | return 1;
134 | }
135 | } while(true);
136 | }
137 | else {
138 | // Compare words
139 | if(collator != null) {
140 | // To use the collator the whole subwords have to be compared - character-by-character comparision
141 | // is not possible. So find the two subwords first
142 | int aw = sIndex;
143 | int bw = tIndex;
144 | do {
145 | ++sIndex;
146 | } while(sIndex < sLength && !Character.isDigit(s.charAt(sIndex)));
147 | do {
148 | ++tIndex;
149 | } while(tIndex < tLength && !Character.isDigit(t.charAt(tIndex)));
150 |
151 | String as = s.substring(aw, sIndex);
152 | String bs = t.substring(bw, tIndex);
153 | int subwordResult = collator.compare(as, bs);
154 | if(subwordResult != 0) {
155 | return subwordResult;
156 | }
157 | }
158 | else {
159 | // No collator specified. All characters should be ascii only. Compare character-by-character.
160 | do {
161 | if(sChar != tChar) {
162 | if(caseSensitive) {
163 | return sChar - tChar;
164 | }
165 | sChar = Character.toUpperCase(sChar);
166 | tChar = Character.toUpperCase(tChar);
167 | if(sChar != tChar) {
168 | sChar = Character.toLowerCase(sChar);
169 | tChar = Character.toLowerCase(tChar);
170 | if(sChar != tChar) {
171 | return sChar - tChar;
172 | }
173 | }
174 | }
175 | ++sIndex;
176 | ++tIndex;
177 | if(sIndex == sLength && tIndex == tLength) {
178 | return 0;
179 | }
180 | if(sIndex == sLength) {
181 | return -1;
182 | }
183 | if(tIndex == tLength) {
184 | return 1;
185 | }
186 | sChar = s.charAt(sIndex);
187 | tChar = t.charAt(tIndex);
188 | sCharIsDigit = Character.isDigit(sChar);
189 | tCharIsDigit = Character.isDigit(tChar);
190 | } while(!sCharIsDigit && !tCharIsDigit);
191 | }
192 | }
193 | }
194 | }
195 | }
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/entity/Item.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker.entity;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | public class Item implements Parcelable {
7 | private String label;
8 | private boolean isFile;
9 |
10 | public Item(String path, boolean isFile) {
11 | this.label = path;
12 | this.isFile = isFile;
13 | }
14 |
15 | public String getLabel() {
16 | return label;
17 | }
18 |
19 | public void setLabel(String label) {
20 | this.label = label;
21 | }
22 |
23 | public boolean isFile() {
24 | return isFile;
25 | }
26 |
27 | public void setFile(boolean file) {
28 | isFile = file;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return label;
34 | }
35 |
36 | @Override
37 | public int describeContents() {
38 | return 0;
39 | }
40 |
41 | @Override
42 | public void writeToParcel(Parcel dest, int flags) {
43 | dest.writeString(label);
44 | dest.writeByte(isFile ? (byte) 1 : (byte) 0);
45 | }
46 |
47 | protected Item(Parcel in) {
48 | label = in.readString();
49 | isFile = in.readByte() != 0;
50 | }
51 |
52 | public static final Creator- CREATOR = new Creator
- () {
53 | @Override
54 | public Item createFromParcel(Parcel source) {
55 | return new Item(source);
56 | }
57 |
58 | @Override
59 | public Item[] newArray(int size) {
60 | return new Item[size];
61 | }
62 | };
63 | }
64 |
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/entity/ItemViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker.entity;
2 |
3 | import android.graphics.Color;
4 | import android.text.Spannable;
5 | import android.view.View;
6 | import android.widget.Checkable;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import com.github.isabsent.filepicker.R;
11 | import com.github.isabsent.filepicker.SimpleFilePickerDialog;
12 |
13 | import static eltos.simpledialogfragment.list.CustomListDialog.MULTI_CHOICE;
14 | import static eltos.simpledialogfragment.list.CustomListDialog.SINGLE_CHOICE;
15 |
16 | public class ItemViewHolder {
17 | private View itemView;
18 | private TextView textView;
19 | private ImageView imageView;
20 |
21 | public ItemViewHolder(View itemView) {
22 | this.itemView = itemView;
23 | textView = (TextView) itemView.findViewById(R.id.text1);
24 | imageView = (ImageView) itemView.findViewById(R.id.icon);
25 | }
26 |
27 | public void bind(Item item, SimpleFilePickerDialog.CompositeMode mode, boolean isItemChecked, Spannable text) {
28 | textView.setText(text);
29 | imageView.setImageResource(item.isFile() ? R.mipmap.ic_insert_drive_file_black_24dp : R.mipmap.ic_folder_black_24dp);
30 |
31 | int choiceMode = mode.getChoiceMode();
32 | if (choiceMode == SINGLE_CHOICE || choiceMode == MULTI_CHOICE)
33 | ((Checkable) textView).setChecked(isItemChecked);
34 | else if (!SimpleFilePickerDialog.CompositeMode.isImmediate(mode))
35 | itemView.setBackgroundColor(isItemChecked ? Color.LTGRAY : Color.TRANSPARENT);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/filepicker/src/main/java/com/github/isabsent/filepicker/entity/SimpleFilePickerItem.java:
--------------------------------------------------------------------------------
1 | package com.github.isabsent.filepicker.entity;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.widget.ListView;
6 |
7 | public class SimpleFilePickerItem implements Parcelable {
8 | private long id;
9 | private Item item;
10 |
11 | @Override
12 | public String toString() {
13 | return item.toString();
14 | }
15 |
16 | public SimpleFilePickerItem(Item item){
17 | this(item, ListView.INVALID_ROW_ID);
18 | }
19 |
20 | public SimpleFilePickerItem(Item item, long id){
21 | this.id = id;
22 | this.item = item;
23 | }
24 |
25 | private SimpleFilePickerItem(Parcel in) {
26 | id = in.readLong();
27 | item = in.readParcelable(Item.class.getClassLoader());
28 | }
29 | @Override
30 | public void writeToParcel(Parcel dest, int flags) {
31 | dest.writeLong(id);
32 | dest.writeParcelable(item, flags);
33 | }
34 |
35 | public static final Creator CREATOR = new Creator() {
36 | @Override
37 | public SimpleFilePickerItem createFromParcel(Parcel in) {
38 | return new SimpleFilePickerItem(in);
39 | }
40 |
41 | @Override
42 | public SimpleFilePickerItem[] newArray(int size) {
43 | return new SimpleFilePickerItem[size];
44 | }
45 | };
46 | @Override
47 | public int describeContents() {
48 | return 0;
49 | }
50 |
51 |
52 | public void setId(long id) {
53 | this.id = id;
54 | }
55 |
56 | public long getId() {
57 | return id;
58 | }
59 |
60 | public Item getItem() {
61 | return item;
62 | }
63 |
64 | public void setItem(Item item) {
65 | this.item = item;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout-v17/simple_list_item_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
26 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout-v17/simple_list_item_multiple_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
29 |
30 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout-v17/simple_list_item_single_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
29 |
30 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout/simple_list_item_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
26 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout/simple_list_item_multiple_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
29 |
30 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/layout/simple_list_item_single_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
29 |
30 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-hdpi/ic_folder_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-hdpi/ic_folder_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-hdpi/ic_insert_drive_file_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-hdpi/ic_insert_drive_file_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-mdpi/ic_folder_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-mdpi/ic_folder_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-mdpi/ic_insert_drive_file_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-mdpi/ic_insert_drive_file_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xhdpi/ic_folder_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xhdpi/ic_folder_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xhdpi/ic_insert_drive_file_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xhdpi/ic_insert_drive_file_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xxhdpi/ic_folder_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xxhdpi/ic_folder_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xxhdpi/ic_insert_drive_file_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xxhdpi/ic_insert_drive_file_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xxxhdpi/ic_folder_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xxxhdpi/ic_folder_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/mipmap-xxxhdpi/ic_insert_drive_file_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/filepicker/src/main/res/mipmap-xxxhdpi/ic_insert_drive_file_black_24dp.png
--------------------------------------------------------------------------------
/filepicker/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
- #de000000
8 |
9 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FilePicker
3 |
4 | Open
5 | Select
6 | Up
7 |
8 |
--------------------------------------------------------------------------------
/filepicker/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/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/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 11 11:14:45 GMT+07:00 2018
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 |
--------------------------------------------------------------------------------
/screenshot/Screenshot_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/screenshot/Screenshot_01.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/screenshot/Screenshot_02.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/isabsent/FilePicker/ae7f902e0561f43b8da58dae36099a69c72e0038/screenshot/Screenshot_03.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':filepicker'
2 |
--------------------------------------------------------------------------------