Skip to content

Commit d191575

Browse files
authored
Starting on a more comprehensive set of user docs (besides the source code)
1 parent c08c7cc commit d191575

1 file changed

Lines changed: 86 additions & 69 deletions

File tree

README.md

Lines changed: 86 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ Key features in the library include the following:
4444

4545
### Screenshots of the library in action (Default theme)
4646

47-
<img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201112-052224.png" width="250" /><img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201113-134724.png" width="250" /><img src="" width="250" />
48-
49-
<img src="" width="250" /><img src="" width="250" /><img src="" width="250" />
47+
<img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201112-052224.png" width="250" /> <img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201113-134724.png" width="250" /> <img src="https://raw.githubusercontent.com/maxieds/AndroidFilePickerLight/master/Screenshots/SampleApplicationDemo-ProgressBarDisplay.png" width="250" />
5048

5149
## Including the library in an Android application
5250

@@ -121,6 +119,9 @@ that the application set the option
121119
<!-- Complete the internals of the application tag (activities, etc.) below -->
122120
</application>
123121
```
122+
Note that unlike some samples to get other Android libraries up and running, there is no need to define references
123+
to the custom ``FileProvider`` implemented by the library. It is sufficient to just use the standardized wrappers
124+
to launch a new ``FileChooserActivity`` instance and use the file picker functionality bundled within that interface.
124125

125126
## Sample client Java source code
126127

@@ -154,12 +155,27 @@ the results:
154155

155156
This is a quick method to select a file and/or directory picked by the user:
156157
```java
157-
public void actionButtonLaunchSingleFilePickerActivity(View btnView) {
158+
public void actionButtonLaunchSingleFilePickerActivity(View btnView) {
158159
FileChooserBuilder fpInst = FileChooserBuilder.getDirectoryChooserInstance(this);
159160
fpInst.showHidden(true);
161+
fpInst.setPickerInitialPath(FileChooserBuilder.BaseFolderPathType.BASE_PATH_DEFAULT);
162+
fpInst.launchFilePicker();
163+
}
164+
public void actionButtonLaunchSingleFilePickerActivity(View btnView) {
165+
FileChooserBuilder fpInst = FileChooserBuilder.getSingleFilePickerInstance(this);
166+
fpInst.showHidden(true);
160167
fpInst.setPickerInitialPath(FileChooserBuilder.BaseFolderPathType.BASE_PATH_TYPE_EXTERNAL_FILES_SCREENSHOTS);
161168
fpInst.launchFilePicker();
162169
}
170+
public void actionButtonLaunchOmnivorousMultiPickerActivity(View btnView) {
171+
FileChooserBuilder fpInst = new FileChooserBuilder(this);
172+
fpInst.setSelectionMode(FileChooserBuilder.SelectionModeType.SELECT_OMNIVORE);
173+
fpInst.setSelectMultiple(5);
174+
fpInst.setActionCode(FileChooserBuilder.ACTIVITY_CODE_SELECT_MULTIPLE_FILES);
175+
fpInst.showHidden(true);
176+
fpInst.setPickerInitialPath(FileChooserBuilder.BaseFolderPathType.BASE_PATH_TYPE_EXTERNAL_FILES_DOWNLOADS);
177+
fpInst.launchFilePicker();
178+
}
163179
```
164180

165181
### Detailed list of non-display type options
@@ -174,14 +190,77 @@ These can be set using the ``AndroidFilePickerLight.Builder`` class as follows:
174190
### Extending file types for filtering and sorting purposes in the picker UI
175191

176192

193+
#### Overriding the default file and directory sorting (TODO)
177194

178-
### Configuring the client theme and UI look-and-feel properties
195+
An example of how to do this is already seen by glancing through the sources.
196+
In particular, we define an extendable base class as follows:
197+
```java
198+
public static class FileItemsSortFunc implements Comparator<File> {
199+
public File[] sortFileItemsList(File[] folderContentsList) {
200+
Arrays.sort(folderContentsList, this);
201+
return folderContentsList;
202+
}
203+
@Override
204+
public int compare(File f1, File f2) {
205+
// default is standard lexicographical ordering (override the compare functor base classes for customized sorting):
206+
return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
207+
}
208+
}
209+
```
210+
Subclasses that override the method above are free to sort the file
211+
contents in the order that they are best displayed in the client application.
212+
Some examples would be to override the default of placing directories at the top of the
213+
files list, to perform a case-insensitive lexicographical sort (like happens on many Linux),
214+
or otherwise to prioritize the file rankings where the most importantly valued presentations
215+
are shown first.
216+
217+
Note that in the source the custom objects to filter (match, then include/exclude) the full
218+
directory listings, and then sort those files that remain are applied together. See, for example,
219+
the next code:
220+
```java
221+
public static class FileFilterByRegex extends FileFilterBase {
222+
private Pattern patternSpec;
223+
public FileFilterByRegex(String regexPatternSpec, boolean inclExcl) {
224+
patternSpec = Pattern.compile(regexPatternSpec);
225+
setIncludeExcludeMatchesOption(inclExcl);
226+
}
227+
public boolean fileMatchesFilter(String fileAbsName) {
228+
if(patternSpec.matcher(fileAbsName).matches()) {
229+
return includeExcludeMatches == INCLUDE_FILES_IN_FILTER_PATTERN;
230+
}
231+
return includeExcludeMatches == EXCLUDE_FILES_IN_FILTER_PATTERN;
232+
}
233+
}
234+
```
235+
236+
#### Extending the inclusion/exclusion mechanism of files by type
237+
238+
The specification (by Java interface and a few utility derived instances) are found in the
239+
library source file ``FileFilter.java``. The bulk of the interface is reproduced as
240+
follows:
241+
```java
242+
public interface FileFilterInterface {
243+
244+
static final boolean INCLUDE_FILES_IN_FILTER_PATTERN = FilePickerBuilder.INCLUDE_FILES_IN_FILTER_PATTERN;
245+
static final boolean EXCLUDE_FILES_IN_FILTER_PATTERN = FilePickerBuilder.EXCLUDE_FILES_IN_FILTER_PATTERN;
246+
247+
void setIncludeExcludeMatchesOption(boolean includeExcludeParam);
248+
boolean includeFileInSearchResults(FileTypes.FileType fileItem);
249+
boolean fileMatchesFilter(FileTypes.FileType fileItem);
250+
251+
}
252+
```
179253

180-
#### Basic example (quickstart guide to using the file picker library)
181254

182255

183256

257+
### Configuring the client theme and UI look-and-feel properties
184258

259+
This part of the library, while a primary motivator for writing it and a key feature it aims to have,
260+
is still under active development. I will add in documentation showing how to customize the file
261+
picker themes (color schemes, icons, and other properties) as they become ready to use.
262+
263+
#### Basic example (quickstart guide to using the file picker library)
185264

186265
#### Full example (detailed usage of the current custom theme/UI display options)
187266

@@ -223,9 +302,7 @@ This functionality may be useful at some point for those willing to extend this
223302
custom external file providers, e.g., to read and recurse into directories on Dropbox or GitHub.
224303
I have a simple visual Toast-like display that can be updated and/or canceled in real time to
225304
let the user know that the directory is loading and that the client application is just "thinking"
226-
(as opposed to freezing with a runtime error). The stock progress bar looks something like the following screenshot:
227-
228-
<img src="https://raw.githubusercontent.com/maxieds/AndroidFilePickerLight/master/Screenshots/SampleApplicationDemo-ProgressBarDisplay.png" width="250" />
305+
(as opposed to freezing with a runtime error).
229306

230307
To invoke this progress bar display in realtime, consider calling the following code examples:
231308
```java
@@ -241,63 +318,3 @@ its demo application). The core of the progress bar is
241318
shown by periodically posting Toast messages with a custom layout ``View``. Please post a new issue message
242319
if anyone using this library in their own application finds this useful, or amusing too.
243320

244-
#### Overriding the default file and directory sorting (TODO)
245-
246-
An example of how to do this is already seen by glancing through the sources.
247-
In particular, we define an extendable base class as follows:
248-
```java
249-
public static class FileItemsSortFunc implements Comparator<File> {
250-
public File[] sortFileItemsList(File[] folderContentsList) {
251-
Arrays.sort(folderContentsList, this);
252-
return folderContentsList;
253-
}
254-
@Override
255-
public int compare(File f1, File f2) {
256-
// default is standard lexicographical ordering (override the compare functor base classes for customized sorting):
257-
return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
258-
}
259-
}
260-
```
261-
Subclasses that override the method above are free to sort the file
262-
contents in the order that they are best displayed in the client application.
263-
Some examples would be to override the default of placing directories at the top of the
264-
files list, to perform a case-insensitive lexicographical sort (like happens on many Linux),
265-
or otherwise to prioritize the file rankings where the most importantly valued presentations
266-
are shown first.
267-
268-
Note that in the source the custom objects to filter (match, then include/exclude) the full
269-
directory listings, and then sort those files that remain are applied together. See, for example,
270-
the next code:
271-
```java
272-
public static class FileFilterByRegex extends FileFilterBase {
273-
private Pattern patternSpec;
274-
public FileFilterByRegex(String regexPatternSpec, boolean inclExcl) {
275-
patternSpec = Pattern.compile(regexPatternSpec);
276-
setIncludeExcludeMatchesOption(inclExcl);
277-
}
278-
public boolean fileMatchesFilter(String fileAbsName) {
279-
if(patternSpec.matcher(fileAbsName).matches()) {
280-
return includeExcludeMatches == INCLUDE_FILES_IN_FILTER_PATTERN;
281-
}
282-
return includeExcludeMatches == EXCLUDE_FILES_IN_FILTER_PATTERN;
283-
}
284-
}
285-
```
286-
287-
#### Extending the inclusion/exclusion mechanism of files by type
288-
289-
The specification (by Java interface and a few utility derived instances) are found in the
290-
library source file ``FileFilter.java``. The bulk of the interface is reproduced as
291-
follows:
292-
```java
293-
public interface FileFilterInterface {
294-
295-
static final boolean INCLUDE_FILES_IN_FILTER_PATTERN = FilePickerBuilder.INCLUDE_FILES_IN_FILTER_PATTERN;
296-
static final boolean EXCLUDE_FILES_IN_FILTER_PATTERN = FilePickerBuilder.EXCLUDE_FILES_IN_FILTER_PATTERN;
297-
298-
void setIncludeExcludeMatchesOption(boolean includeExcludeParam);
299-
boolean includeFileInSearchResults(FileTypes.FileType fileItem);
300-
boolean fileMatchesFilter(FileTypes.FileType fileItem);
301-
302-
}
303-
```

0 commit comments

Comments
 (0)