├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE
├── README.md
├── build.gradle
├── filebrowser
├── .gitignore
├── build.gradle
├── libs
│ └── commons-io-2.6.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── aditya
│ │ └── filebrowser
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── aditya
│ │ │ └── filebrowser
│ │ │ ├── Constants.java
│ │ │ ├── FileBrowser.java
│ │ │ ├── FileBrowserWithCustomHandler.java
│ │ │ ├── FileChooser.java
│ │ │ ├── FolderChooser.java
│ │ │ ├── NavigationHelper.java
│ │ │ ├── ToolbarActionMode.java
│ │ │ ├── adapters
│ │ │ ├── CustomAdapter.java
│ │ │ └── CustomAdapterItemClickListener.java
│ │ │ ├── fileoperations
│ │ │ ├── FileIO.java
│ │ │ ├── FileNavigator.java
│ │ │ ├── FileResolution.java
│ │ │ ├── GetRemovableDevice.java
│ │ │ └── Operations.java
│ │ │ ├── interfaces
│ │ │ ├── IContextSwitcher.java
│ │ │ ├── IFuncPtr.java
│ │ │ └── ITrackSelection.java
│ │ │ ├── listeners
│ │ │ ├── OnFileChangedListener.java
│ │ │ ├── SearchViewListener.java
│ │ │ └── TabChangeListener.java
│ │ │ ├── models
│ │ │ └── FileItem.java
│ │ │ └── utils
│ │ │ ├── AssortedUtils.java
│ │ │ ├── Permissions.java
│ │ │ ├── UIUpdateHelper.java
│ │ │ └── UIUtils.java
│ └── res
│ │ ├── drawable
│ │ ├── ic_android_black_24dp.xml
│ │ ├── ic_audiotrack_black_24dp.xml
│ │ ├── ic_check_black_24dp.xml
│ │ ├── ic_close_black_24dp.xml
│ │ ├── ic_content_copy_black_24dp.xml
│ │ ├── ic_content_cut_black_24dp.xml
│ │ ├── ic_content_paste_black_24dp.xml
│ │ ├── ic_create_black_24dp.xml
│ │ ├── ic_create_new_folder_black_24dp.xml
│ │ ├── ic_crop_original_black_24dp.xml
│ │ ├── ic_done_black_24dp.xml
│ │ ├── ic_folder_open_black_24dp.xml
│ │ ├── ic_format_line_spacing_black_24dp.xml
│ │ ├── ic_info_outline_black_24dp.xml
│ │ ├── ic_insert_drive_file_black_24dp.xml
│ │ ├── ic_keyboard_backspace_black_24dp.xml
│ │ ├── ic_layers_black_24dp.xml
│ │ ├── ic_loop_black_24dp.xml
│ │ ├── ic_low_priority_black_24dp.xml
│ │ ├── ic_more_vert_black_24dp.xml
│ │ ├── ic_new_releases_black_24dp.xml
│ │ ├── ic_ondemand_video_black_24dp.xml
│ │ ├── ic_photo_black_24dp.xml
│ │ ├── ic_remove_circle_outline_black_24dp.xml
│ │ ├── ic_sd_storage_black_24dp.xml
│ │ ├── ic_search_black_24dp.xml
│ │ ├── ic_security_black_24dp.xml
│ │ ├── ic_share_black_24dp.xml
│ │ ├── ic_storage_black_24dp.xml
│ │ ├── ic_swap_vert_black_24dp.xml
│ │ ├── ic_tune_black_24dp.xml
│ │ └── nav_selector.xml
│ │ ├── layout
│ │ ├── dialog_with_text.xml
│ │ ├── file_item.xml
│ │ ├── filebrowser_activity_main.xml
│ │ ├── filebrowser_toolbar.xml
│ │ └── filter_options.xml
│ │ ├── menu
│ │ ├── toolbar_default_menu.xml
│ │ ├── toolbar_default_menu_filechooser.xml
│ │ ├── toolbar_multiselect_menu.xml
│ │ └── toolbar_multiselect_menu_filechooser.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-de
│ │ └── strings.xml
│ │ ├── values-es
│ │ └── strings.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── bottom_nav_items.xml
│ │ ├── bottom_nav_items_folderchooser.xml
│ │ ├── bottom_nav_items_multiselect.xml
│ │ ├── bottom_nav_items_multiselect_filechooser.xml
│ │ ├── path_change_menu.xml
│ │ ├── provider_paths.xml
│ │ └── searchable.xml
│ └── test
│ └── java
│ └── com
│ └── aditya
│ └── filebrowser
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
└── Test
│ ├── .gitignore
│ ├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── aditya
│ │ │ └── test
│ │ │ └── ApplicationTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── aditya
│ │ │ │ └── test
│ │ │ │ ├── FileSelectedBroadCastReceiver.java
│ │ │ │ └── MainActivity.java
│ │ └── res
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ ├── colors.xml
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── aditya
│ │ └── test
│ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
└── 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 | .idea
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/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 adityak368
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FileBrowser
2 |
3 | A FileBrowser / FileChooser for Android that you can integrate to your app to browse/select files from internal/external storage.
4 |
5 | [](https://android-arsenal.com/details/1/5636)
6 |
7 | # Using Maven
8 | ``` xml
9 |
10 | com.adityak
11 | browsemyfiles
12 | 1.9
13 | pom
14 |
15 | ```
16 | # Or Using Gradle
17 | ```
18 | compile 'com.adityak:browsemyfiles:1.9'
19 | ```
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | It easily integrates with your app's color scheme. You can change the color scheme using the following in your styles.xml
28 |
29 | ``` xml
30 | - @color/colorPrimary
31 | - @color/colorPrimaryDark
32 | - @color/colorAccent
33 | - @color/actionModeToolbar
34 | ```
35 |
36 | There are 3 main classes to use the library.
37 |
38 | 1. FileBrowser - Used to just Browse files in storage (has all file IO features)
39 | 2. FileChooser - Used to select single/multiple files in storage (has some IO features)
40 | 3. FolderChooser - Used to select single/multiple folders in storage (has some IO features)
41 | 4. FileBrowserWithCustomHandler - Used to run custom code when files are selected (has all IO features)
42 |
43 | # 1. FileBrowser
44 | Use following Intent to start the FileBrowser
45 |
46 | ``` java
47 | Intent i4 = new Intent(getApplicationContext(), FileBrowser.class);
48 | startActivity(i4);
49 | ```
50 |
51 | # 2. FileChooser
52 |
53 | Use following Intent to start the FileChooser
54 | - For Single Selection
55 |
56 | ``` java
57 | Intent i2 = new Intent(getApplicationContext(), FileChooser.class);
58 | i2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());
59 | startActivityForResult(i2, PICK_FILE_REQUEST);
60 | ```
61 |
62 |
63 | To get the selected file, In your calling activity's onActivityResult method, use the following
64 |
65 | ```java
66 |
67 | if (requestCode == PICK_FILE_REQUEST && data!=null) {
68 | if (resultCode == RESULT_OK) {
69 | Uri file = data.getData();
70 | }
71 | }
72 |
73 | ```
74 |
75 |
76 | - For Multiple Selection
77 | ``` java
78 | Intent i2 = new Intent(getApplicationContext(), FileChooser.class);
79 | i2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.MULTIPLE_SELECTION.ordinal());
80 | startActivityForResult(i2, PICK_FILE_REQUEST);
81 | ```
82 |
83 | To get the selected file, In your calling activity's onActivityResult method, use the following
84 |
85 | ```java
86 |
87 | if (requestCode == PICK_FILE_REQUEST && data!=null) {
88 | if (resultCode == RESULT_OK) {
89 | ArrayList selectedFiles = data.getParcelableArrayListExtra(Constants.SELECTED_ITEMS);
90 | }
91 | }
92 |
93 | ```
94 |
95 | # 3. FolderChooser
96 |
97 | Use following Intent to start the FolderChooser
98 | - For Single Selection
99 |
100 | ``` java
101 | Intent i2 = new Intent(getApplicationContext(), FolderChooser.class);
102 | i2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());
103 | startActivityForResult(i2, PICK_FOLDER_REQUEST);
104 | ```
105 |
106 | To get the selected folder, In your calling activity's onActivityResult method, use the following
107 |
108 | ```java
109 |
110 | if (requestCode == PICK_FOLDER_REQUEST && data!=null) {
111 | if (resultCode == RESULT_OK) {
112 | Uri file = data.getData();
113 | }
114 | }
115 |
116 | ```
117 |
118 | - For Multiple Selection
119 | ``` java
120 | Intent i2 = new Intent(getApplicationContext(), FolderChooser.class);
121 | i2.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.MULTIPLE_SELECTION.ordinal());
122 | startActivityForResult(i2, PICK_FOLDER_REQUEST);
123 | ```
124 |
125 | To get the selected file, In your calling activity's onActivityResult method, use the following
126 |
127 | ```java
128 |
129 | if (requestCode == PICK_FOLDER_REQUEST && data!=null) {
130 | if (resultCode == RESULT_OK) {
131 | ArrayList selectedFiles = data.getParcelableArrayListExtra(Constants.SELECTED_ITEMS);
132 | }
133 | }
134 |
135 | ```
136 |
137 | # 4. FileBrowserWithCustomHandler
138 |
139 | Register a Broadcast receiver and handle the onReceive method like below
140 |
141 | ```java
142 |
143 | public class FileSelectedBroadCastReceiver extends BroadcastReceiver {
144 | @Override
145 | public void onReceive(Context context, Intent intent) {
146 | Uri filePath = intent.getParcelableExtra(com.aditya.filebrowser.Constants.BROADCAST_SELECTED_FILE);
147 | }
148 | }
149 |
150 | ```
151 |
152 | Register the receiver like the following snippet
153 |
154 | ``` xml
155 |
156 |
159 |
160 |
161 |
162 |
163 |
164 | ```
165 |
166 | If you also need some other parameters to be sent with the broadcast use the following when creating the activity
167 | ``` java
168 |
169 | Intent i = new Intent(mContext, FileBrowserWithCustomHandler.class);
170 | Bundle ib = new Bundle();
171 | //add extras
172 | i.putExtras(ib);
173 | startActivity(i);
174 |
175 | ```
176 | and in the broadcast receiver use the following to get the extras
177 |
178 | ``` java
179 | Bundle b = intent.getExtras()
180 | ```
181 |
182 |
183 | ### To load a particular directory instead of the normal root directory
184 | Add the following in the intent
185 | ``` java
186 | Intent i = new Intent(this, FileBrowser.class); //works for all 3 main classes (i.e FileBrowser, FileChooser, FileBrowserWithCustomHandler)
187 | i.putExtra(Constants.INITIAL_DIRECTORY, new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Movies").getAbsolutePath());
188 | ```
189 |
190 |
191 | ### To list only the files with a particular extension
192 | Add the following in the intent
193 | ``` java
194 | Intent i = new Intent(this, FileBrowser.class); //works for all 3 main classes (i.e FileBrowser, FileChooser, FileBrowserWithCustomHandler)
195 | i.putExtra(Constants.ALLOWED_FILE_EXTENSIONS, "mkv;mp4;avi");
196 | ```
197 |
198 | Use file extensions delimited by semicolon
199 |
200 | ### Known Issues
201 | Currently folder size is calculated using Java's Api getTotalSpace() which gives the size of the partition of the path which may not always give the desired result.
202 | To get the exact size, properties can be used which gives the exact result. If Exact size is to be known, then UI would lag as it would take some time to calculate size - Fix for this is postponed
203 |
204 |
205 | If you have any questions/queries/Bugs/Hugs please mail @
206 | adityak368@gmail.com
207 |
--------------------------------------------------------------------------------
/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 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.4.1'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | google()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/filebrowser/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/filebrowser/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | PUBLISH_GROUP_ID = 'com.adityak'
5 | PUBLISH_ARTIFACT_ID = 'browsemyfiles'
6 | PUBLISH_VERSION = '1.9'
7 | }
8 |
9 | android {
10 | compileSdkVersion 27
11 | buildToolsVersion "28.0.3"
12 |
13 | defaultConfig {
14 | //applicationId "com.aditya.filebrowser"
15 | minSdkVersion 17
16 | targetSdkVersion 27
17 | versionCode 11
18 | versionName "1.9"
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(include: ['*.jar'], dir: 'libs')
30 | testImplementation 'junit:junit:4.12'
31 | implementation 'com.android.support:design:27.1.1'
32 | implementation 'com.android.support:appcompat-v7:27.1.1'
33 | implementation 'com.android.support:recyclerview-v7:27.1.1'
34 | implementation 'com.beardedhen:androidbootstrap:2.3.1'
35 | implementation 'com.roughike:bottom-bar:2.3.1'
36 | implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.20'
37 | implementation files('libs/commons-io-2.6.jar')
38 | }
39 |
40 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
--------------------------------------------------------------------------------
/filebrowser/libs/commons-io-2.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/libs/commons-io-2.6.jar
--------------------------------------------------------------------------------
/filebrowser/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\Aditya\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 |
--------------------------------------------------------------------------------
/filebrowser/src/androidTest/java/com/aditya/filebrowser/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/filebrowser/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
15 |
19 |
20 |
21 |
24 |
28 |
29 |
30 |
33 |
36 |
37 |
38 |
41 |
44 |
45 |
46 |
47 |
48 |
53 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/Constants.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import android.Manifest;
4 | import android.os.Environment;
5 |
6 | import com.aditya.filebrowser.fileoperations.GetRemovableDevice;
7 |
8 | import java.io.File;
9 | import java.util.List;
10 |
11 | /**
12 | * Created by adik on 10/18/2015.
13 | */
14 | public class Constants {
15 |
16 | public enum FILTER_OPTIONS {
17 | FILES,
18 | FOLDER,
19 | ALL
20 | }
21 |
22 | public enum SORT_OPTIONS {
23 | NAME,
24 | SIZE,
25 | LAST_MODIFIED
26 | }
27 |
28 | public enum APP_MODE {
29 | FILE_BROWSER,
30 | FILE_CHOOSER,
31 | FOLDER_CHOOSER,
32 | }
33 |
34 | public enum CHOICE_MODE {
35 | SINGLE_CHOICE,
36 | MULTI_CHOICE
37 | }
38 |
39 | public enum SELECTION_MODES {
40 | SINGLE_SELECTION,
41 | MULTIPLE_SELECTION
42 | }
43 |
44 | public static final String APP_PREMISSION_KEY = "APP_PERMISSIONS";
45 | public static final String FILE_SELECTED_BROADCAST = "com.adityak.filebrowser.FILE_SELECTED_BROADCAST";
46 | public static final String INITIAL_DIRECTORY = "INITIAL_DIRECTORY";
47 | public static final String ALLOWED_FILE_EXTENSIONS = "ALLOWED_FILE_EXTENSIONS";
48 | public static final String BROADCAST_SELECTED_FILE = "BROADCAST_SELECTED_FILE";
49 | public static final String SELECTION_MODE = "SELECTION_MODE";
50 | public static final String SELECTED_ITEMS = "SELECTED_ITEMS";
51 | public static final String [] APP_PREMISSIONS = {
52 | Manifest.permission.WRITE_EXTERNAL_STORAGE};
53 | public static final String INTERNALSTORAGE = "Internal Storage";
54 | public static final String EXTERNALSTORAGE = "External Storage";
55 | public static File internalStorageRoot = Environment.getExternalStorageDirectory();
56 | public static File externalStorageRoot;
57 | public static final String SHOW_FOLDER_SIZE = "false";
58 | public static final String DATE_FORMAT = "dd.MM.yyyy HH:mm:ss";
59 |
60 | static {
61 |
62 | try {
63 | List infos = GetRemovableDevice.getStorageList();
64 | boolean isExternalDirectoryInitialized = false;
65 | for(int i=0; i0)
69 | externalStorageRoot = detectedDirectory;
70 | else
71 | externalStorageRoot = new File("/");
72 | isExternalDirectoryInitialized = true;
73 | break;
74 | }
75 | }
76 | if (!isExternalDirectoryInitialized)
77 | externalStorageRoot = new File("/");
78 | } catch (Exception e) {
79 | e.printStackTrace();
80 | externalStorageRoot = new File("/");
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/FileBrowserWithCustomHandler.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | /**
4 | * Created by Aditya on 4/15/2017.
5 | */
6 |
7 | import android.app.Activity;
8 | import android.app.SearchManager;
9 | import android.content.Context;
10 | import android.content.Intent;
11 | import android.net.Uri;
12 | import android.os.Bundle;
13 | import android.os.Handler;
14 | import android.os.Looper;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.support.v7.view.ActionMode;
17 | import android.support.v7.widget.LinearLayoutManager;
18 | import android.support.v7.widget.SearchView;
19 | import android.support.v7.widget.Toolbar;
20 | import android.view.Menu;
21 | import android.view.MenuItem;
22 | import android.view.View;
23 | import android.widget.TextView;
24 | import android.widget.Toast;
25 |
26 | import com.aditya.filebrowser.adapters.CustomAdapter;
27 | import com.aditya.filebrowser.adapters.CustomAdapterItemClickListener;
28 | import com.aditya.filebrowser.fileoperations.FileIO;
29 | import com.aditya.filebrowser.fileoperations.Operations;
30 | import com.aditya.filebrowser.interfaces.IContextSwitcher;
31 | import com.aditya.filebrowser.interfaces.IFuncPtr;
32 | import com.aditya.filebrowser.listeners.OnFileChangedListener;
33 | import com.aditya.filebrowser.listeners.SearchViewListener;
34 | import com.aditya.filebrowser.listeners.TabChangeListener;
35 | import com.aditya.filebrowser.models.FileItem;
36 | import com.aditya.filebrowser.utils.AssortedUtils;
37 | import com.aditya.filebrowser.utils.Permissions;
38 | import com.aditya.filebrowser.utils.UIUtils;
39 | import com.roughike.bottombar.BottomBar;
40 | import com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener;
41 | import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
42 |
43 | import org.apache.commons.io.FileUtils;
44 |
45 | import java.io.File;
46 | import java.util.ArrayList;
47 | import java.util.Arrays;
48 | import java.util.HashSet;
49 | import java.util.List;
50 | import java.util.Set;
51 |
52 |
53 | public class FileBrowserWithCustomHandler extends AppCompatActivity implements OnFileChangedListener, IContextSwitcher {
54 |
55 | private Context mContext;
56 |
57 | private CustomAdapter mAdapter;
58 | private FastScrollRecyclerView.LayoutManager mLayoutManager;
59 | private FastScrollRecyclerView mFilesListView;
60 |
61 | private BottomBar mBottomView;
62 | private BottomBar mTopStorageView;
63 | private TabChangeListener mTabChangeListener;
64 |
65 | private TextView mCurrentPath;
66 | private NavigationHelper mNavigationHelper;
67 | private Operations op;
68 | private FileIO io;
69 |
70 | //Action Mode for filebrowser_toolbar
71 | private static ActionMode mActionMode;
72 | private static final int APP_PERMISSION_REQUEST = 0;
73 |
74 | private SearchView mSearchView;
75 | private MenuItem mSearchMenuItem;
76 | private SearchViewListener mSearchViewListener;
77 | private List mFileList = new ArrayList<>();
78 |
79 | @Override
80 | protected void onCreate(Bundle savedInstanceState) {
81 | super.onCreate(savedInstanceState);
82 |
83 | mContext = this;
84 |
85 | // Get File Storage Permission
86 | Intent in = new Intent(this, Permissions.class);
87 | Bundle bundle = new Bundle();
88 | bundle.putStringArray(Constants.APP_PREMISSION_KEY, Constants.APP_PREMISSIONS);
89 | in.putExtras(bundle);
90 | startActivityForResult(in, APP_PERMISSION_REQUEST);
91 |
92 | // Initialize Stuff
93 | mNavigationHelper = new NavigationHelper(mContext);
94 | mNavigationHelper.setmChangeDirectoryListener(this);
95 | io = new FileIO(mNavigationHelper, new Handler(Looper.getMainLooper()), mContext);
96 | op = Operations.getInstance(mContext);
97 |
98 | //set file filter (i.e display files with the given extension)
99 | String filterFilesWithExtension = getIntent().getStringExtra(Constants.ALLOWED_FILE_EXTENSIONS);
100 | if(filterFilesWithExtension != null && !filterFilesWithExtension.isEmpty()) {
101 | Set allowedFileExtensions = new HashSet(Arrays.asList(filterFilesWithExtension.split(";")));
102 | mNavigationHelper.setAllowedFileExtensionFilter(allowedFileExtensions);
103 | }
104 |
105 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
106 | }
107 |
108 | @Override
109 | public void onBackPressed() {
110 |
111 | if (mAdapter.getChoiceMode() == Constants.CHOICE_MODE.MULTI_CHOICE) {
112 | switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
113 | return;
114 | }
115 |
116 | if (!mNavigationHelper.navigateBack()) {
117 | super.onBackPressed();
118 | }
119 | }
120 |
121 | @Override
122 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
123 | super.onActivityResult(requestCode, resultCode, data);
124 | if (requestCode == APP_PERMISSION_REQUEST) {
125 | if (resultCode != Activity.RESULT_OK)
126 | Toast.makeText(mContext, mContext.getString(R.string.error_no_permissions), Toast.LENGTH_LONG).show();
127 | loadUi();
128 | }
129 | }
130 |
131 | @Override
132 | public boolean onCreateOptionsMenu(Menu menu) {
133 | // Inflate the menu; this adds items to the action bar if it is present.
134 | getMenuInflater().inflate(R.menu.toolbar_default_menu, menu);
135 | // Get the SearchView and set the searchable configuration
136 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
137 | mSearchMenuItem = menu.findItem(R.id.action_search);
138 | mSearchView = (SearchView)mSearchMenuItem.getActionView();
139 | // Assumes current activity is the searchable activity
140 | mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
141 | //searchView.setSubmitButtonEnabled(true);
142 | mSearchView.setOnQueryTextListener(mSearchViewListener);
143 | return true;
144 | }
145 |
146 | @Override
147 | public boolean onOptionsItemSelected(MenuItem item) {
148 |
149 | if (item.getItemId() == R.id.action_showfoldersizes) {
150 | if (AssortedUtils.GetPrefs(Constants.SHOW_FOLDER_SIZE, mContext).equalsIgnoreCase("true"))
151 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "false", mContext);
152 | else
153 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "true", mContext);
154 | onFileChanged(mNavigationHelper.getCurrentDirectory());
155 | }
156 | else if (item.getItemId() == R.id.action_newfolder) {
157 | UIUtils.showEditTextDialog(this, getString(R.string.new_folder), "", new IFuncPtr(){
158 | @Override
159 | public void execute(final String val) {
160 | io.createDirectory(new File(mNavigationHelper.getCurrentDirectory(),val.trim()));
161 | }
162 | });
163 | }
164 | else if (item.getItemId() == R.id.action_paste) {
165 | if (op.getOperation() == Operations.FILE_OPERATIONS.NONE) {
166 | UIUtils.ShowToast(mContext.getString(R.string.no_operation_error), mContext);
167 | }
168 | if (op.getSelectedFiles() == null) {
169 | UIUtils.ShowToast(mContext.getString(R.string.no_files_paste), mContext);
170 | }
171 | io.pasteFiles(mNavigationHelper.getCurrentDirectory());
172 | }
173 |
174 | return false;
175 |
176 | }
177 |
178 | @Override
179 | public void onFileChanged(File updatedDirectory) {
180 | if(updatedDirectory!=null && updatedDirectory.exists() && updatedDirectory.isDirectory()) {
181 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
182 | mCurrentPath.setText(updatedDirectory.getAbsolutePath());
183 | mAdapter.notifyDataSetChanged();
184 | mTopStorageView.getTabWithId(R.id.menu_internal_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getTotalSpace()));
185 | if (Constants.externalStorageRoot != null)
186 | mTopStorageView.getTabWithId(R.id.menu_external_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getTotalSpace()));
187 | }
188 | }
189 |
190 | private void loadUi() {
191 | setContentView(R.layout.filebrowser_activity_main);
192 | mCurrentPath = (TextView) findViewById(R.id.currentPath);
193 |
194 | mFilesListView = (FastScrollRecyclerView) findViewById(R.id.recycler_view);
195 | mAdapter = new CustomAdapter(mFileList,mContext);
196 | mFilesListView.setAdapter(mAdapter);
197 | mLayoutManager = new LinearLayoutManager(mContext);
198 | mFilesListView.setLayoutManager(mLayoutManager);
199 | final CustomAdapterItemClickListener onItemClickListener = new CustomAdapterItemClickListener(mContext, mFilesListView, new CustomAdapterItemClickListener.OnItemClickListener() {
200 | @Override
201 | public void onItemClick(View view, int position) {
202 | // TODO Handle item click
203 | if (mAdapter.getChoiceMode()== Constants.CHOICE_MODE.SINGLE_CHOICE) {
204 | File f = mAdapter.getItemAt(position).getFile();
205 | if (f.isDirectory()) {
206 | closeSearchView();
207 | mNavigationHelper.changeDirectory(f);
208 | } else {
209 | Uri selectedFileUri = Uri.fromFile(f);
210 | Intent i = new Intent(Constants.FILE_SELECTED_BROADCAST);
211 | i.putExtra(Constants.BROADCAST_SELECTED_FILE, selectedFileUri);
212 | Bundle extras = getIntent().getExtras();
213 | if(extras!=null)
214 | i.putExtras(extras);
215 | sendBroadcast(i);
216 | }
217 | }
218 | }
219 |
220 | @Override
221 | public void onItemLongClick(View view, int position) {
222 | switchMode(Constants.CHOICE_MODE.MULTI_CHOICE);
223 | mAdapter.selectItem(position);
224 | mFilesListView.scrollToPosition(position);
225 | }
226 | });
227 | mFilesListView.addOnItemTouchListener(onItemClickListener);
228 |
229 | mFilesListView.setOnFastScrollStateChangeListener(new OnFastScrollStateChangeListener() {
230 | @Override
231 | public void onFastScrollStart() {
232 | onItemClickListener.setmFastScrolling(true);
233 | }
234 |
235 | @Override
236 | public void onFastScrollStop() {
237 | onItemClickListener.setmFastScrolling(false);
238 | }
239 | });
240 |
241 | mSearchViewListener = new SearchViewListener(mAdapter);
242 |
243 | Toolbar toolbar = findViewById(R.id.filebrowser_tool_bar);
244 | setSupportActionBar(toolbar);
245 |
246 | mBottomView = findViewById(R.id.bottom_navigation);
247 | mTopStorageView = findViewById(R.id.currPath_Nav);
248 |
249 | mTabChangeListener = new TabChangeListener(this, mNavigationHelper, mAdapter, io,this);
250 |
251 | mBottomView.setOnTabSelectListener(mTabChangeListener);
252 | mBottomView.setOnTabReselectListener(mTabChangeListener);
253 |
254 | mTopStorageView.setOnTabSelectListener(mTabChangeListener);
255 | mTopStorageView.setOnTabReselectListener(mTabChangeListener);
256 |
257 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
258 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
259 |
260 | onFileChanged(mNavigationHelper.getCurrentDirectory());
261 |
262 | //switch to initial directory if given
263 | String initialDirectory = getIntent().getStringExtra(Constants.INITIAL_DIRECTORY);
264 | if (initialDirectory != null && !initialDirectory.isEmpty() ) {
265 | File initDir = new File(initialDirectory);
266 | if (initDir.exists())
267 | mNavigationHelper.changeDirectory(initDir);
268 | }
269 | }
270 |
271 | public void switchMode(Constants.CHOICE_MODE mode) {
272 | if(mode == Constants.CHOICE_MODE.SINGLE_CHOICE) {
273 | if(mActionMode != null)
274 | mActionMode.finish();
275 | } else {
276 | if(mActionMode == null) {
277 | closeSearchView();
278 | ToolbarActionMode newToolBar = new ToolbarActionMode(this,this, mAdapter, Constants.APP_MODE.FILE_BROWSER, io);
279 | mActionMode = startSupportActionMode(newToolBar);
280 | mActionMode.setTitle(mContext.getString(R.string.select_multiple));
281 | }
282 | }
283 | }
284 |
285 | public void changeBottomNavMenu(Constants.CHOICE_MODE multiChoice) {
286 | if (multiChoice == Constants.CHOICE_MODE.SINGLE_CHOICE) {
287 | mBottomView.setItems(R.xml.bottom_nav_items);
288 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
289 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
290 | } else {
291 | mBottomView.setItems(R.xml.bottom_nav_items_multiselect);
292 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
293 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
294 | }
295 | }
296 |
297 | @Override
298 | public void setNullToActionMode() {
299 | if (mActionMode != null)
300 | mActionMode = null;
301 | }
302 |
303 | @Override
304 | public void reDrawFileList() {
305 | mFilesListView.setLayoutManager(null);
306 | mFilesListView.setAdapter(mAdapter);
307 | mFilesListView.setLayoutManager(mLayoutManager);
308 | mTabChangeListener.setmAdapter(mAdapter);
309 | mAdapter.notifyDataSetChanged();
310 | }
311 |
312 | private void closeSearchView() {
313 | if (mSearchView.isShown()) {
314 | mSearchView.setQuery("", false);
315 | mSearchMenuItem.collapseActionView();
316 | mSearchView.setIconified(true);
317 | }
318 | }
319 | }
320 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/FileChooser.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import android.app.Activity;
4 | import android.app.SearchManager;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.Uri;
8 | import android.os.Bundle;
9 | import android.os.Handler;
10 | import android.os.Looper;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.view.ActionMode;
13 | import android.support.v7.widget.LinearLayoutManager;
14 | import android.support.v7.widget.SearchView;
15 | import android.support.v7.widget.Toolbar;
16 | import android.view.Menu;
17 | import android.view.MenuItem;
18 | import android.view.View;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import com.aditya.filebrowser.adapters.CustomAdapter;
23 | import com.aditya.filebrowser.adapters.CustomAdapterItemClickListener;
24 | import com.aditya.filebrowser.fileoperations.FileIO;
25 | import com.aditya.filebrowser.fileoperations.Operations;
26 | import com.aditya.filebrowser.interfaces.IContextSwitcher;
27 | import com.aditya.filebrowser.listeners.OnFileChangedListener;
28 | import com.aditya.filebrowser.listeners.SearchViewListener;
29 | import com.aditya.filebrowser.listeners.TabChangeListener;
30 | import com.aditya.filebrowser.models.FileItem;
31 | import com.aditya.filebrowser.utils.AssortedUtils;
32 | import com.aditya.filebrowser.utils.Permissions;
33 | import com.roughike.bottombar.BottomBar;
34 | import com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener;
35 | import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
36 |
37 | import org.apache.commons.io.FileUtils;
38 |
39 | import java.io.File;
40 | import java.util.ArrayList;
41 | import java.util.Arrays;
42 | import java.util.HashSet;
43 | import java.util.List;
44 | import java.util.Set;
45 |
46 | /**
47 | * Created by Aditya on 4/17/2017.
48 | */
49 | public class FileChooser extends AppCompatActivity implements OnFileChangedListener, IContextSwitcher {
50 |
51 | private Context mContext;
52 |
53 | private CustomAdapter mAdapter;
54 | private FastScrollRecyclerView.LayoutManager mLayoutManager;
55 | private FastScrollRecyclerView mFilesListView;
56 |
57 | private BottomBar mBottomView;
58 | private BottomBar mTopStorageView;
59 | private TabChangeListener mTabChangeListener;
60 |
61 | private TextView mCurrentPath;
62 | private NavigationHelper mNavigationHelper;
63 |
64 | private FileIO io;
65 | private Operations op;
66 | private int mSelectionMode;
67 |
68 | //Action Mode for filebrowser_toolbar
69 | private static ActionMode mActionMode;
70 | private static final int APP_PERMISSION_REQUEST = 0;
71 |
72 | private SearchView mSearchView;
73 | private MenuItem mSearchMenuItem;
74 | private SearchViewListener mSearchViewListener;
75 | private List mFileList = new ArrayList<>();
76 |
77 | @Override
78 | protected void onCreate(Bundle savedInstanceState) {
79 | super.onCreate(savedInstanceState);
80 |
81 | mContext = this;
82 |
83 | // Get File Storage Permission
84 | Intent in = new Intent(this, Permissions.class);
85 | Bundle bundle = new Bundle();
86 | bundle.putStringArray(Constants.APP_PREMISSION_KEY, Constants.APP_PREMISSIONS);
87 | in.putExtras(bundle);
88 | startActivityForResult(in, APP_PERMISSION_REQUEST);
89 |
90 | // Initialize Stuff
91 | mSelectionMode = getIntent().getIntExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());
92 | mNavigationHelper = new NavigationHelper(mContext);
93 | mNavigationHelper.setmChangeDirectoryListener(this);
94 | io = new FileIO(mNavigationHelper, new Handler(Looper.getMainLooper()), mContext);
95 | op = Operations.getInstance(mContext);
96 |
97 | //set file filter (i.e display files with the given extension)
98 | String filterFilesWithExtension = getIntent().getStringExtra(Constants.ALLOWED_FILE_EXTENSIONS);
99 | if (filterFilesWithExtension != null && !filterFilesWithExtension.isEmpty()) {
100 | Set allowedFileExtensions = new HashSet(Arrays.asList(filterFilesWithExtension.split(";")));
101 | mNavigationHelper.setAllowedFileExtensionFilter(allowedFileExtensions);
102 | }
103 |
104 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
105 | }
106 |
107 | @Override
108 | public void onBackPressed() {
109 |
110 | if (mAdapter.getChoiceMode() == Constants.CHOICE_MODE.MULTI_CHOICE) {
111 | switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
112 | return;
113 | }
114 |
115 | if (!mNavigationHelper.navigateBack()) {
116 | super.onBackPressed();
117 | }
118 | }
119 |
120 | @Override
121 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
122 | super.onActivityResult(requestCode, resultCode, data);
123 | if (requestCode == APP_PERMISSION_REQUEST ) {
124 | if (resultCode != Activity.RESULT_OK)
125 | Toast.makeText(mContext,mContext.getString(R.string.permission_error),Toast.LENGTH_LONG).show();
126 | loadUi();
127 | }
128 | }
129 |
130 | @Override
131 | public boolean onCreateOptionsMenu(Menu menu) {
132 | // Inflate the menu; this adds items to the action bar if it is present.
133 | getMenuInflater().inflate(R.menu.toolbar_default_menu_filechooser, menu);
134 | // Get the SearchView and set the searchable configuration
135 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
136 | mSearchMenuItem = menu.findItem(R.id.action_search);
137 | mSearchView = (SearchView)mSearchMenuItem.getActionView();
138 | // Assumes current activity is the searchable activity
139 | mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
140 | //searchView.setSubmitButtonEnabled(true);
141 | mSearchView.setOnQueryTextListener(mSearchViewListener);
142 | return true;
143 | }
144 |
145 | @Override
146 | public boolean onOptionsItemSelected(MenuItem item) {
147 |
148 | if (item.getItemId() == R.id.action_showfoldersizes) {
149 |
150 | if (AssortedUtils.GetPrefs(Constants.SHOW_FOLDER_SIZE, mContext).equalsIgnoreCase("true"))
151 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "false", mContext);
152 | else
153 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "true", mContext);
154 |
155 | onFileChanged(mNavigationHelper.getCurrentDirectory());
156 | }
157 |
158 | return false;
159 | }
160 |
161 | private void loadUi() {
162 | setContentView(R.layout.filebrowser_activity_main);
163 | mCurrentPath = (TextView) findViewById(R.id.currentPath);
164 |
165 | mFilesListView = (FastScrollRecyclerView) findViewById(R.id.recycler_view);
166 | mAdapter = new CustomAdapter(mFileList,mContext);
167 | mFilesListView.setAdapter(mAdapter);
168 | mLayoutManager = new LinearLayoutManager(mContext);
169 | mFilesListView.setLayoutManager(mLayoutManager);
170 | final CustomAdapterItemClickListener onItemClickListener = new CustomAdapterItemClickListener(mContext, mFilesListView, new CustomAdapterItemClickListener.OnItemClickListener() {
171 | @Override
172 | public void onItemClick(View view, int position) {
173 | // TODO Handle item click
174 | if (mAdapter.getChoiceMode() == Constants.CHOICE_MODE.SINGLE_CHOICE) {
175 | File f = mAdapter.getItemAt(position).getFile();
176 | if (f.isDirectory()) {
177 | closeSearchView();
178 | mNavigationHelper.changeDirectory(f);
179 | } else {
180 | if(mSelectionMode == Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal()) {
181 | Uri fileUri = Uri.fromFile(f);
182 | Intent data = new Intent();
183 | data.setData(fileUri);
184 | setResult(RESULT_OK, data);
185 | finish();
186 | } else {
187 | ArrayList chosenItems = new ArrayList<>();
188 | chosenItems.add(Uri.fromFile(f));
189 | Intent data = new Intent();
190 | data.putParcelableArrayListExtra(Constants.SELECTED_ITEMS, chosenItems);
191 | setResult(Activity.RESULT_OK, data);
192 | finish();
193 | }
194 | }
195 | }
196 | }
197 |
198 | @Override
199 | public void onItemLongClick(View view, int position) {
200 | switchMode(Constants.CHOICE_MODE.MULTI_CHOICE);
201 | mAdapter.selectItem(position);
202 | mFilesListView.scrollToPosition(position);
203 | }
204 | });
205 | mFilesListView.addOnItemTouchListener(onItemClickListener);
206 |
207 | mFilesListView.setOnFastScrollStateChangeListener(new OnFastScrollStateChangeListener() {
208 |
209 | @Override
210 | public void onFastScrollStart() {
211 | onItemClickListener.setmFastScrolling(true);
212 | }
213 |
214 | @Override
215 | public void onFastScrollStop() {
216 | onItemClickListener.setmFastScrolling(false);
217 | }
218 | });
219 |
220 | mSearchViewListener = new SearchViewListener(mAdapter);
221 |
222 | Toolbar toolbar = findViewById(R.id.filebrowser_tool_bar);
223 | setSupportActionBar(toolbar);
224 |
225 | mBottomView = findViewById(R.id.bottom_navigation);
226 | mTopStorageView = findViewById(R.id.currPath_Nav);
227 |
228 | mTabChangeListener = new TabChangeListener(this, mNavigationHelper, mAdapter, io,this);
229 | mTabChangeListener.setSelectionMode(Constants.SELECTION_MODES.values()[mSelectionMode]);
230 |
231 | mBottomView.setOnTabSelectListener(mTabChangeListener);
232 | mBottomView.setOnTabReselectListener(mTabChangeListener);
233 |
234 | mTopStorageView.setOnTabSelectListener(mTabChangeListener);
235 | mTopStorageView.setOnTabReselectListener(mTabChangeListener);
236 |
237 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
238 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
239 |
240 | onFileChanged(mNavigationHelper.getCurrentDirectory());
241 |
242 | //switch to initial directory if given
243 | String initialDirectory = getIntent().getStringExtra(Constants.INITIAL_DIRECTORY);
244 | if (initialDirectory != null && !initialDirectory.isEmpty() ) {
245 | File initDir = new File(initialDirectory);
246 | if (initDir.exists())
247 | mNavigationHelper.changeDirectory(initDir);
248 | }
249 | }
250 |
251 | @Override
252 | public void switchMode(Constants.CHOICE_MODE mode) {
253 | if (mode == Constants.CHOICE_MODE.SINGLE_CHOICE) {
254 | if (mActionMode != null)
255 | mActionMode.finish();
256 | } else {
257 | if (mActionMode == null) {
258 | closeSearchView();
259 | ToolbarActionMode newToolBar = new ToolbarActionMode(this,this, mAdapter, Constants.APP_MODE.FILE_CHOOSER, io);
260 | mActionMode = startSupportActionMode(newToolBar);
261 | mActionMode.setTitle(mContext.getString(R.string.select_multiple));
262 | }
263 | }
264 | }
265 |
266 | @Override
267 | public void changeBottomNavMenu(Constants.CHOICE_MODE multiChoice) {
268 | if (multiChoice == Constants.CHOICE_MODE.SINGLE_CHOICE) {
269 | mBottomView.setItems(R.xml.bottom_nav_items);
270 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
271 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
272 | } else {
273 | mBottomView.setItems(R.xml.bottom_nav_items_multiselect_filechooser);
274 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
275 | mBottomView.getTabWithId(R.id.menu_none1).setVisibility(View.GONE);
276 | mBottomView.getTabWithId(R.id.menu_none2).setVisibility(View.GONE);
277 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
278 | }
279 | }
280 |
281 | //Set action mode null after use
282 | @Override
283 | public void setNullToActionMode() {
284 | if (mActionMode != null)
285 | mActionMode = null;
286 | }
287 |
288 | @Override
289 | public void reDrawFileList() {
290 | mFilesListView.setLayoutManager(null);
291 | mFilesListView.setAdapter(mAdapter);
292 | mFilesListView.setLayoutManager(mLayoutManager);
293 | mTabChangeListener.setmAdapter(mAdapter);
294 | mAdapter.notifyDataSetChanged();
295 | }
296 |
297 | @Override
298 | public void onFileChanged(File updatedDirectory) {
299 | if (updatedDirectory != null && updatedDirectory.exists() && updatedDirectory.isDirectory()) {
300 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
301 | mCurrentPath.setText(updatedDirectory.getAbsolutePath());
302 | mAdapter.notifyDataSetChanged();
303 | mTopStorageView.getTabWithId(R.id.menu_internal_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getTotalSpace()));
304 | if (Constants.externalStorageRoot != null)
305 | mTopStorageView.getTabWithId(R.id.menu_external_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getTotalSpace()));
306 | }
307 | }
308 |
309 | private void closeSearchView() {
310 | if (mSearchView.isShown()) {
311 | mSearchView.setQuery("", false);
312 | mSearchMenuItem.collapseActionView();
313 | mSearchView.setIconified(true);
314 | }
315 | }
316 | }
317 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/FolderChooser.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | /**
4 | * Created by Aditya on 4/15/2017.
5 | */
6 |
7 | import android.app.Activity;
8 | import android.app.SearchManager;
9 | import android.content.ActivityNotFoundException;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.net.Uri;
13 | import android.os.Bundle;
14 | import android.os.Handler;
15 | import android.os.Looper;
16 | import android.support.v4.content.FileProvider;
17 | import android.support.v7.app.AppCompatActivity;
18 | import android.support.v7.view.ActionMode;
19 | import android.support.v7.widget.LinearLayoutManager;
20 | import android.support.v7.widget.SearchView;
21 | import android.support.v7.widget.Toolbar;
22 | import android.view.Menu;
23 | import android.view.MenuItem;
24 | import android.view.View;
25 | import android.webkit.MimeTypeMap;
26 | import android.widget.TextView;
27 | import android.widget.Toast;
28 |
29 | import com.aditya.filebrowser.adapters.CustomAdapter;
30 | import com.aditya.filebrowser.adapters.CustomAdapterItemClickListener;
31 | import com.aditya.filebrowser.fileoperations.FileIO;
32 | import com.aditya.filebrowser.fileoperations.Operations;
33 | import com.aditya.filebrowser.interfaces.IContextSwitcher;
34 | import com.aditya.filebrowser.listeners.OnFileChangedListener;
35 | import com.aditya.filebrowser.listeners.SearchViewListener;
36 | import com.aditya.filebrowser.listeners.TabChangeListener;
37 | import com.aditya.filebrowser.models.FileItem;
38 | import com.aditya.filebrowser.utils.AssortedUtils;
39 | import com.aditya.filebrowser.utils.Permissions;
40 | import com.aditya.filebrowser.utils.UIUtils;
41 | import com.roughike.bottombar.BottomBar;
42 | import com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener;
43 | import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
44 |
45 | import org.apache.commons.io.FileUtils;
46 | import org.apache.commons.io.FilenameUtils;
47 |
48 | import java.io.File;
49 | import java.util.ArrayList;
50 | import java.util.Arrays;
51 | import java.util.HashSet;
52 | import java.util.List;
53 | import java.util.Set;
54 |
55 | public class FolderChooser extends AppCompatActivity implements OnFileChangedListener, IContextSwitcher {
56 |
57 | private Context mContext;
58 |
59 | private CustomAdapter mAdapter;
60 | private FastScrollRecyclerView.LayoutManager mLayoutManager;
61 | private FastScrollRecyclerView mFilesListView;
62 |
63 | private BottomBar mBottomView;
64 | private BottomBar mTopStorageView;
65 | private TabChangeListener mTabChangeListener;
66 |
67 | private TextView mCurrentPath;
68 | private NavigationHelper mNavigationHelper;
69 |
70 | private FileIO io;
71 | private Operations op;
72 | private int mSelectionMode;
73 |
74 | //Action Mode for filebrowser_toolbar
75 | private static ActionMode mActionMode;
76 | private static final int APP_PERMISSION_REQUEST = 0;
77 |
78 | private SearchView mSearchView;
79 | private MenuItem mSearchMenuItem;
80 | private SearchViewListener mSearchViewListener;
81 | private List mFileList = new ArrayList<>();
82 |
83 | @Override
84 | protected void onCreate(Bundle savedInstanceState) {
85 | super.onCreate(savedInstanceState);
86 |
87 | mContext = this;
88 |
89 | // Get File Storage Permission
90 | Intent in = new Intent(this, Permissions.class);
91 | Bundle bundle = new Bundle();
92 | bundle.putStringArray(Constants.APP_PREMISSION_KEY, Constants.APP_PREMISSIONS);
93 | in.putExtras(bundle);
94 | startActivityForResult(in, APP_PERMISSION_REQUEST);
95 |
96 | // Initialize Stuff
97 | mSelectionMode = getIntent().getIntExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());
98 | mNavigationHelper = new NavigationHelper(mContext);
99 | mNavigationHelper.setmChangeDirectoryListener(this);
100 | io = new FileIO(mNavigationHelper, new Handler(Looper.getMainLooper()), mContext);
101 | op = Operations.getInstance(mContext);
102 |
103 | //set file filter (i.e display files with the given extension)
104 | String filterFilesWithExtension = getIntent().getStringExtra(Constants.ALLOWED_FILE_EXTENSIONS);
105 | if (filterFilesWithExtension != null && !filterFilesWithExtension.isEmpty()) {
106 | Set allowedFileExtensions = new HashSet(Arrays.asList(filterFilesWithExtension.split(";")));
107 | mNavigationHelper.setAllowedFileExtensionFilter(allowedFileExtensions);
108 | }
109 |
110 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
111 | }
112 |
113 | @Override
114 | public void onBackPressed() {
115 |
116 | if (mAdapter.getChoiceMode() == Constants.CHOICE_MODE.MULTI_CHOICE) {
117 | switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
118 | return;
119 | }
120 |
121 | if (!mNavigationHelper.navigateBack()) {
122 | super.onBackPressed();
123 | }
124 | }
125 |
126 | @Override
127 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
128 | super.onActivityResult(requestCode, resultCode, data);
129 | if (requestCode == APP_PERMISSION_REQUEST ) {
130 | if (resultCode != Activity.RESULT_OK)
131 | Toast.makeText(mContext,mContext.getString(R.string.permission_error),Toast.LENGTH_LONG).show();
132 | loadUi();
133 | }
134 | }
135 |
136 | @Override
137 | public boolean onCreateOptionsMenu(Menu menu) {
138 | // Inflate the menu; this adds items to the action bar if it is present.
139 | getMenuInflater().inflate(R.menu.toolbar_default_menu_filechooser, menu);
140 | // Get the SearchView and set the searchable configuration
141 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
142 | mSearchMenuItem = menu.findItem(R.id.action_search);
143 | mSearchView = (SearchView)mSearchMenuItem.getActionView();
144 | // Assumes current activity is the searchable activity
145 | mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
146 | //searchView.setSubmitButtonEnabled(true);
147 | mSearchView.setOnQueryTextListener(mSearchViewListener);
148 | return true;
149 | }
150 |
151 | @Override
152 | public boolean onOptionsItemSelected(MenuItem item) {
153 |
154 | if (item.getItemId() == R.id.action_showfoldersizes) {
155 |
156 | if (AssortedUtils.GetPrefs(Constants.SHOW_FOLDER_SIZE, mContext).equalsIgnoreCase("true"))
157 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "false", mContext);
158 | else
159 | AssortedUtils.SavePrefs(Constants.SHOW_FOLDER_SIZE, "true", mContext);
160 |
161 | onFileChanged(mNavigationHelper.getCurrentDirectory());
162 | }
163 |
164 | return false;
165 | }
166 |
167 | private void loadUi() {
168 | setContentView(R.layout.filebrowser_activity_main);
169 | mCurrentPath = (TextView) findViewById(R.id.currentPath);
170 |
171 | mFilesListView = (FastScrollRecyclerView) findViewById(R.id.recycler_view);
172 | mAdapter = new CustomAdapter(mFileList,mContext);
173 | mFilesListView.setAdapter(mAdapter);
174 | mLayoutManager = new LinearLayoutManager(mContext);
175 | mFilesListView.setLayoutManager(mLayoutManager);
176 | final CustomAdapterItemClickListener onItemClickListener = new CustomAdapterItemClickListener(mContext, mFilesListView, new CustomAdapterItemClickListener.OnItemClickListener() {
177 | @Override
178 | public void onItemClick(View view, int position) {
179 | // TODO Handle item click
180 | if (mAdapter.getChoiceMode() == Constants.CHOICE_MODE.SINGLE_CHOICE) {
181 | File f = mAdapter.getItemAt(position).getFile();
182 | if (f.isDirectory()) {
183 | closeSearchView();
184 | mNavigationHelper.changeDirectory(f);
185 | } else {
186 | MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
187 | Intent openFileIntent = new Intent(Intent.ACTION_VIEW);
188 | String mimeType = mimeMap.getMimeTypeFromExtension(FilenameUtils.getExtension(f.getName()));
189 | Uri uri = FileProvider.getUriForFile(mContext, mContext.getString(R.string.filebrowser_provider), f);
190 | openFileIntent.setDataAndType(uri,mimeType);
191 | openFileIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
192 | openFileIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
193 | try {
194 | mContext.startActivity(openFileIntent);
195 | } catch (ActivityNotFoundException e) {
196 | Toast.makeText(mContext, mContext.getString(R.string.no_app_to_handle), Toast.LENGTH_LONG).show();
197 | }
198 | }
199 | }
200 | }
201 |
202 | @Override
203 | public void onItemLongClick(View view, int position) {
204 | switchMode(Constants.CHOICE_MODE.MULTI_CHOICE);
205 | mAdapter.selectItem(position);
206 | mFilesListView.scrollToPosition(position);
207 | }
208 | });
209 | mFilesListView.addOnItemTouchListener(onItemClickListener);
210 |
211 | mFilesListView.setOnFastScrollStateChangeListener(new OnFastScrollStateChangeListener() {
212 |
213 | @Override
214 | public void onFastScrollStart() {
215 | onItemClickListener.setmFastScrolling(true);
216 | }
217 |
218 | @Override
219 | public void onFastScrollStop() {
220 | onItemClickListener.setmFastScrolling(false);
221 | }
222 | });
223 |
224 | mSearchViewListener = new SearchViewListener(mAdapter);
225 |
226 | Toolbar toolbar = findViewById(R.id.filebrowser_tool_bar);
227 | setSupportActionBar(toolbar);
228 |
229 | mBottomView = findViewById(R.id.bottom_navigation);
230 | mBottomView.setItems(R.xml.bottom_nav_items_folderchooser);
231 |
232 | mTopStorageView = findViewById(R.id.currPath_Nav);
233 |
234 | mTabChangeListener = new TabChangeListener(this, mNavigationHelper, mAdapter, io,this);
235 | mTabChangeListener.setSelectionMode(Constants.SELECTION_MODES.values()[mSelectionMode]);
236 | mTabChangeListener.setAppMode(Constants.APP_MODE.FOLDER_CHOOSER);
237 |
238 | mBottomView.setOnTabSelectListener(mTabChangeListener);
239 | mBottomView.setOnTabReselectListener(mTabChangeListener);
240 |
241 | mTopStorageView.setOnTabSelectListener(mTabChangeListener);
242 | mTopStorageView.setOnTabReselectListener(mTabChangeListener);
243 |
244 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
245 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
246 |
247 | onFileChanged(mNavigationHelper.getCurrentDirectory());
248 |
249 | //switch to initial directory if given
250 | String initialDirectory = getIntent().getStringExtra(Constants.INITIAL_DIRECTORY);
251 | if (initialDirectory != null && !initialDirectory.isEmpty() ) {
252 | File initDir = new File(initialDirectory);
253 | if (initDir.exists())
254 | mNavigationHelper.changeDirectory(initDir);
255 | }
256 | }
257 |
258 | @Override
259 | public void switchMode(Constants.CHOICE_MODE mode) {
260 | if (mode == Constants.CHOICE_MODE.SINGLE_CHOICE) {
261 | if (mActionMode != null)
262 | mActionMode.finish();
263 | } else {
264 | if (mActionMode == null) {
265 | closeSearchView();
266 | ToolbarActionMode newToolBar = new ToolbarActionMode(this,this, mAdapter, Constants.APP_MODE.FOLDER_CHOOSER, io);
267 | mActionMode = startSupportActionMode(newToolBar);
268 | mActionMode.setTitle(mContext.getString(R.string.select_multiple));
269 | }
270 | }
271 | }
272 |
273 | @Override
274 | public void changeBottomNavMenu(Constants.CHOICE_MODE multiChoice) {
275 | if (multiChoice == Constants.CHOICE_MODE.SINGLE_CHOICE) {
276 | mBottomView.setItems(R.xml.bottom_nav_items_folderchooser);
277 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
278 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
279 | } else {
280 | mBottomView.setItems(R.xml.bottom_nav_items_multiselect_filechooser);
281 | mBottomView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
282 | mBottomView.getTabWithId(R.id.menu_none1).setVisibility(View.GONE);
283 | mBottomView.getTabWithId(R.id.menu_none2).setVisibility(View.GONE);
284 | mTopStorageView.getTabWithId(R.id.menu_none).setVisibility(View.GONE);
285 | }
286 | }
287 |
288 | //Set action mode null after use
289 | @Override
290 | public void setNullToActionMode() {
291 | if (mActionMode != null)
292 | mActionMode = null;
293 | }
294 |
295 | @Override
296 | public void reDrawFileList() {
297 | mFilesListView.setLayoutManager(null);
298 | mFilesListView.setAdapter(mAdapter);
299 | mFilesListView.setLayoutManager(mLayoutManager);
300 | mTabChangeListener.setmAdapter(mAdapter);
301 | mAdapter.notifyDataSetChanged();
302 | }
303 |
304 | @Override
305 | public void onFileChanged(File updatedDirectory) {
306 | if (updatedDirectory != null && updatedDirectory.exists() && updatedDirectory.isDirectory()) {
307 | mFileList = mNavigationHelper.getFilesItemsInCurrentDirectory();
308 | mCurrentPath.setText(updatedDirectory.getAbsolutePath());
309 | mAdapter.notifyDataSetChanged();
310 | mTopStorageView.getTabWithId(R.id.menu_internal_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.internalStorageRoot.getTotalSpace()));
311 | if (Constants.externalStorageRoot != null)
312 | mTopStorageView.getTabWithId(R.id.menu_external_storage).setTitle(FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getUsableSpace()) + "/" + FileUtils.byteCountToDisplaySize(Constants.externalStorageRoot.getTotalSpace()));
313 | }
314 | }
315 |
316 | private void closeSearchView() {
317 | if (mSearchView.isShown()) {
318 | mSearchView.setQuery("", false);
319 | mSearchMenuItem.collapseActionView();
320 | mSearchView.setIconified(true);
321 | }
322 | }
323 | }
324 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/NavigationHelper.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 |
6 | import com.aditya.filebrowser.fileoperations.FileNavigator;
7 | import com.aditya.filebrowser.fileoperations.Operations;
8 | import com.aditya.filebrowser.listeners.OnFileChangedListener;
9 | import com.aditya.filebrowser.models.FileItem;
10 | import com.aditya.filebrowser.utils.UIUtils;
11 |
12 | import org.apache.commons.io.comparator.LastModifiedFileComparator;
13 | import org.apache.commons.io.comparator.NameFileComparator;
14 | import org.apache.commons.io.comparator.SizeFileComparator;
15 |
16 | import java.io.File;
17 | import java.util.ArrayList;
18 | import java.util.Arrays;
19 | import java.util.Comparator;
20 | import java.util.List;
21 | import java.util.Set;
22 |
23 | /**
24 | * Created by Aditya on 4/18/2017.
25 | */
26 | public class NavigationHelper {
27 |
28 | private FileNavigator mFileNavigator;
29 | private ArrayList mFiles = new ArrayList();
30 | private Context mContext;
31 | private List mChangeDirectoryListeners;
32 |
33 | NavigationHelper(Context mContext) {
34 | this.mContext = mContext;
35 | this.mFileNavigator = FileNavigator.getInstance();
36 | this.mChangeDirectoryListeners = new ArrayList<>();
37 | }
38 |
39 | public void setAllowedFileExtensionFilter(Set allowedFileExtensions) {
40 | mFileNavigator.setAllowedFileExtensionFilter(allowedFileExtensions);
41 | }
42 |
43 | public boolean navigateBack() {
44 |
45 | File parent = mFileNavigator.getmCurrentNode().getParentFile();
46 | if(parent==null || parent.compareTo(mFileNavigator.getmCurrentNode())==0 || Constants.externalStorageRoot==null || Constants.externalStorageRoot.compareTo(mFileNavigator.getmCurrentNode())==0 || Constants.internalStorageRoot.compareTo(mFileNavigator.getmCurrentNode())==0)
47 | return false;
48 | mFileNavigator.setmCurrentNode(parent);
49 | triggerFileChanged();
50 | return true;
51 | }
52 |
53 | public void navigateToInternalStorage() {
54 | mFileNavigator.setmCurrentNode(Constants.internalStorageRoot);
55 | triggerFileChanged();
56 | }
57 |
58 | public void navigateToExternalStorage() {
59 | String state = Environment.getExternalStorageState();
60 | if (Environment.MEDIA_MOUNTED.equals(state)) {
61 | mFileNavigator.setmCurrentNode(Constants.externalStorageRoot);
62 | } else {
63 | UIUtils.ShowToast(mContext.getString(R.string.external_storage_error),mContext);
64 | }
65 | triggerFileChanged();
66 | }
67 |
68 | public void changeDirectory(File newDirectory) {
69 | if(newDirectory!=null && newDirectory.exists() && newDirectory.isDirectory()) {
70 | mFileNavigator.setmCurrentNode(newDirectory);
71 | }
72 | triggerFileChanged();
73 | }
74 |
75 | public ArrayList getFilesItemsInCurrentDirectory() {
76 | Operations op = Operations.getInstance(mContext);
77 | Constants.SORT_OPTIONS option = op.getmCurrentSortOption();
78 | Constants.FILTER_OPTIONS filterOption = op.getmCurrentFilterOption();
79 | if (mFileNavigator.getmCurrentNode() == null) mFileNavigator.setmCurrentNode(mFileNavigator.getmRootNode());
80 | File[] files = mFileNavigator.getFilesInCurrentDirectory();
81 | if (files != null) {
82 | mFiles.clear();
83 | Comparator comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
84 | switch(option) {
85 | case SIZE:
86 | comparator = SizeFileComparator.SIZE_COMPARATOR;
87 | break;
88 | case LAST_MODIFIED:
89 | comparator = LastModifiedFileComparator.LASTMODIFIED_COMPARATOR;
90 | break;
91 | }
92 | Arrays.sort(files,comparator);
93 | for (int i = 0; i < files.length; i++) {
94 | boolean addToFilter = true;
95 | switch(filterOption) {
96 | case FILES:
97 | addToFilter = !files[i].isDirectory();
98 | break;
99 | case FOLDER:
100 | addToFilter = files[i].isDirectory();
101 | break;
102 | }
103 | if (addToFilter)
104 | mFiles.add(new FileItem(files[i]));
105 | }
106 | }
107 | return mFiles;
108 | }
109 |
110 | public File getCurrentDirectory() {
111 | return mFileNavigator.getmCurrentNode();
112 | }
113 |
114 | public void triggerFileChanged() {
115 | for(int i=0;i< mChangeDirectoryListeners.size();i++) {
116 | mChangeDirectoryListeners.get(i).onFileChanged(getCurrentDirectory());
117 | }
118 | }
119 |
120 | public void setmChangeDirectoryListener(OnFileChangedListener mChangeDirectoryListener) {
121 | this.mChangeDirectoryListeners.add(mChangeDirectoryListener);
122 | }
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/ToolbarActionMode.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import android.app.Activity;
4 | import android.app.SearchManager;
5 | import android.content.Context;
6 | import android.support.v7.view.ActionMode;
7 | import android.support.v7.widget.SearchView;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 |
11 | import com.aditya.filebrowser.Constants;
12 | import com.aditya.filebrowser.fileoperations.FileIO;
13 | import com.aditya.filebrowser.R;
14 | import com.aditya.filebrowser.adapters.CustomAdapter;
15 | import com.aditya.filebrowser.interfaces.IContextSwitcher;
16 | import com.aditya.filebrowser.listeners.SearchViewListener;
17 | import com.aditya.filebrowser.models.FileItem;
18 | import com.aditya.filebrowser.utils.UIUtils;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * Created by Aditya on 4/15/2017.
24 | */
25 | public class ToolbarActionMode implements ActionMode.Callback{
26 |
27 | private CustomAdapter mAdapter;
28 | private IContextSwitcher mIContextSwitcher;
29 | private Constants.APP_MODE appMode;
30 | private Activity mActivity;
31 | private FileIO io;
32 |
33 | private SearchView mSearchView;
34 | private MenuItem mSearchMenuItem;
35 |
36 | ToolbarActionMode(Activity mActivity, IContextSwitcher mIContextSwitcher, CustomAdapter mAdapter, Constants.APP_MODE mode, FileIO io) {
37 | this.mAdapter = mAdapter;
38 | this.mIContextSwitcher = mIContextSwitcher;
39 | this.appMode = mode;
40 | this.mActivity = mActivity;
41 | this.io = io;
42 | }
43 |
44 | @Override
45 | public boolean onCreateActionMode(ActionMode mode, Menu menu) {
46 | if (this.appMode == Constants.APP_MODE.FILE_BROWSER)
47 | mode.getMenuInflater().inflate(R.menu.toolbar_multiselect_menu, menu);//Inflate the menu over action mode
48 | else if (this.appMode == Constants.APP_MODE.FILE_CHOOSER || this.appMode == Constants.APP_MODE.FOLDER_CHOOSER )
49 | mode.getMenuInflater().inflate(R.menu.toolbar_multiselect_menu_filechooser, menu);//Inflate the menu over action mode
50 |
51 | return true;
52 | }
53 |
54 | @Override
55 | public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
56 | mAdapter.setChoiceMode(Constants.CHOICE_MODE.MULTI_CHOICE);
57 | mIContextSwitcher.changeBottomNavMenu(Constants.CHOICE_MODE.MULTI_CHOICE);
58 | mIContextSwitcher.reDrawFileList();
59 | return false;
60 | }
61 |
62 | @Override
63 | public void onDestroyActionMode(ActionMode mode) {
64 | mAdapter.setChoiceMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
65 | mIContextSwitcher.changeBottomNavMenu(Constants.CHOICE_MODE.SINGLE_CHOICE);
66 | mIContextSwitcher.reDrawFileList();
67 | mIContextSwitcher.setNullToActionMode();
68 | }
69 |
70 | @Override
71 | public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
72 | List selectedItems = mAdapter.getSelectedItems();;
73 | if (item.getItemId() == R.id.action_properties) {
74 | if (io != null)
75 | io.getProperties(selectedItems);
76 | mode.finish();
77 | }
78 | else if (item.getItemId() == R.id.action_share) {
79 | if (io != null)
80 | io.shareMultipleFiles(selectedItems);
81 | mode.finish();//Finish action mode
82 | }
83 | else if (item.getItemId() == R.id.action_rename) {
84 | if (selectedItems.size() != 1) {
85 | UIUtils.ShowToast(mActivity.getString(R.string.selection_error_single), mActivity);
86 | return false;
87 | }
88 | if (!selectedItems.get(0).getFile().canWrite()) {
89 | UIUtils.ShowToast(mActivity.getString(R.string.permission_error), mActivity);
90 | return false;
91 | }
92 | io.renameFile(selectedItems.get(0));
93 | mode.finish();//Finish action mode
94 | }
95 | else if (item.getItemId() == R.id.action_selectall) {
96 | mAdapter.selectAll();
97 | }
98 | else if (item.getItemId() == R.id.action_unselectall) {
99 | mAdapter.unSelectAll();
100 | }
101 | return false;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/adapters/CustomAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.CheckBox;
10 | import android.widget.CompoundButton;
11 | import android.widget.Filter;
12 | import android.widget.Filterable;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.aditya.filebrowser.Constants;
17 | import com.aditya.filebrowser.fileoperations.FileResolution;
18 | import com.aditya.filebrowser.R;
19 | import com.aditya.filebrowser.models.FileItem;
20 | import com.aditya.filebrowser.utils.AssortedUtils;
21 | import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
22 |
23 | import org.apache.commons.io.FileUtils;
24 |
25 | import java.io.File;
26 | import java.text.SimpleDateFormat;
27 | import java.util.ArrayList;
28 | import java.util.Date;
29 | import java.util.List;
30 |
31 |
32 | public class CustomAdapter extends RecyclerView.Adapter implements Filterable, FastScrollRecyclerView.SectionedAdapter {
33 |
34 | public void selectAll() {
35 | for(int i=0;i fileList;
54 | private List filteredfileList;
55 |
56 | private Constants.CHOICE_MODE currMode;
57 | private Context mContext;
58 | private FileFilter mFileFilter;
59 | @Override
60 | public Filter getFilter() {
61 | if (mFileFilter == null) {
62 | mFileFilter = new FileFilter();
63 | }
64 | return mFileFilter;
65 | }
66 |
67 | @NonNull
68 | @Override
69 | public String getSectionName(int position) {
70 | return Character.toString(filteredfileList.get(position).getFile().getName().charAt(0)).toUpperCase();
71 | }
72 |
73 | private class FileFilter extends Filter {
74 |
75 | @Override
76 | protected FilterResults performFiltering(CharSequence constraint) {
77 | FilterResults filterResults = new FilterResults();
78 |
79 | if (constraint!=null && constraint.length()>0) {
80 | ArrayList tempList = new ArrayList();
81 | // search content in friend list
82 | for (FileItem fileItem : fileList) {
83 | if (fileItem.getFile().getName().toLowerCase().contains(constraint.toString().toLowerCase())) {
84 | tempList.add(fileItem);
85 | }
86 | }
87 | filterResults.count = tempList.size();
88 | filterResults.values = tempList;
89 | } else {
90 | filterResults.count = fileList.size();
91 | filterResults.values = fileList;
92 | }
93 | return filterResults;
94 | }
95 |
96 | @Override
97 | protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
98 | filteredfileList = (ArrayList) filterResults.values;
99 | notifyDataSetChanged();
100 | }
101 | }
102 |
103 | public class MyViewHolder extends RecyclerView.ViewHolder {
104 | public TextView fileName;
105 | public TextView fileModified;
106 | public ImageView fileIcon;
107 | public CheckBox selectcb;
108 |
109 | public MyViewHolder(View view) {
110 | super(view);
111 | fileName = (TextView) view.findViewById(R.id.filename);
112 | fileModified = (TextView) view.findViewById(R.id.filemodifiedinfo);
113 | fileIcon = (ImageView) view.findViewById(R.id.file_icon);
114 | selectcb = (CheckBox) view.findViewById(R.id.selectFile);
115 | }
116 | }
117 |
118 |
119 | public CustomAdapter(List fileList,Context mContext) {
120 | this.fileList = fileList;
121 | this.filteredfileList = fileList;
122 | this.currMode = Constants.CHOICE_MODE.SINGLE_CHOICE;
123 | this.mContext = mContext;
124 | }
125 |
126 | public void setChoiceMode(Constants.CHOICE_MODE mode) {
127 | this.currMode = mode;
128 | if(mode== Constants.CHOICE_MODE.SINGLE_CHOICE)
129 | for(FileItem item : filteredfileList) {
130 | item.setSelected(false);
131 | }
132 | }
133 |
134 | public Constants.CHOICE_MODE getChoiceMode() {
135 | return this.currMode;
136 | }
137 |
138 | @Override
139 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
140 | View itemView = LayoutInflater.from(parent.getContext())
141 | .inflate(R.layout.file_item, parent, false);
142 |
143 | return new MyViewHolder(itemView);
144 | }
145 |
146 | @Override
147 | public void onBindViewHolder(final MyViewHolder holder, int position) {
148 | File f = filteredfileList.get(holder.getAdapterPosition()).getFile();
149 | holder.fileIcon.setImageResource(FileResolution.getFileIcon(f));
150 | int length = 0;
151 | String children = "";
152 | if(f.isDirectory()) {
153 | if(f.listFiles()!=null)
154 | length = f.listFiles().length;
155 | children = " (" +length + ")";
156 | }
157 |
158 | holder.fileName.setText(f.getName() + children);
159 | try {
160 | Date d = new Date(f.lastModified());
161 | SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT);
162 | String fileSize = "";
163 | if(AssortedUtils.GetPrefs(Constants.SHOW_FOLDER_SIZE,mContext).equalsIgnoreCase("true")) {
164 | fileSize = filteredfileList.get(holder.getAdapterPosition()).getFileSize();
165 | }
166 | holder.fileModified.setText(mContext.getString(R.string.file_info,fileSize,formatter.format(d)));
167 | } catch (Exception e) {
168 |
169 | }
170 | if(getChoiceMode()== Constants.CHOICE_MODE.MULTI_CHOICE) {
171 | holder.selectcb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
172 | @Override
173 | public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
174 | filteredfileList.get(holder.getAdapterPosition()).setSelected(isChecked);
175 | }
176 | });
177 | holder.selectcb.setChecked(filteredfileList.get(holder.getAdapterPosition()).isSelected());
178 | } else {
179 | holder.selectcb.setVisibility(View.GONE);
180 | }
181 | }
182 |
183 | @Override
184 | public int getItemCount() {
185 | return filteredfileList.size();
186 | }
187 |
188 | public List getSelectedItems() {
189 | List selectedItems = new ArrayList();
190 | if(getChoiceMode()== Constants.CHOICE_MODE.MULTI_CHOICE) {
191 | for(FileItem item : filteredfileList) {
192 | if(item.isSelected())
193 | selectedItems.add(item);
194 | }
195 | }
196 | return selectedItems;
197 | }
198 |
199 | public FileItem getItemAt(int position) {
200 | return filteredfileList.get(position);
201 | }
202 | }
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/adapters/CustomAdapterItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.GestureDetector;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 |
9 | /**
10 | * Created by Aditya on 4/14/2017.
11 | */
12 |
13 | public class CustomAdapterItemClickListener implements RecyclerView.OnItemTouchListener {
14 |
15 | private OnItemClickListener mListener;
16 | private boolean mFastScrolling = false;
17 |
18 | public interface OnItemClickListener {
19 | void onItemClick(View view, int position);
20 | void onItemLongClick(View view, int position);
21 | }
22 |
23 | GestureDetector mGestureDetector;
24 |
25 | public CustomAdapterItemClickListener(Context context, final RecyclerView recyclerView, OnItemClickListener listener) {
26 | mListener = listener;
27 | mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
28 | @Override
29 | public boolean onSingleTapUp(MotionEvent e) {
30 | return true;
31 | }
32 | @Override
33 | public void onLongPress(MotionEvent e){
34 | View childView = recyclerView.findChildViewUnder(e.getX(), e.getY());
35 |
36 | if(childView != null && mListener != null && !ismFastScrolling()){
37 | mListener.onItemLongClick(childView, recyclerView.getChildAdapterPosition(childView));
38 | }
39 | }
40 | });
41 | }
42 | @Override
43 | public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
44 | View childView = view.findChildViewUnder(e.getX(), e.getY());
45 | if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e) && !ismFastScrolling()) {
46 | mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
47 | }
48 | return false;
49 | }
50 |
51 | @Override
52 | public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
53 | }
54 |
55 | @Override
56 | public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
57 |
58 | }
59 |
60 | public boolean ismFastScrolling() {
61 | return mFastScrolling;
62 | }
63 |
64 | public void setmFastScrolling(boolean mFastScrollFlag) {
65 | this.mFastScrolling = mFastScrollFlag;
66 | }
67 | }
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/fileoperations/FileNavigator.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.fileoperations;
2 |
3 | import com.aditya.filebrowser.Constants;
4 |
5 | import org.apache.commons.io.FileUtils;
6 | import org.apache.commons.io.FilenameUtils;
7 |
8 | import java.io.File;
9 | import java.io.FilenameFilter;
10 | import java.util.Arrays;
11 | import java.util.List;
12 | import java.util.Set;
13 |
14 | /**
15 | * Created by Aditya on 4/17/2017.
16 | */
17 | public class FileNavigator {
18 |
19 | private static FileNavigator mNavigator;
20 |
21 | private File mCurrentNode = Constants.internalStorageRoot;
22 | private File mRootNode = Constants.internalStorageRoot;
23 |
24 | private Set mAllowedFileExtensionFilter;
25 |
26 | public static FileNavigator getInstance() {
27 | if(mNavigator==null) {
28 | mNavigator = new FileNavigator();
29 | }
30 | return mNavigator;
31 | }
32 |
33 | public File [] getFilesInCurrentDirectory() {
34 | if(mAllowedFileExtensionFilter!=null) {
35 | FilenameFilter fileNameFilter = new FilenameFilter() {
36 | @Override
37 | public boolean accept(File dir, String name) {
38 | File absolutePath = new File(dir, name);
39 | if (absolutePath.isDirectory()) {
40 | return true;
41 | }
42 | String fileExtension = FilenameUtils.getExtension(name);
43 | if(mAllowedFileExtensionFilter.contains(fileExtension)) {
44 | return true;
45 | }
46 | return false;
47 | }
48 | };
49 | return mCurrentNode.listFiles(fileNameFilter);
50 | }
51 | return mCurrentNode.listFiles();
52 | }
53 |
54 | private FileNavigator() {
55 | }
56 |
57 | public File getmCurrentNode() {
58 | return mCurrentNode;
59 | }
60 |
61 | public void setmCurrentNode(File mCurrentNode) {
62 | if(mCurrentNode!=null)
63 | this.mCurrentNode = mCurrentNode;
64 | }
65 |
66 | public void setAllowedFileExtensionFilter(Set allowedFileExtensions) {
67 | this.mAllowedFileExtensionFilter = allowedFileExtensions;
68 | }
69 |
70 |
71 | public File getmRootNode() {
72 | return mRootNode;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/fileoperations/FileResolution.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.fileoperations;
2 |
3 | import com.aditya.filebrowser.R;
4 |
5 | import org.apache.commons.io.FilenameUtils;
6 |
7 | import java.io.File;
8 | import java.util.HashMap;
9 |
10 | /**
11 | * Created by Aditya on 4/14/2017.
12 | */
13 | public class FileResolution {
14 |
15 | public static HashMap extIconMap;
16 |
17 | static {
18 | extIconMap = new HashMap();
19 | extIconMap.put("jpg", R.drawable.ic_photo_black_24dp);
20 | extIconMap.put("bmp", R.drawable.ic_photo_black_24dp);
21 | extIconMap.put("png", R.drawable.ic_photo_black_24dp);
22 | extIconMap.put("gif", R.drawable.ic_photo_black_24dp);
23 | extIconMap.put("psd", R.drawable.ic_photo_black_24dp);
24 |
25 | extIconMap.put("mp3", R.drawable.ic_audiotrack_black_24dp);
26 | extIconMap.put("wav", R.drawable.ic_audiotrack_black_24dp);
27 | extIconMap.put("wma", R.drawable.ic_audiotrack_black_24dp);
28 | extIconMap.put("aac", R.drawable.ic_audiotrack_black_24dp);
29 | extIconMap.put("mid", R.drawable.ic_audiotrack_black_24dp);
30 |
31 | extIconMap.put("3gp", R.drawable.ic_ondemand_video_black_24dp);
32 | extIconMap.put("3g2", R.drawable.ic_ondemand_video_black_24dp);
33 | extIconMap.put("avi", R.drawable.ic_ondemand_video_black_24dp);
34 | extIconMap.put("flv", R.drawable.ic_ondemand_video_black_24dp);
35 | extIconMap.put("mov", R.drawable.ic_ondemand_video_black_24dp);
36 | extIconMap.put("mp4", R.drawable.ic_ondemand_video_black_24dp);
37 | extIconMap.put("mpg", R.drawable.ic_ondemand_video_black_24dp);
38 | extIconMap.put("rm", R.drawable.ic_ondemand_video_black_24dp);
39 | extIconMap.put("vob", R.drawable.ic_ondemand_video_black_24dp);
40 | extIconMap.put("wmv", R.drawable.ic_ondemand_video_black_24dp);
41 | extIconMap.put("mkv", R.drawable.ic_ondemand_video_black_24dp);
42 |
43 | extIconMap.put("rar", R.drawable.ic_layers_black_24dp);
44 | extIconMap.put("zip", R.drawable.ic_layers_black_24dp);
45 |
46 | extIconMap.put("apk", R.drawable.ic_android_black_24dp);
47 |
48 | }
49 |
50 | public static int getFileIcon(File f) {
51 | if (f.isDirectory()) {
52 | return R.drawable.ic_folder_open_black_24dp;
53 | } else {
54 | String ext = FilenameUtils.getExtension(f.getName());
55 | if (ext!=null && extIconMap.containsKey(ext))
56 | return extIconMap.get(ext);
57 |
58 | return R.drawable.ic_insert_drive_file_black_24dp;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/fileoperations/GetRemovableDevice.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.fileoperations;
2 |
3 | import android.util.Log;
4 |
5 | import com.aditya.filebrowser.Constants;
6 |
7 | import java.io.BufferedReader;
8 | import java.io.FileNotFoundException;
9 | import java.io.FileReader;
10 | import java.io.IOException;
11 | import java.util.ArrayList;
12 | import java.util.Arrays;
13 | import java.util.HashSet;
14 | import java.util.List;
15 | import java.util.StringTokenizer;
16 |
17 | public class GetRemovableDevice {
18 |
19 | private static final String TAG = "StorageUtils";
20 |
21 | public static class StorageInfo {
22 |
23 | public final String path;
24 | public final boolean internal;
25 | public final boolean readonly;
26 | public final int display_number;
27 |
28 | StorageInfo(String path, boolean internal, boolean readonly, int display_number) {
29 | this.path = path;
30 | this.internal = internal;
31 | this.readonly = readonly;
32 | this.display_number = display_number;
33 | }
34 |
35 | public String getDisplayName() {
36 | StringBuilder res = new StringBuilder();
37 | if (internal) {
38 | res.append(Constants.INTERNALSTORAGE);
39 | } else if (display_number > 1) {
40 | res.append(Constants.EXTERNALSTORAGE + display_number);
41 | } else {
42 | res.append(Constants.EXTERNALSTORAGE);
43 | }
44 | if (readonly) {
45 | res.append(" (Read only)");
46 | }
47 | return res.toString();
48 | }
49 | }
50 |
51 | public static List getStorageList() {
52 |
53 | List list = new ArrayList();
54 | BufferedReader buf_reader = null;
55 | try {
56 | HashSet paths = new HashSet();
57 | buf_reader = new BufferedReader(new FileReader("/proc/mounts"));
58 | String line;
59 | int cur_display_number = 1;
60 | Log.d(TAG, "/proc/mounts");
61 | while ((line = buf_reader.readLine()) != null) {
62 | Log.d(TAG, line);
63 | if (line.contains("vfat") || line.contains("/mnt")) {
64 | StringTokenizer tokens = new StringTokenizer(line, " ");
65 | String unused = tokens.nextToken(); //device
66 | String mount_point = tokens.nextToken(); //mount point
67 | if (paths.contains(mount_point)) {
68 | continue;
69 | }
70 | unused = tokens.nextToken(); //file system
71 | List flags = Arrays.asList(tokens.nextToken().split(",")); //flags
72 | boolean readonly = flags.contains("ro");
73 |
74 | if (line.contains("/dev/block/vold")) {
75 | if (!line.contains("/mnt/secure")
76 | && !line.contains("/mnt/asec")
77 | && !line.contains("/mnt/obb")
78 | && !line.contains("/dev/mapper")
79 | && !line.contains("tmpfs")) {
80 | paths.add(mount_point);
81 | list.add(new StorageInfo(mount_point, false, readonly, cur_display_number++));
82 | }
83 | }
84 | }
85 | }
86 |
87 | } catch (FileNotFoundException ex) {
88 | ex.printStackTrace();
89 | } catch (IOException ex) {
90 | ex.printStackTrace();
91 | } finally {
92 | if (buf_reader != null) {
93 | try {
94 | buf_reader.close();
95 | } catch (IOException ex) {}
96 | }
97 | }
98 | return list;
99 | }
100 | }
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/fileoperations/Operations.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.fileoperations;
2 |
3 | import android.content.Context;
4 |
5 | import com.aditya.filebrowser.Constants;
6 | import com.aditya.filebrowser.R;
7 | import com.aditya.filebrowser.models.FileItem;
8 | import com.aditya.filebrowser.utils.UIUtils;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by adik on 9/27/2015.
14 | */
15 | public class Operations {
16 |
17 | public enum FILE_OPERATIONS {
18 | CUT,
19 | COPY,
20 | NONE
21 | }
22 |
23 | private List selectedFiles;
24 |
25 | public void resetOperation() {
26 | if(selectedFiles!=null)
27 | selectedFiles.clear();
28 | selectedFiles = null;
29 | setOperation(FILE_OPERATIONS.NONE);
30 | }
31 |
32 | public FILE_OPERATIONS getOperation() {
33 | return currOperation;
34 | }
35 |
36 | public void setOperation(FILE_OPERATIONS operationn) {
37 | this.currOperation = operationn;
38 | }
39 |
40 | private FILE_OPERATIONS currOperation;
41 |
42 | public List getSelectedFiles() {
43 | return selectedFiles;
44 | }
45 |
46 | public void setSelectedFiles(List selectedItems) {
47 | this.selectedFiles = selectedItems;
48 | UIUtils.ShowToast(mContext.getString(R.string.selected_items,selectedItems.size()),mContext);
49 | }
50 |
51 | private static Operations op;
52 |
53 | private Context mContext;
54 |
55 | private Operations(Context mContext)
56 | {
57 | this.mContext = mContext;
58 | this.currOperation = FILE_OPERATIONS.NONE;
59 | }
60 |
61 | public static Operations getInstance(Context mContext)
62 | {
63 | if(op==null)
64 | {
65 | op = new Operations(mContext);
66 | }
67 | return op;
68 | }
69 |
70 | public Constants.SORT_OPTIONS getmCurrentSortOption() {
71 | return mCurrentSortOption;
72 | }
73 |
74 | public void setmCurrentSortOption(Constants.SORT_OPTIONS mCurrentSortOption) {
75 | this.mCurrentSortOption = mCurrentSortOption;
76 | }
77 |
78 | public Constants.FILTER_OPTIONS getmCurrentFilterOption() {
79 | return mCurrentFilterOption;
80 | }
81 |
82 | public void setmCurrentFilterOption(Constants.FILTER_OPTIONS mCurrentFilterOption) {
83 | this.mCurrentFilterOption = mCurrentFilterOption;
84 | }
85 |
86 | private Constants.SORT_OPTIONS mCurrentSortOption = Constants.SORT_OPTIONS.NAME;
87 |
88 | private Constants.FILTER_OPTIONS mCurrentFilterOption = Constants.FILTER_OPTIONS.ALL;
89 | }
90 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/interfaces/IContextSwitcher.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.interfaces;
2 |
3 | import com.aditya.filebrowser.Constants;
4 |
5 | /**
6 | * Created by Aditya on 4/18/2017.
7 | */
8 | public interface IContextSwitcher {
9 | public void changeBottomNavMenu(Constants.CHOICE_MODE multiChoice);
10 | public void setNullToActionMode();
11 | public void reDrawFileList();
12 | public void switchMode(Constants.CHOICE_MODE mode);
13 | }
14 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/interfaces/IFuncPtr.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.interfaces;
2 |
3 | /**
4 | * Created by Aditya on 4/15/2017.
5 | */
6 | public interface IFuncPtr {
7 | void execute(String val);
8 | }
9 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/interfaces/ITrackSelection.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.interfaces;
2 |
3 | /**
4 | * Created by Aditya on 4/15/2017.
5 | */
6 | public interface ITrackSelection {
7 | boolean isSelected();
8 | void setSelected(boolean isSelected);
9 | }
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/listeners/OnFileChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.listeners;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * Created by Aditya on 4/18/2017.
7 | */
8 | public interface OnFileChangedListener {
9 | void onFileChanged(File updatedFile);
10 | }
11 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/listeners/SearchViewListener.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.listeners;
2 |
3 | import android.support.v7.widget.SearchView;
4 |
5 | import com.aditya.filebrowser.adapters.CustomAdapter;
6 |
7 | /**
8 | * Created by Aditya on 4/30/2017.
9 | */
10 | public class SearchViewListener implements SearchView.OnQueryTextListener {
11 |
12 | CustomAdapter mAdapter;
13 |
14 | @Override
15 | public boolean onQueryTextSubmit(String query) {
16 | return false;
17 | }
18 |
19 | @Override
20 | public boolean onQueryTextChange(String newText) {
21 | mAdapter.getFilter().filter(newText);
22 | return false;
23 | }
24 |
25 | public SearchViewListener(CustomAdapter customAdapter) {
26 | this.mAdapter = customAdapter;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/listeners/TabChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.listeners;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.support.annotation.IdRes;
7 | import android.support.v4.content.ContextCompat;
8 | import android.widget.RadioGroup;
9 |
10 | import com.aditya.filebrowser.Constants;
11 | import com.aditya.filebrowser.fileoperations.FileIO;
12 | import com.aditya.filebrowser.NavigationHelper;
13 | import com.aditya.filebrowser.fileoperations.Operations;
14 | import com.aditya.filebrowser.R;
15 | import com.aditya.filebrowser.adapters.CustomAdapter;
16 | import com.aditya.filebrowser.interfaces.IContextSwitcher;
17 | import com.aditya.filebrowser.models.FileItem;
18 | import com.aditya.filebrowser.utils.UIUtils;
19 | import com.roughike.bottombar.OnTabReselectListener;
20 | import com.roughike.bottombar.OnTabSelectListener;
21 |
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | /**
26 | * Created by Aditya on 4/18/2017.
27 | */
28 | public class TabChangeListener implements OnTabSelectListener, OnTabReselectListener {
29 |
30 | private NavigationHelper mNavigationHelper;
31 | private CustomAdapter mAdapter;
32 | private Activity mActivity;
33 | private FileIO io;
34 | private IContextSwitcher mIContextSwitcher;
35 | private Constants.SELECTION_MODES selectionMode;
36 | private Constants.APP_MODE appMode;
37 |
38 | public TabChangeListener(Activity mActivity, NavigationHelper mNavigationHelper, CustomAdapter mAdapter, FileIO io, IContextSwitcher mContextSwtcher) {
39 | this.mNavigationHelper = mNavigationHelper;
40 | this.mActivity = mActivity;
41 | this.mAdapter = mAdapter;
42 | this.io = io;
43 | this.mIContextSwitcher = mContextSwtcher;
44 | this.selectionMode = Constants.SELECTION_MODES.SINGLE_SELECTION;
45 | this.appMode = Constants.APP_MODE.FILE_CHOOSER;
46 | }
47 |
48 | @Override
49 | public void onTabSelected(@IdRes int tabId) {
50 | handleTabChange(tabId);
51 | }
52 |
53 | @Override
54 | public void onTabReSelected(@IdRes int tabId) {
55 | handleTabChange(tabId);
56 | }
57 |
58 | private void handleTabChange(int tabId) {
59 |
60 | if (tabId == R.id.menu_back) {
61 | mNavigationHelper.navigateBack();
62 | }
63 | else if (tabId == R.id.menu_internal_storage) {
64 | mNavigationHelper.navigateToInternalStorage();
65 | }
66 | else if (tabId == R.id.menu_external_storage) {
67 | mNavigationHelper.navigateToExternalStorage();
68 | }
69 | else if (tabId == R.id.menu_refresh) {
70 | mNavigationHelper.triggerFileChanged();
71 | }
72 | else if (tabId == R.id.menu_filter) {
73 | UIUtils.showRadioButtonDialog(mActivity, mActivity.getResources().getStringArray(R.array.filter_options), mActivity.getString(R.string.filter_only), new RadioGroup.OnCheckedChangeListener() {
74 | @Override
75 | public void onCheckedChanged(RadioGroup radioGroup, int position) {
76 | Operations op = Operations.getInstance(mActivity);
77 | if (op != null) {
78 | op.setmCurrentFilterOption(Constants.FILTER_OPTIONS.values()[position]);
79 | }
80 | mNavigationHelper.triggerFileChanged();
81 | }
82 | });
83 | }
84 | else if (tabId == R.id.menu_sort) {
85 | UIUtils.showRadioButtonDialog(mActivity, mActivity.getResources().getStringArray(R.array.sort_options), mActivity.getString(R.string.sort_by), new RadioGroup.OnCheckedChangeListener() {
86 | @Override
87 | public void onCheckedChanged(RadioGroup radioGroup, int position) {
88 | Operations op = Operations.getInstance(mActivity);
89 | if (op != null) {
90 | op.setmCurrentSortOption(Constants.SORT_OPTIONS.values()[position]);
91 | }
92 | mNavigationHelper.triggerFileChanged();
93 | }
94 | });
95 | }
96 | else if (tabId == R.id.menu_delete) {
97 | List selectedItems = mAdapter.getSelectedItems();
98 | if (io != null) {
99 | io.deleteItems(selectedItems);
100 | mIContextSwitcher.switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
101 | }
102 | }
103 | else if (tabId == R.id.menu_copy) {
104 | Operations op = Operations.getInstance(mActivity);
105 | if (op != null) {
106 | op.setOperation(Operations.FILE_OPERATIONS.COPY);
107 | op.setSelectedFiles(mAdapter.getSelectedItems());
108 | mIContextSwitcher.switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
109 | }
110 | }
111 | else if (tabId == R.id.menu_cut) {
112 | Operations op = Operations.getInstance(mActivity);
113 | if (op != null) {
114 | op.setOperation(Operations.FILE_OPERATIONS.CUT);
115 | op.setSelectedFiles(mAdapter.getSelectedItems());
116 | mIContextSwitcher.switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
117 | }
118 | }
119 | else if (tabId == R.id.menu_chooseitems) {
120 | {
121 | List selItems = getmAdapter().getSelectedItems();
122 | ArrayList chosenItems = new ArrayList<>();
123 | boolean hasInvalidSelections = false;
124 | for (int i = 0; i < selItems.size(); i++) {
125 | if (getAppMode() == Constants.APP_MODE.FOLDER_CHOOSER) {
126 | if (selItems.get(i).getFile().isDirectory()) {
127 | chosenItems.add(Uri.fromFile(selItems.get(i).getFile()));
128 | } else {
129 | hasInvalidSelections = true;
130 | }
131 | } else {
132 | chosenItems.add(Uri.fromFile(selItems.get(i).getFile()));
133 | }
134 | }
135 | if (hasInvalidSelections) {
136 | UIUtils.ShowToast(mActivity.getString(R.string.invalid_selections),mActivity);
137 | mActivity.finish();
138 | }
139 |
140 | mIContextSwitcher.switchMode(Constants.CHOICE_MODE.SINGLE_CHOICE);
141 | if(getSelectionMode() == Constants.SELECTION_MODES.SINGLE_SELECTION) {
142 | if(chosenItems.size() == 1) {
143 | Intent data = new Intent();
144 | data.setData(chosenItems.get(0));
145 | mActivity.setResult(Activity.RESULT_OK, data);
146 | mActivity.finish();
147 | } else {
148 | UIUtils.ShowToast(mActivity.getString(R.string.selection_error_single),mActivity);
149 | }
150 | } else {
151 | Intent data = new Intent();
152 | data.putParcelableArrayListExtra(Constants.SELECTED_ITEMS, chosenItems);
153 | mActivity.setResult(Activity.RESULT_OK, data);
154 | mActivity.finish();
155 | }
156 | }
157 | } else if (tabId == R.id.menu_select) {
158 | Uri fileUri = Uri.fromFile(mNavigationHelper.getCurrentDirectory());
159 | Intent data = new Intent();
160 | data.setData(fileUri);
161 | mActivity.setResult(Activity.RESULT_OK, data);
162 | mActivity.finish();
163 | }
164 | }
165 |
166 | public CustomAdapter getmAdapter() {
167 | return mAdapter;
168 | }
169 |
170 | public void setmAdapter(CustomAdapter mAdapter) {
171 | this.mAdapter = mAdapter;
172 | }
173 |
174 | public Constants.SELECTION_MODES getSelectionMode() {
175 | return selectionMode;
176 | }
177 |
178 | public void setSelectionMode(Constants.SELECTION_MODES selectionMode) {
179 | this.selectionMode = selectionMode;
180 | }
181 |
182 | public Constants.APP_MODE getAppMode() {
183 | return appMode;
184 | }
185 |
186 | public void setAppMode(Constants.APP_MODE appMode) {
187 | this.appMode = appMode;
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/models/FileItem.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.models;
2 |
3 | import com.aditya.filebrowser.interfaces.ITrackSelection;
4 | import com.aditya.filebrowser.utils.AssortedUtils;
5 |
6 | import org.apache.commons.io.FileUtils;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Created by Aditya on 4/15/2017.
12 | */
13 | public class FileItem implements ITrackSelection {
14 |
15 | private File file;
16 | private boolean isSelected;
17 | private String fileSize;
18 |
19 | public File getFile() {
20 | return file;
21 | }
22 |
23 | public void setFile(File file) {
24 | this.file = file;
25 | }
26 |
27 | public String getFileSize() {
28 | return fileSize;
29 | }
30 |
31 | public void setFileSize(String fileSize) {
32 | this.fileSize = fileSize;
33 | }
34 |
35 | @Override
36 | public boolean isSelected() {
37 | return isSelected;
38 | }
39 |
40 | @Override
41 | public void setSelected(boolean isSelected) {
42 | this.isSelected = isSelected;
43 | }
44 |
45 | public FileItem(File file) {
46 | this.file = file;
47 | try {
48 | if (file.isDirectory()) {
49 | setFileSize(FileUtils.byteCountToDisplaySize(AssortedUtils.GetMinimumDirSize(file)) + " | ");
50 | } else {
51 | setFileSize(FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(file)) + " | ");
52 | }
53 | } catch (Exception e) {
54 | setFileSize("Unknown | ");
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/utils/AssortedUtils.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | import java.io.File;
8 |
9 | public class AssortedUtils {
10 |
11 | public static void SavePrefs(String key, String value, Context context)
12 | {
13 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
14 | SharedPreferences.Editor editor = sp.edit();
15 | editor.putString(key,value);
16 | editor.apply();
17 | }
18 |
19 | public static String GetPrefs(String key, Context context)
20 | {
21 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
22 | return sp.getString(key, "");
23 | }
24 |
25 | public static long GetMinimumDirSize(File file)
26 | {
27 | long result = 0;
28 | for (File f : file.listFiles()) {
29 | if(f.isFile()) {
30 | result += f.length();
31 | } else if(f.isDirectory()) {
32 | result += f.getTotalSpace();
33 | }
34 | }
35 | return result;
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/utils/Permissions.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.utils;
2 |
3 | /**
4 | * Created by Aditya on 4/15/2017.
5 | */
6 |
7 | import android.app.Activity;
8 | import android.content.Context;
9 | import android.content.pm.PackageManager;
10 | import android.os.Build;
11 | import android.os.Bundle;
12 | import android.support.annotation.NonNull;
13 | import android.support.v4.app.ActivityCompat;
14 | import android.support.v4.content.ContextCompat;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.widget.Toast;
17 |
18 | import com.aditya.filebrowser.Constants;
19 | import com.aditya.filebrowser.R;
20 |
21 | import java.util.ArrayList;
22 |
23 | /**
24 | * Created by Aditya on 4/14/2017.
25 | */
26 | public class Permissions extends AppCompatActivity {
27 |
28 | public static final int APP_PERMISSIONS_REQUEST = 0;
29 | public static final int DENIED = 1;
30 | public static final int BLOCKED_OR_NEVER_ASKED = 2;
31 | public static final int GRANTED = 3;
32 | private Context mContext;
33 |
34 | public void requestPermissions(String[] permissions) {
35 |
36 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
37 |
38 | int ungrantedPermCount = 0;
39 | ArrayList permissionsToBeAsked = new ArrayList();
40 | for(int i=0; i < permissions.length; i++) {
41 | if (isPermissionIsGranted(permissions[i],this) != GRANTED) {
42 | ungrantedPermCount++;
43 | permissionsToBeAsked.add(permissions[i]);
44 | }
45 | }
46 | if (ungrantedPermCount == 0) {
47 | setResult(Activity.RESULT_OK);
48 | finish();
49 | } else {
50 | ActivityCompat.requestPermissions(this,
51 | permissionsToBeAsked.toArray(new String[permissionsToBeAsked.size()]),
52 | APP_PERMISSIONS_REQUEST);
53 | }
54 | } else {
55 | setResult(Activity.RESULT_OK);
56 | finish();
57 | }
58 | }
59 |
60 | public static int isPermissionIsGranted(String permission, Activity activity) {
61 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
62 | if(ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
63 | if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)){
64 | return BLOCKED_OR_NEVER_ASKED;
65 | }
66 | return DENIED;
67 | }
68 | return GRANTED;
69 | } else {
70 | return GRANTED;
71 | }
72 | }
73 |
74 | @Override
75 | protected void onCreate(Bundle savedInstanceState) {
76 | super.onCreate(savedInstanceState);
77 |
78 | mContext = this;
79 |
80 | Bundle b = this.getIntent().getExtras();
81 | String[] permissions = b.getStringArray(Constants.APP_PREMISSION_KEY);
82 | if (permissions != null) {
83 | requestPermissions(permissions);
84 | } else {
85 | Toast.makeText(mContext, mContext.getString(R.string.permission_request_error),Toast.LENGTH_LONG).show();
86 | finish();
87 | }
88 | }
89 |
90 | @Override
91 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
92 | switch (requestCode) {
93 | case APP_PERMISSIONS_REQUEST: {
94 | // If request is cancelled, the result arrays are empty.
95 | if (grantResults.length > 0) {
96 |
97 | boolean isAllPermissionsGranted = true;
98 | for (int i=0; i < grantResults.length; i++) {
99 | if(grantResults[i] != PackageManager.PERMISSION_GRANTED) {
100 | isAllPermissionsGranted = false;
101 | break;
102 | }
103 | }
104 | if (isAllPermissionsGranted) {
105 | setResult(Activity.RESULT_OK);
106 | } else {
107 | setResult(Activity.RESULT_CANCELED);
108 | }
109 |
110 | } else {
111 | setResult(Activity.RESULT_CANCELED);
112 | }
113 | finish();
114 | }
115 | }
116 | }
117 |
118 | }
119 |
120 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/utils/UIUpdateHelper.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.utils;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 |
6 | import com.aditya.filebrowser.NavigationHelper;
7 |
8 | /**
9 | * Created by Aditya on 4/16/2017.
10 | */
11 | public class UIUpdateHelper {
12 |
13 | Context mContext;
14 | NavigationHelper mNavigationeHelper;
15 |
16 | public UIUpdateHelper(NavigationHelper mNavigationeHelper, Context mContext) {
17 | this.mContext = mContext;
18 | this.mNavigationeHelper = mNavigationeHelper;
19 | }
20 |
21 | public Runnable updateRunner() {
22 | return new Runnable() {
23 | @Override
24 | public void run() {
25 | mNavigationeHelper.triggerFileChanged();
26 | }
27 | };
28 | }
29 |
30 | public Runnable errorRunner(final String msg) {
31 | return new Runnable() {
32 | @Override
33 | public void run() {
34 | UIUtils.ShowToast(msg, mContext);
35 | mNavigationeHelper.triggerFileChanged();
36 | }
37 | };
38 | }
39 |
40 | public Runnable progressUpdater(final ProgressDialog progressDialog, final int progress, final String msg) {
41 | return new Runnable() {
42 | @Override
43 | public void run() {
44 | if(progressDialog!=null) {
45 | progressDialog.setProgress(progress);
46 | progressDialog.setMessage(msg);
47 | }
48 | }
49 | };
50 | }
51 |
52 | public Runnable toggleProgressBarVisibility(final ProgressDialog progressDialog) {
53 | return new Runnable() {
54 | @Override
55 | public void run() {
56 | if(progressDialog!=null) {
57 | progressDialog.dismiss();
58 | }
59 | }
60 | };
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/filebrowser/src/main/java/com/aditya/filebrowser/utils/UIUtils.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser.utils;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.DialogInterface.OnClickListener;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.RadioButton;
11 | import android.widget.RadioGroup;
12 | import android.widget.Toast;
13 |
14 | import com.aditya.filebrowser.R;
15 | import com.aditya.filebrowser.interfaces.IFuncPtr;
16 | import com.beardedhen.androidbootstrap.BootstrapButton;
17 | import com.beardedhen.androidbootstrap.BootstrapEditText;
18 |
19 | public class UIUtils {
20 |
21 | public static void ShowError(String msg, Context context)
22 | {
23 | AlertDialog.Builder dlgAlert = new AlertDialog.Builder(context);
24 | dlgAlert.setMessage(msg);
25 | dlgAlert.setTitle(context.getString(R.string.error_common));
26 | dlgAlert.setIcon(android.R.drawable.ic_dialog_alert);
27 | dlgAlert.setPositiveButton(context.getString(R.string.ok), new OnClickListener() {
28 |
29 | @Override
30 | public void onClick(DialogInterface popup, int arg1) {
31 | // TODO Auto-generated method stub
32 | popup.dismiss();
33 | }
34 | });
35 | dlgAlert.setCancelable(false);
36 | dlgAlert.show();
37 | }
38 |
39 | public static void ShowMsg(String msg, String title,Context context)
40 | {
41 | AlertDialog.Builder dlgAlert = new AlertDialog.Builder(context);
42 | dlgAlert.setMessage(msg);
43 | dlgAlert.setTitle(title);
44 | dlgAlert.setIcon(android.R.drawable.ic_dialog_info);
45 | dlgAlert.setPositiveButton(context.getString(R.string.ok), new OnClickListener() {
46 |
47 | @Override
48 | public void onClick(DialogInterface popup, int arg1) {
49 | // TODO Auto-generated method stub
50 | popup.dismiss();
51 | }
52 | });
53 | dlgAlert.setCancelable(false);
54 | dlgAlert.show();
55 | }
56 |
57 | public static void ShowToast(String msg,Context context)
58 | {
59 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
60 | }
61 |
62 | public static void showRadioButtonDialog(Context mContext, String[] options, String title, final RadioGroup.OnCheckedChangeListener listener) {
63 |
64 | LayoutInflater inflater = (LayoutInflater)mContext.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
65 | View v = inflater.inflate(R.layout.filter_options, null);
66 |
67 | // custom dialog
68 | final Dialog dialog = new AlertDialog.Builder(mContext)
69 | .setTitle(title)
70 | .setView(v)
71 | .create();
72 |
73 | RadioGroup rg = (RadioGroup) v.findViewById(R.id.filter_group);
74 | BootstrapButton okButton = (BootstrapButton) v.findViewById(R.id.okbutton);
75 | for(int i=0;i
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_audiotrack_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_check_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_content_copy_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_content_cut_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_content_paste_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_create_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_create_new_folder_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_crop_original_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_done_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_folder_open_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_format_line_spacing_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_info_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_insert_drive_file_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_keyboard_backspace_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_layers_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_loop_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_low_priority_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_more_vert_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_new_releases_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_ondemand_video_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_photo_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_remove_circle_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_sd_storage_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_search_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_security_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_share_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_storage_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_swap_vert_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/ic_tune_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/drawable/nav_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/layout/dialog_with_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
22 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/layout/file_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
27 |
28 |
40 |
41 |
51 |
52 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/layout/filebrowser_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
21 |
22 |
28 |
29 |
33 |
34 |
35 |
36 |
42 |
43 |
44 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
70 |
71 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/layout/filebrowser_toolbar.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/layout/filter_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
22 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/menu/toolbar_default_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/menu/toolbar_default_menu_filechooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/menu/toolbar_multiselect_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/menu/toolbar_multiselect_menu_filechooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/filebrowser/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/filebrowser/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/filebrowser/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/filebrowser/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/filebrowser/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dateiexplorer
4 | Ausschneiden
5 | Aktualisieren
6 | Einfügen
7 | Kopieren
8 | Filtern
9 | Sortieren
10 | Mehr
11 | Löschen
12 | Umbenennen
13 | Teilen
14 | Neuer Ordner
15 | Quellverzeichnis
16 | Zurück
17 | Versteckte Ordner zeigen
18 | Eigenschaften
19 | Abbrechen
20 | Alle auswählen
21 | Ordnergröße anzeigen
22 | Versteckte Ordner anzeigen
23 | Objekte auswählen
24 | Suchen
25 | Nach Dateien suchen
26 | OK
27 | schreibgeschützt
28 | Es konnte kein Ordner hinzugefügt werden
29 | Die App besitzt keine Schreibrechte
30 | Dateien löschen
31 | Are you sure you want to delete %d items?
32 | Dateien werden gelöscht
33 | Es ist ein Fehler aufgetreten
34 | Keine Objekte ausgewählt
35 | Bitte warten
36 | Kopieren von %s
37 | Verschieben von %s
38 | Es ist ein Fehler aufgetreten
39 | Umbenennen
40 | Es ist ein Fehler aufgetreten
41 | Eigenschaften
42 | Verzeichnis
43 | Datei
44 | Typ: %s \n\n
45 | Größe: %s \n\n
46 | Zul. geändert: %s \n\n
47 | Pfad: %s
48 | Mehrehre Dateien \n\n
49 | Typ:
50 | Es konnten keine Eigenschaften erfasst werden
51 | Es wurde keine App gefunden, die Diesen Dateityp unterstützt
52 | %d Dateien ausgewählt
53 | Bitte nur 1 Datei auswählen
54 | Fehler
55 | Keine Berechtigungen erforderlich
56 | Die App besitzt nicht alle erforderlichen Rechte
57 | Keine Aktion ausgewählt
58 | Keine Dateien ausgewählt
59 | Es wurde keine App gefunden, die diesen Dateityp unterstützt
60 | Mehrere Dateien auswählen
61 | Es kann keine SD-Karte gefunden werden!
62 |
63 | - Dateien
64 | - Ordner
65 | - Alles
66 |
67 |
68 |
69 | - Name
70 | - Größe
71 | - Zuletzt geändert
72 |
73 | Filtern nach
74 | Sortieren nach
75 | %1$s zul. geändert %2$s
76 | Alles wiederufen
77 | Datei Bild
78 | wählen
79 | ungültige Auswahl
80 |
81 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Explorador de archivos
3 | Cortar
4 | Refrescar
5 | Pegar
6 | Copiar
7 | Filtrar
8 | Ordenar
9 | Más
10 | Eliminar
11 | Renombrar
12 | Compartir
13 | Nueva carpeta
14 | Raíz
15 | Atrás
16 | Ver carpetas ocultas
17 | Propiedades
18 | Int
19 | Ext
20 | Cancelar
21 | Seleccionar todo
22 | Ver tamaño de carpeta
23 | Ver carpetas ocultas
24 | Elegir items
25 | Buscar
26 | Ver archivos
27 | Ok
28 | Solo filtrar
29 | Ordenar por
30 | %1$s Última modificación: %2$s
31 | (Solo lectura)
32 |
33 | Ocurrió un error en la creación de la nueva carpeta
34 | Sin permiso para escribir
35 |
36 | Borrar archivos
37 | Estás seguro de eliminar %d elementos?
38 | Borrando, espera por favor…
39 | Ocurrió un error en la eliminación
40 | No hay elementos seleccionados
41 |
42 | Espera por favor…
43 | Copiando %s
44 | Moviendo %s
45 | Ocurrió un error pegando los elementos
46 |
47 | Renombrar
48 | Ocurrió un error en el renombrado
49 |
50 | Propiedades
51 | Directorio
52 | Archivo
53 | Tipo: %s \n\n
54 | Tamaño: %s \n\n
55 | Última modificación %s \n\n
56 | Path %s
57 | Multiples archivos \n\n
58 | Tipo:
59 | Imposible calcular las propiedades
60 |
61 | Sin apps para compartir los elementos
62 | %d elementos seleccionados
63 | Por favor selecciona solo un elemento
64 |
65 | No se solicitan permisos
66 | Error
67 | Faltan algunos permisos. La aplicación puede no funcionar correctamente. Por favor concede los permisos solicitados.
68 | Ninguna operación seleccionada
69 | Sin archivos seleccionados para pegar
70 | No se encontró ninguna aplicación para manejar este tipo de archivo.
71 | Seleccina múltiples archivos
72 | No se puede localizar el almacenamiento externo
73 | Deseleccionar todo
74 | imagen de archivo
75 | seleccionar
76 | Selecciones inválidas
77 |
78 |
79 | - Archivos
80 | - Carpetas
81 | - Todo
82 |
83 |
84 |
85 | - Nombre
86 | - Tamaño
87 | - Última modificación
88 |
89 |
90 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #515151
7 | #778cff
8 |
9 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | File Browser
3 | com.aditya.filebrowser.provider
4 | Cut
5 | Refresh
6 | Paste
7 | Copy
8 | Filter
9 | Sort
10 | More
11 | Delete
12 | Rename
13 | Share
14 | New Folder
15 | Root
16 | Back
17 | Show Hidden Folders
18 | Properties
19 | Int
20 | Ext
21 | Cancel
22 | Select All
23 | Show Folder Size
24 | Show Hidden Folders
25 | Choose Items
26 | Search
27 | Search Files
28 | Ok
29 | Filter Only
30 | Sort By
31 | %1$s Last Modified: %2$s
32 | (Read only)
33 |
34 | An error occurred while creating a new folder
35 | No Write Permission Granted
36 |
37 | Delete files
38 | Are you sure you want to delete %d items?
39 | Deleting Please Wait…
40 | An error occurred while deleting
41 | No Items selected
42 |
43 | Please Wait…
44 | Copying %s
45 | Moving %s
46 | An error occurred while pasting
47 |
48 | Rename
49 | An error occurred while renaming
50 |
51 | Properties
52 | Directory
53 | File
54 | Type: %s \n\n
55 | Size: %s \n\n
56 | Last Modified %s \n\n
57 | Path %s
58 | Multiple Files \n\n
59 | Type:
60 | Could Not Compute Properties
61 |
62 | No app found to handle sharing
63 | Selected %d items
64 | Please select only 1 item
65 |
66 | No Permissions Requested
67 | Error
68 | Some permissions not granted!. App may not work properly!. Please grant the required permissions!
69 | No operation selected
70 | No files selected to paste
71 | No app found to handle this type of file.
72 | Select Multiple Files
73 | Cannot Locate External Store
74 | Unselect All
75 | File Image
76 | Select
77 | Invalid selections
78 |
79 | - Files
80 | - Folders
81 | - All
82 |
83 |
84 |
85 | - Name
86 | - Size
87 | - Last Modified
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/bottom_nav_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
13 |
17 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/bottom_nav_items_folderchooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/bottom_nav_items_multiselect.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
13 |
17 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/bottom_nav_items_multiselect_filechooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
9 |
13 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/path_change_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
10 |
11 |
12 |
13 |
17 |
22 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/filebrowser/src/main/res/xml/searchable.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/filebrowser/src/test/java/com/aditya/filebrowser/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aditya.filebrowser;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jun 30 18:23:48 CEST 2019
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-5.1.1-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 |
--------------------------------------------------------------------------------
/sample/Test/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/sample/Test/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/Test/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 | defaultConfig {
7 | applicationId "com.aditya.test"
8 | minSdkVersion 17
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | testImplementation 'junit:junit:4.12'
24 | implementation 'com.android.support:support-v4:28.0.0'
25 | implementation 'com.android.support:support-media-compat:28.0.0'
26 | implementation 'com.android.support:design:28.0.0'
27 | implementation 'com.android.support:appcompat-v7:28.0.0'
28 | //implementation project(":filebrowser")
29 | implementation 'com.adityak:browsemyfiles:1.9'
30 | }
31 |
--------------------------------------------------------------------------------
/sample/Test/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\Aditya\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 |
--------------------------------------------------------------------------------
/sample/Test/app/src/androidTest/java/com/aditya/test/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aditya.test;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/sample/Test/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/java/com/aditya/test/FileSelectedBroadCastReceiver.java:
--------------------------------------------------------------------------------
1 | package com.aditya.test;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.net.Uri;
7 | import android.widget.Toast;
8 |
9 | /**
10 | * Created by Aditya on 7/15/2017.
11 | */
12 |
13 | public class FileSelectedBroadCastReceiver extends BroadcastReceiver {
14 | @Override
15 | public void onReceive(Context context, Intent intent) {
16 | Uri filePath = intent.getParcelableExtra(com.aditya.filebrowser.Constants.BROADCAST_SELECTED_FILE);
17 | Toast.makeText(context,filePath.toString(),Toast.LENGTH_LONG).show();
18 | }
19 | }
--------------------------------------------------------------------------------
/sample/Test/app/src/main/java/com/aditya/test/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.aditya.test;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Environment;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.os.Bundle;
9 | import android.widget.Toast;
10 |
11 | import com.aditya.filebrowser.Constants;
12 | import com.aditya.filebrowser.FileBrowser;
13 | import com.aditya.filebrowser.FileBrowserWithCustomHandler;
14 | import com.aditya.filebrowser.FileChooser;
15 | import com.aditya.filebrowser.FolderChooser;
16 |
17 | import java.io.File;
18 |
19 | public class MainActivity extends AppCompatActivity {
20 | static int PICK_FOLDER_REQUEST = 1;
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | Intent i = new Intent(this, FolderChooser.class);
26 | i.putExtra(Constants.INITIAL_DIRECTORY, new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Movies").getAbsolutePath());
27 | i.putExtra(Constants.ALLOWED_FILE_EXTENSIONS, "mkv;mp4");
28 | i.putExtra(Constants.SELECTION_MODE, Constants.SELECTION_MODES.SINGLE_SELECTION.ordinal());
29 | startActivityForResult(i, PICK_FOLDER_REQUEST);
30 | //startActivity(i);
31 | }
32 |
33 | @Override
34 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
35 | super.onActivityResult(requestCode, resultCode, data);
36 | if (requestCode == PICK_FOLDER_REQUEST && data!=null) {
37 | if (resultCode == RESULT_OK) {
38 | Uri file = data.getData();
39 | Toast.makeText(this, file.toString(), Toast.LENGTH_SHORT).show();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values-w820dp/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #2196F3
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Test
3 |
4 |
--------------------------------------------------------------------------------
/sample/Test/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/Test/app/src/test/java/com/aditya/test/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aditya.test;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/sample/Test/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 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.4.1'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | maven {
20 | url "https://maven.google.com"
21 | }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/sample/Test/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/sample/Test/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adityak368/Android-FileBrowser-FilePicker/2ddde4e3dfc5874e9fb2cf80c18477554282f74d/sample/Test/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/Test/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jun 29 16:24:33 CEST 2019
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-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/sample/Test/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 |
--------------------------------------------------------------------------------
/sample/Test/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 |
--------------------------------------------------------------------------------
/sample/Test/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':filebrowser'
2 |
--------------------------------------------------------------------------------