5
5
6
6
<img src =" https://jitpack.io/v/maxieds/AndroidFilePickerLight.svg " /><img src =" https://img.shields.io/badge/NOTE%3A-Project%20is%20a%20work%20in%20progress-orange " /><img src =" https://img.shields.io/badge/API%2029%2B-Tested%20on%20Android%2010-yellowgreen " /><img src =" https://badges.frapsoft.com/os/gpl/gpl.svg?v=103 " />
7
7
8
-
9
8
<img src =" https://forthebadge.com/images/badges/made-with-java.svg " /><img src =" https://forthebadge.com/images/badges/powered-by-coffee.svg " /><img src =" https://forthebadge.com/images/badges/built-for-android.svg " />
10
9
11
- <img src =" https://badges.frapsoft.com/os/v2/open-source-175x29.png?v=103 " />
10
+ <img src =" https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/ReadmeEmojiBadges/HackerCatEmoji-v1.png " />< img src = " https:// badges.frapsoft.com/os/v2/open-source-175x29.png?v=103" />< img src = " https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/ReadmeEmojiBadges/tRUTH.png " />
12
11
13
12
#### A polite request from the developer
14
13
@@ -19,8 +18,6 @@ fellow Android developers alike with a quality code base.
19
18
It will make me just * so happy* all over if you all that appreciate this source code contribution as much as I have writing it
20
19
can help me reach out to my first ** 100-star** repository on GitHub.
21
20
22
- [ ![ HitCount] ( http://hits.dwyl.com/maxieds/AndroidFileChooserLight.svg )] ( http://hits.dwyl.com/maxieds/AndroidFileChooserLight )
23
-
24
21
## About the library
25
22
26
23
A file and directory chooser widget for Android that focuses on presenting an easy to configure lightweight UI.
@@ -65,7 +62,7 @@ library can be included in the client Android application:
65
62
in the application * build.gradle* configuration.
66
63
* Update the project * AndroidManifest.xml* file to extend the documents provider,
67
64
request required permissions, and setup some helpful legacy file handling options for devices
68
- targeting Android platforms with SDK < 11.
65
+ targeting Android platforms with SDK < Android OS 11.
69
66
70
67
Examples of using the library to pick files and directories from client Java code is also
71
68
included in the detailed documentation in the next section.
@@ -134,7 +131,7 @@ Note that unlike some samples to get other Android libraries up and running, the
134
131
to the custom `` FileProvider `` implemented by the library. It is sufficient to just use the standardized wrappers
135
132
to launch a new `` FileChooserActivity `` instance and use the file picker functionality bundled within that interface.
136
133
137
- ## Sample client Java source code
134
+ ## Sample client source code in Java
138
135
139
136
The next examples document basic, advanced, and custom uses of the library in client code.
140
137
The file chooser instance is launched via a traditional `` startActivityForResult `` call
@@ -161,6 +158,13 @@ the results:
161
158
showFileChooserResultsDialog(selectedFilePaths, rteErrorMsg);
162
159
}
163
160
```
161
+ The following are the unique `` Intent `` keys that are associated with the returned data (if available):
162
+ ``` java
163
+ public static final String FILE_PICKER_INTENT_DATA_TYPE_KEY = " FilePickerIntentKey.SelectedIntentDataType" ;
164
+ public static final String FILE_PICKER_INTENT_DATA_PAYLOAD_KEY = " FilePickerIntentKey.SelectedIntentDataPayloadList" ;
165
+ public static final String FILE_PICKER_EXCEPTION_MESSAGE_KEY = " FilePickerIntentKey.UnexpectedExitMessage" ;
166
+ public static final String FILE_PICKER_EXCEPTION_CAUSE_KEY = " FilePickerIntentKey.ExceptionCauseDescKey" ;
167
+ ```
164
168
165
169
### Basic usage: Returning a file path selected by the user
166
170
@@ -195,7 +199,51 @@ The next options are available to configure the non-display type (e.g., properti
195
199
file chooser that do not depend on how it looks) properties of the library.
196
200
These can be set using the `` AndroidFilePickerLight.Builder `` class as follows:
197
201
``` java
198
- /* TODO */
202
+ FileChooserBuilder fcBuilderConfig = new FileChooserBuilder .getDirectoryChooserInstance(FileChooserActivity . getInstance())
203
+ .allowSelectFileItems()
204
+ .allowSelectFolderItems()
205
+ .setDisplayUIConfig(CustomThemeBuilder uiCfg) // Reserved for future use (see docs below)
206
+ .setActionCode(int activityResultCode)
207
+ .setNavigationFoldersList(List<DefaultNavFoldersType > navFoldersList)
208
+ .showHidden(boolean enable)
209
+ .setSelectMultiple(int maxFileInsts)
210
+ .setSelectionMode(SelectionModeType modeType)
211
+ .setPickerInitialPath(BaseFolderPathType storageAccessBase)
212
+ .setActivityIdleTimeout(long timeoutMillis)
213
+ .setExternalFilesProvider(ContentProvider extFileProvider); // Reserved for future use
214
+ ```
215
+ The relevant `` enum `` types that can be passed as arguments to these methods include the following:
216
+ ``` java
217
+ public enum SelectionModeType {
218
+ SELECT_FILE ,
219
+ SELECT_MULTIPLE_FILES ,
220
+ SELECT_DIRECTORY_ONLY ,
221
+ SELECT_OMNIVORE
222
+ }
223
+ public enum BaseFolderPathType {
224
+ BASE_PATH_TYPE_FILES_DIR ,
225
+ BASE_PATH_TYPE_EXTERNAL_FILES_DOWNLOADS ,
226
+ BASE_PATH_TYPE_EXTERNAL_FILES_MOVIES ,
227
+ BASE_PATH_TYPE_EXTERNAL_FILES_MUSIC ,
228
+ BASE_PATH_TYPE_EXTERNAL_FILES_DOCUMENTS ,
229
+ BASE_PATH_TYPE_EXTERNAL_FILES_DCIM ,
230
+ BASE_PATH_TYPE_EXTERNAL_FILES_PICTURES ,
231
+ BASE_PATH_TYPE_EXTERNAL_FILES_SCREENSHOTS ,
232
+ BASE_PATH_TYPE_USER_DATA_DIR ,
233
+ BASE_PATH_TYPE_MEDIA_STORE ,
234
+ BASE_PATH_SECONDARY_STORAGE ,
235
+ BASE_PATH_DEFAULT ,
236
+ BASE_PATH_EXTERNAL_PROVIDER ;
237
+ }
238
+ public enum DefaultNavFoldersType {
239
+ FOLDER_ROOT_STORAGE (" Root" , R . attr. namedFolderSDCardIcon, BaseFolderPathType . BASE_PATH_DEFAULT ),
240
+ FOLDER_PICTURES (" Pictures" , R . attr. namedFolderPicsIcon, BaseFolderPathType . BASE_PATH_TYPE_EXTERNAL_FILES_PICTURES ),
241
+ FOLDER_CAMERA (" Camera" , R . attr. namedFolderCameraIcon, BaseFolderPathType . BASE_PATH_TYPE_EXTERNAL_FILES_PICTURES ),
242
+ FOLDER_SCREENSHOTS (" Screenshots" , R . attr. namedFolderScreenshotsIcon, BaseFolderPathType . BASE_PATH_TYPE_EXTERNAL_FILES_SCREENSHOTS ),
243
+ FOLDER_DOWNLOADS (" Downloads" , R . attr. namedFolderDownloadsIcon, BaseFolderPathType . BASE_PATH_TYPE_EXTERNAL_FILES_DOWNLOADS ),
244
+ FOLDER_USER_HOME (" Home" , R . attr. namedFolderUserHomeIcon, BaseFolderPathType . BASE_PATH_TYPE_USER_DATA_DIR ),
245
+ FOLDER_MEDIA_VIDEO (" Media" , R . attr. namedFolderMediaIcon, BaseFolderPathType . BASE_PATH_TYPE_EXTERNAL_FILES_DCIM );
246
+ }
199
247
```
200
248
201
249
### Extending file types for filtering and sorting purposes in the picker UI
@@ -249,7 +297,6 @@ Here is an example of how to utilize these customized classes with the library's
249
297
``` java
250
298
FileChooserBuilder fcConfig = new FileChooserBuilder ();
251
299
fcConfig. setFilesListSortCompareFunction(FileFilter . FileItemsSortFunc );
252
- // TODO
253
300
254
301
// Some defaults for convenience:
255
302
fcConfig. filterByDefaultFileTypes(List<DefaultFileTypes > fileTypesList, boolean includeExcludeInList);
@@ -263,7 +310,7 @@ This part of the library, while a primary motivator for writing it and a key fea
263
310
is still under active development. I will add in documentation showing how to customize the file
264
311
picker themes (color schemes, icons, and other properties) as they become ready to use.
265
312
266
- #### Basic example (quickstart guide to using the file picker library)
313
+ #### Basic example (quickstart guide to using the file picker library styling options )
267
314
268
315
#### Full example (detailed usage of the current custom theme/UI display options)
269
316
@@ -299,25 +346,28 @@ here is the full listing and type specs for what attributes can actually be chan
299
346
300
347
### Misc other useful utilities and customizations bundled with the main library
301
348
302
- ### Displaying a visual linear bar style progress bar for slow directory loads (TODO)
349
+ #### Displaying a visual linear bar style progress bar for slow directory loads
303
350
304
351
This functionality may be useful at some point for those willing to extend this code with
305
352
custom external file providers, e.g., to read and recurse into directories on Dropbox or GitHub.
306
353
I have a simple visual Toast-like display that can be updated and/or canceled in real time to
307
354
let the user know that the directory is loading and that the client application is just "thinking"
308
- (as opposed to freezing with a runtime error).
355
+ (as opposed to freezing with an inexplicable runtime error).
309
356
310
- To invoke this progress bar display in realtime, consider calling the following code examples:
357
+ To invoke this progress bar display in realtime, consider calling the following
358
+ [ code examples] ( https://github.com/maxieds/AndroidFileChooserLight/blob/master/AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/DisplayUtils.java#L159 ) :
311
359
``` java
312
- DisplayUtils . DisplayProgressBar(String waitingOnProcessLabel , int curPos, int totalPos);
360
+ DisplayUtils . DisplayProgressBar(Activity activityInstInput, String thingsName , int curPos, int totalPos);
313
361
DisplayUtils . EnableProgressBarDisplay(true );
314
362
// ... Then whenever the long process completes, kill the progress bar update callbacks with: ...
315
- DisplayUtils . EnableProgressBarDisplay(true );
363
+ DisplayUtils . EnableProgressBarDisplay(false );
316
364
```
317
365
In principle, the status bar is useful when the underlying operation takes longer than, say 8-10 seconds to complete.
318
366
This code is modified from a status timer to keep the user informed while scanning for a long duration read of
319
367
NFC tags on Android (see [ the MFCToolLibrary] ( https://github.com/maxieds/MifareClassicToolLibrary ) and
320
368
its demo application). The core of the progress bar is
321
- shown by periodically posting Toast messages with a custom layout `` View `` . Please post a new issue message
322
- if anyone using this library in their own application finds this useful, or amusing too.
369
+ shown by periodically posting Toast messages with a custom layout `` View `` .
370
+ ** Please do post a new issue message
371
+ if anyone using this library in their own application finds this useful, or amusing too
372
+ (input and feedback from other humans is good, in general).**
323
373
0 commit comments