Skip to content

Commit 75e42ea

Browse files
committed
Preparing files to test Green and Orange custom themes in the demo application
1 parent a79a7ed commit 75e42ea

55 files changed

Lines changed: 168 additions & 114 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/CustomThemeBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public CustomThemeBuilder(Activity activityCtxRef) {
5757
cancelActionBtnIconResId = NULL_RESOURCE_ID;
5858
themeColorScheme = null;
5959
toolbarIconResId = NULL_RESOURCE_ID;
60-
navBtnIconResIdMap = new HashMap<FileChooserBuilder.BaseFolderPathType, Integer>();
60+
navBtnIconResIdMap = new HashMap<FileChooserBuilder.DefaultNavFoldersType, Integer>();
6161
fileIconResId = fileHiddenIconResId = folderIconResId = NULL_RESOURCE_ID;
6262
}
6363

@@ -229,9 +229,9 @@ public static int getToolbarIconDimension() {
229229
return 48; // pixels
230230
}
231231

232-
private Map<FileChooserBuilder.BaseFolderPathType, Integer> navBtnIconResIdMap;
232+
private Map<FileChooserBuilder.DefaultNavFoldersType, Integer> navBtnIconResIdMap;
233233

234-
public CustomThemeBuilder setNavigationByPathButtonIcon(@DrawableRes int iconResId, FileChooserBuilder.BaseFolderPathType whichBtnType) {
234+
public CustomThemeBuilder setNavigationByPathButtonIcon(@DrawableRes int iconResId, FileChooserBuilder.DefaultNavFoldersType whichBtnType) {
235235
navBtnIconResIdMap.put(whichBtnType, iconResId);
236236
return this;
237237
}
@@ -243,7 +243,7 @@ public static int getNavigationPathButtonIconDimension() {
243243
public interface FileChooserActivityMainLayoutStylizer {
244244
boolean styleNavigationDisplayToolbar(Toolbar toolbar);
245245
boolean styleNavigationByPathsBaseDisplay(TextView tvNavBtnsDirective);
246-
boolean styleDefaultPathNavigationButton(ImageButton dirNavBtn, FileChooserBuilder.BaseFolderPathType baseFolderBtnType) throws RuntimeException;
246+
boolean styleDefaultPathNavigationButton(ImageButton dirNavBtn, FileChooserBuilder.DefaultNavFoldersType baseFolderBtnType) throws RuntimeException;
247247
boolean styleBottomNavigationActionButtons(Button doneActionBtn, Button cancelActionBtn);
248248
boolean styleMainActivityLayout(View parentContainerLayoutView) throws RuntimeException;
249249
boolean styleMainActivityWindow(Window mainActivityWin) throws RuntimeException;
@@ -295,7 +295,7 @@ public FileChooserActivityMainLayoutStylizer createActivityMainLayoutStylizer()
295295

296296
private final Activity _activityCtx = activityCtx;
297297
private final FileChooserColorScheme _themeColorScheme = themeColorScheme;
298-
private final Map<FileChooserBuilder.BaseFolderPathType, Integer> _navBtnIconResIdMap = navBtnIconResIdMap;
298+
private final Map<FileChooserBuilder.DefaultNavFoldersType, Integer> _navBtnIconResIdMap = navBtnIconResIdMap;
299299
private final Drawable _toolbarLogoIcon = _toolbarLogoIconFinal;
300300
private final String _pickerTitleText = _pickerTitleTextFinal;
301301
private final String _navBarPrefixText = _navBarPrefixTextFinal;
@@ -318,7 +318,7 @@ public boolean styleNavigationDisplayToolbar(Toolbar toolbar) {
318318
}
319319

320320
@Override
321-
public boolean styleDefaultPathNavigationButton(ImageButton dirNavBtn, FileChooserBuilder.BaseFolderPathType baseFolderBtnType) throws RuntimeException {
321+
public boolean styleDefaultPathNavigationButton(ImageButton dirNavBtn, FileChooserBuilder.DefaultNavFoldersType baseFolderBtnType) throws RuntimeException {
322322
if(dirNavBtn == null || baseFolderBtnType == null) {
323323
return false;
324324
}

AndroidFilePickerLightLibrary/src/main/res/layout/main_picker_activity_base_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@
180180
android:scrollbars="none"
181181
android:splitMotionEvents="false"
182182
android:verticalScrollbarPosition="right"
183-
android:overScrollMode="never"
184183
android:scrollbarSize="30dp"
185184
/>
185+
<!--android:overScrollMode="never"-->
186186

187187
</LinearLayout>
188188

README.md

Lines changed: 75 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99

1010
<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" />
1111

12-
#### A polite request from the developer
13-
14-
In the event that this library and the documentation of new Android features this code provides is useful, please
15-
:star::star::star::star::star: my application. I have taken my free time on this project to
16-
*Hack for freedom with free software (TM, so to speak, as I like to say it)* by providing users and
17-
fellow Android developers alike with a quality code base.
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
19-
can help me reach out to my first **100-star** repository on GitHub.
20-
2112
## About the library
2213

2314
A file and directory chooser widget for Android that focuses on presenting an easy to configure lightweight UI.
@@ -42,17 +33,18 @@ media file processing minimal.
4233
### Feature set
4334

4435
Key features in the library include the following:
45-
* Easy to configure theming and UI display settings including icons and color choices
36+
* Easy to configure themes and UI display settings including icons and color choices
37+
(see [docs link below](https://github.com/maxieds/AndroidFileChooserLight#configuring-the-client-theme-and-ui-look-and-feel-properties))
4638
* Simple actions and extendable Java interface to select and filter files/directories
39+
(see [docs link below](https://github.com/maxieds/AndroidFileChooserLight#extending-file-types-for-filtering-and-sorting-purposes-in-the-picker-ui))
4740
* Allows client code to access many standard file system types on the Android device without
48-
complicated procedures and permissions headaches inherited by the new Android 11 policy changes
49-
* Exceptions and errors thrown at runtime extend the standard Java ``RuntimeException`` class for
50-
ease of handling. Many of these exceptions are just wrappers around data returned by a newly
51-
spawned file picker activity and do not necessarily indicate errors in the file selection process.
41+
complicated procedures and permissions issues inherited by the new Android 11 policy changes
5242

5343
### Screenshots of the library in action (Default theme)
5444

55-
<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" />
45+
<img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201112-052224.png" width="250" />
46+
<img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201113-134724.png" width="250" />
47+
<img src="https://raw.githubusercontent.com/maxieds/AndroidFilePickerLight/master/Screenshots/SampleApplicationDemo-ProgressBarDisplay.png" width="250" />
5648

5749
## Including the library for use in a client Android application
5850

@@ -63,9 +55,6 @@ library can be included in the client Android application:
6355
* Update the project *AndroidManifest.xml* file to extend the documents provider,
6456
request required permissions, and setup some helpful legacy file handling options for devices
6557
targeting Android platforms with SDK < Android OS 11.
66-
67-
Examples of using the library to pick files and directories from client Java code is also
68-
included in the detailed documentation in the next section.
6958

7059
### Application build.gradle modifications
7160

@@ -95,16 +84,6 @@ allprojects {
9584

9685
### Project manifest modifications
9786

98-
Near the top of the project manifest file, append the following permissions-related
99-
statements:
100-
```xml
101-
<!-- Core storage permissions required: -->
102-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="true" />
103-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:required="true" />
104-
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" android:required="false" />
105-
<uses-permission android:name="android.permission.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION" android:required="false" />
106-
<uses-permission android:name="android.permission.INTERNET" android:required="false" />
107-
```
10887
For applications targeting so-called legacy platforms, that is Android devices where the new
10988
Android 11 storage management options are not explicitly required, it is
11089
recommended for compatibility sake by the Google developer docs
@@ -263,64 +242,6 @@ FileChooserBuilder fcBuilderConfig = new FileChooserBuilder.getDirectoryChooserI
263242
.setRecyclerViewPrefetchThreadUpdateDelay(550L)
264243
```
265244

266-
### Extending file types for filtering and sorting purposes in the picker UI
267-
268-
Many other good file chooser libraries for Android implement extendable ways for users to filter,
269-
select and sort the files that are presented to the user. We choose to offer the same extendable
270-
functionality here while staying tightly coupled with more Java language standard constructs.
271-
272-
The following is an example of how to create a custom file filter for use with this library.
273-
The full interface specification is found in the source file
274-
[FileFilter.java](https://github.com/maxieds/AndroidFileChooserLight/blob/master/AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/FileFilter.java#L35):
275-
```java
276-
public static class FileFilterByRegex extends FileFilterBase {
277-
private Pattern patternSpec;
278-
public FileFilterByRegex(String regexPatternSpec, boolean inclExcl) {
279-
patternSpec = Pattern.compile(regexPatternSpec);
280-
setIncludeExcludeMatchesOption(inclExcl);
281-
}
282-
public boolean fileMatchesFilter(String fileAbsName) {
283-
if(patternSpec.matcher(fileAbsName).matches()) {
284-
return includeExcludeMatches == INCLUDE_FILES_IN_FILTER_PATTERN;
285-
}
286-
return includeExcludeMatches == EXCLUDE_FILES_IN_FILTER_PATTERN;
287-
}
288-
}
289-
```
290-
The main interface in the base class for the example above extends the stock Java ``FilenameFilter``
291-
interface. There is a difference in what our derived classes must implement. Namely, subject to the
292-
next defines, the code can decide whether to include or exclude the file matches based on whether the
293-
filename filter matches the user specified pattern:
294-
```java
295-
static final boolean INCLUDE_FILES_IN_FILTER_PATTERN = FileChooserBuilder.INCLUDE_FILES_IN_FILTER_PATTERN;
296-
static final boolean EXCLUDE_FILES_IN_FILTER_PATTERN = FileChooserBuilder.EXCLUDE_FILES_IN_FILTER_PATTERN;
297-
```
298-
Similarly, an overloaded sorting class that can be extended is sampled below:
299-
```java
300-
public static class FileItemsSortFunc implements Comparator<File> {
301-
public File[] sortFileItemsList(File[] folderContentsList) {
302-
Arrays.sort(folderContentsList, this);
303-
return folderContentsList;
304-
}
305-
@Override
306-
public int compare(File f1, File f2) {
307-
// default is standard lexicographical ordering (override the compare functor base classes for customized sorting):
308-
return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
309-
}
310-
}
311-
```
312-
Here is an example of how to utilize these customized classes with the library's core
313-
``FileChooserBuilder`` class instances:
314-
```java
315-
FileChooserBuilder fcConfig = new FileChooserBuilder();
316-
fcConfig.setFilesListSortCompareFunction(FileFilter.FileItemsSortFunc);
317-
318-
// Some defaults for convenience:
319-
fcConfig.filterByDefaultFileTypes(List<DefaultFileTypes> fileTypesList, boolean includeExcludeInList);
320-
fcConfig.filterByMimeTypes(List<String> fileTypesList, boolean includeExcludeInList);
321-
fcConfig.filterByRegex(String fileFilterPattern, boolean includeExcludeInList);
322-
```
323-
324245
### Configuring the client theme and UI look-and-feel properties
325246

326247
Now that we have the scheme for passing resources to the library to skin/color/custom theme its UI down,
@@ -374,21 +295,79 @@ fcbConfig.setCustomThemeStylizerConfig(customThemeBuilder);
374295
```
375296
Alternately, the exact colors for the theme can be specified explicitly using:
376297
```java
377-
public static final int COLOR_PRIMARY = 0;
378-
public static final int COLOR_PRIMARY_DARK = 1;
298+
public static final int COLOR_PRIMARY = 0; /* The main RecyclerView (file items list) background color */
299+
public static final int COLOR_PRIMARY_DARK = 1; /* Text color of the upper paths folder history views */
379300
public static final int COLOR_PRIMARY_VERY_DARK = 2;
380-
public static final int COLOR_ACCENT = 3;
381-
public static final int COLOR_ACCENT_MEDIUM = 4;
382-
public static final int COLOR_ACCENT_LIGHT = 5;
383-
public static final int COLOR_TOOLBAR_BG = 6;
384-
public static final int COLOR_TOOLBAR_FG = 7;
385-
public static final int COLOR_TOOLBAR_NAV = 8;
386-
public static final int COLOR_TOOLBAR_DIVIDER = 9;
301+
public static final int COLOR_ACCENT = 3; /* Text color of the file items list */
302+
public static final int COLOR_ACCENT_MEDIUM = 4; /* Text color of the Done/Cancel action buttons */
303+
public static final int COLOR_ACCENT_LIGHT = 5; /* Background color of the Done/Cancel action buttons navigation bar */
304+
public static final int COLOR_TOOLBAR_BG = 6; /* The darker background color of the topmost toolbar */
305+
public static final int COLOR_TOOLBAR_FG = 7; /* The lighter text color of the topmost toolbar */
306+
public static final int COLOR_TOOLBAR_NAV = 8; /* The background of the navigate to stock paths navigation bar (prefixed with "Navigate: ") */
307+
public static final int COLOR_TOOLBAR_DIVIDER = 9; /* The in-between divider color separating the top toolbar and lower navigation */
387308

388309
CustomThemeBuilder customThemeBuilder = new CustomThemeBuilder((Activity) myActivityInst)
389310
.setThemeColors(@ColorRes int[] colorsList);
390311
```
391312

313+
### Extending file types for filtering and sorting purposes in the picker UI
314+
315+
Many other good file chooser libraries for Android implement extendable ways for users to filter,
316+
select and sort the files that are presented to the user. We choose to offer the same extendable
317+
functionality here while staying tightly coupled with more Java language standard constructs.
318+
319+
The following is an example of how to create a custom file filter for use with this library.
320+
The full interface specification is found in the source file
321+
[FileFilter.java](https://github.com/maxieds/AndroidFileChooserLight/blob/master/AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/FileFilter.java#L35):
322+
```java
323+
public static class FileFilterByRegex extends FileFilterBase {
324+
private Pattern patternSpec;
325+
public FileFilterByRegex(String regexPatternSpec, boolean inclExcl) {
326+
patternSpec = Pattern.compile(regexPatternSpec);
327+
setIncludeExcludeMatchesOption(inclExcl);
328+
}
329+
public boolean fileMatchesFilter(String fileAbsName) {
330+
if(patternSpec.matcher(fileAbsName).matches()) {
331+
return includeExcludeMatches == INCLUDE_FILES_IN_FILTER_PATTERN;
332+
}
333+
return includeExcludeMatches == EXCLUDE_FILES_IN_FILTER_PATTERN;
334+
}
335+
}
336+
```
337+
The main interface in the base class for the example above extends the stock Java ``FilenameFilter``
338+
interface. There is a difference in what our derived classes must implement. Namely, subject to the
339+
next defines, the code can decide whether to include or exclude the file matches based on whether the
340+
filename filter matches the user specified pattern:
341+
```java
342+
static final boolean INCLUDE_FILES_IN_FILTER_PATTERN = FileChooserBuilder.INCLUDE_FILES_IN_FILTER_PATTERN;
343+
static final boolean EXCLUDE_FILES_IN_FILTER_PATTERN = FileChooserBuilder.EXCLUDE_FILES_IN_FILTER_PATTERN;
344+
```
345+
Similarly, an overloaded sorting class that can be extended is sampled below:
346+
```java
347+
public static class FileItemsSortFunc implements Comparator<File> {
348+
public File[] sortFileItemsList(File[] folderContentsList) {
349+
Arrays.sort(folderContentsList, this);
350+
return folderContentsList;
351+
}
352+
@Override
353+
public int compare(File f1, File f2) {
354+
// default is standard lexicographical ordering (override the compare functor base classes for customized sorting):
355+
return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
356+
}
357+
}
358+
```
359+
Here is an example of how to utilize these customized classes with the library's core
360+
``FileChooserBuilder`` class instances:
361+
```java
362+
FileChooserBuilder fcConfig = new FileChooserBuilder();
363+
fcConfig.setFilesListSortCompareFunction(FileFilter.FileItemsSortFunc);
364+
365+
// Some defaults for convenience:
366+
fcConfig.filterByDefaultFileTypes(List<DefaultFileTypes> fileTypesList, boolean includeExcludeInList);
367+
fcConfig.filterByMimeTypes(List<String> fileTypesList, boolean includeExcludeInList);
368+
fcConfig.filterByRegex(String fileFilterPattern, boolean includeExcludeInList);
369+
```
370+
392371
### Misc other useful utilities and customizations bundled with the main library
393372

394373
#### Displaying a visual linear bar style progress bar for slow directory loads
@@ -413,7 +392,7 @@ NFC tags on Android (see [the MFCToolLibrary](https://github.com/maxieds/MifareC
413392
its demo application). The core of the progress bar is
414393
shown by periodically posting Toast messages with a custom layout ``View``.
415394

416-
#### A custom (mostly all config options inclusive) GradientDrawable builder class (TODO)
395+
#### A custom (mostly all config options inclusive) GradientDrawable builder class (TODO -- Reserved for future uses)
417396

418397
The specifications (mostly collected as compendia from Android reference manuals) are reproduced as follows:
419398
```java

0 commit comments

Comments
 (0)