Skip to content

Commit b16d6df

Browse files
Added checkbox color customization and updated to v10.1.3
1 parent 66af431 commit b16d6df

7 files changed

Lines changed: 137 additions & 22 deletions

File tree

Readme.md

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If this library helps you, please consider supporting my open-source work.
4949
## Table of Contents
5050

5151
- [Overview](#overview)
52-
- [What is new in v10.1.2](#what-is-new-in-v1012)
52+
- [What is new in v10](#what-is-new-in-v10)
5353
- [Important Android storage reality](#important-android-storage-reality)
5454
- [Requirements](#requirements)
5555
- [Installation](#installation)
@@ -71,7 +71,7 @@ If this library helps you, please consider supporting my open-source work.
7171
- [Handling Android 14+ partial photo/video access](#handling-android-14-partial-photovideo-access)
7272
- [Play Store safe integration options](#play-store-safe-integration-options)
7373
- [Troubleshooting](#troubleshooting)
74-
- [Migration guide from v9.x to v10.1.2](#migration-guide-from-v9x-to-v1012)
74+
- [Migration guide from v9.x to v10.1.3](#migration-guide-from-v9x-to-v1013)
7575
- [Security and privacy recommendations](#security-and-privacy-recommendations)
7676
- [FAQ](#faq)
7777
- [Contributing](#contributing)
@@ -105,9 +105,13 @@ dialog.setDialogSelectionListener(files -> {
105105
106106
---
107107

108-
## What is new in v10.1.2
108+
## What is new in v10
109109

110-
Version `10.1.2` focuses on modern Android support, stability, clearer storage behavior, dialog customization, and advanced file filtering.
110+
Version `10.X.X` focuses on modern Android support, stability, clearer storage behavior, dialog customization, and advanced file filtering.
111+
112+
### New in v10.1.3
113+
114+
- From `v10.1.3`, FilePicker supports checkbox color customization through `DialogProperties`.
111115

112116
### New in v10.1.2
113117

@@ -198,7 +202,7 @@ Official references:
198202

199203
## Installation
200204

201-
FilePicker v10.1.1 is available through **Maven Central** and **JitPack**.
205+
FilePicker v10.1.3 is available through **Maven Central** and **JitPack**.
202206

203207
Recommended installation method: **Maven Central**
204208
Alternative installation method: **JitPack**
@@ -313,15 +317,15 @@ Add the FilePicker dependency inside the `dependencies` block.
313317

314318
```gradle
315319
dependencies {
316-
implementation "io.github.tutorialsandroid:filepicker:10.1.2"
320+
implementation "io.github.tutorialsandroid:filepicker:10.1.3"
317321
}
318322
```
319323

320324
### Kotlin DSL - app/build.gradle.kts
321325

322326
```kotlin
323327
dependencies {
324-
implementation("io.github.tutorialsandroid:filepicker:10.1.2")
328+
implementation("io.github.tutorialsandroid:filepicker:10.1.3")
325329
}
326330
```
327331

@@ -479,15 +483,15 @@ Add the dependency inside the `dependencies` block.
479483

480484
```gradle
481485
dependencies {
482-
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.2"
486+
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.3"
483487
}
484488
```
485489

486490
### Kotlin DSL - app/build.gradle.kts
487491

488492
```kotlin
489493
dependencies {
490-
implementation("com.github.TutorialsAndroid:FilePicker:v10.1.2")
494+
implementation("com.github.TutorialsAndroid:FilePicker:v10.1.3")
491495
}
492496
```
493497

@@ -526,13 +530,13 @@ android {
526530
For production apps, Maven Central is recommended:
527531

528532
```gradle
529-
implementation "io.github.tutorialsandroid:filepicker:10.1.2"
533+
implementation "io.github.tutorialsandroid:filepicker:10.1.3"
530534
```
531535

532536
Use JitPack only if you specifically want to fetch the library directly from GitHub:
533537

534538
```gradle
535-
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.2"
539+
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.3"
536540
```
537541

538542
---
@@ -578,15 +582,15 @@ Only use the old `allprojects` method if your project is very old and does not h
578582

579583
```gradle
580584
dependencies {
581-
implementation "io.github.tutorialsandroid:filepicker:10.1.2"
585+
implementation "io.github.tutorialsandroid:filepicker:10.1.3"
582586
}
583587
```
584588

585589
### JitPack
586590

587591
```gradle
588592
dependencies {
589-
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.2"
593+
implementation "com.github.TutorialsAndroid:FilePicker:v10.1.3"
590594
}
591595
```
592596

@@ -924,6 +928,46 @@ FilePickerDialog dialog = new FilePickerDialog(
924928

925929
---
926930

931+
## Customizing checkbox colors
932+
933+
From `v10.1.3`, FilePicker supports checkbox color customization through `DialogProperties`.
934+
935+
This is useful when the default checkbox colors do not match your app theme, or when the unchecked checkbox blends into a white/light background.
936+
937+
```java
938+
import android.graphics.Color;
939+
940+
DialogProperties properties = new DialogProperties();
941+
942+
properties.selection_mode = DialogConfigs.MULTI_MODE;
943+
properties.selection_type = DialogConfigs.DIR_SELECT;
944+
945+
// Checked checkbox fill color
946+
properties.checkbox_checked_color = Color.parseColor("#6750A4");
947+
948+
// Unchecked checkbox outer/background color
949+
properties.checkbox_unchecked_color = Color.parseColor("#6750A4");
950+
951+
// Tick/checkmark color shown when checked
952+
properties.checkbox_checkmark_color = Color.WHITE;
953+
954+
// Inner color shown when unchecked
955+
properties.checkbox_unchecked_inner_color = Color.parseColor("#F3E8FF");
956+
957+
FilePickerDialog dialog = new FilePickerDialog(MainActivity.this, properties);
958+
dialog.setTitle("Select Directory");
959+
dialog.show();
960+
```
961+
962+
### Notes
963+
964+
- `checkbox_checked_color` controls the selected checkbox fill color.
965+
- `checkbox_unchecked_color` controls the unchecked checkbox outer/background color.
966+
- `checkbox_checkmark_color` controls the tick/checkmark color.
967+
- `checkbox_unchecked_inner_color` controls the inner unchecked color.
968+
- If `checkbox_checked_color` is not set, FilePicker uses the existing `R.color.colorAccent` fallback.
969+
- This works for file selection, directory selection, and file + directory selection.
970+
927971
## Changing dialog width and height
928972

929973
This section answers a common GitHub issue/question: **"Change Width and Height"**.
@@ -1908,7 +1952,7 @@ Possible causes:
19081952

19091953
---
19101954

1911-
## Migration guide from v9.x to v10.1.2
1955+
## Migration guide from v9.x to v10.1.3
19121956

19131957
### 1. Update dependency
19141958

@@ -1965,7 +2009,7 @@ Only use `MANAGE_EXTERNAL_STORAGE` when the answer is policy-safe.
19652009

19662010
### 5. Update dialog size usage if needed
19672011

1968-
If your old app looked too narrow on landscape, tablet, foldable, or ultra-wide screens, use the v10.1.2 sizing API:
2012+
If your old app looked too narrow on landscape, tablet, foldable, or ultra-wide screens, use the v10.1.3 sizing API:
19692013

19702014
```java
19712015
dialog.setDialogSizeByPercent(0.85f, 0.75f);

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ group='com.github.TutorialsAndroid'
44

55
ext {
66
PUBLISH_GROUP_ID = 'io.github.tutorialsandroid'
7-
PUBLISH_VERSION = '10.1.2'
7+
PUBLISH_VERSION = '10.1.3'
88
PUBLISH_ARTIFACT_ID = 'filepicker'
99
PUBLISH_DESCRIPTION = 'Android Library to select files/directories from Device Storage'
1010
PUBLISH_URL = 'https://github.com/TutorialsAndroid/FilePicker'

library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public View getView(final int position, View convertView, ViewGroup parent) {
7272
applySelectionAnimation(convertView, item);
7373
bindIcon(holder, item);
7474
bindTexts(holder, item, isParentRow);
75+
holder.checkbox.setCheckboxColors(
76+
properties.checkbox_checked_color,
77+
properties.checkbox_unchecked_color,
78+
properties.checkbox_checkmark_color,
79+
properties.checkbox_unchecked_inner_color
80+
);
7581

7682
holder.checkbox.setOnCheckedChangedListener(null);
7783
holder.checkbox.setVisibility(isSelectable ? View.VISIBLE : View.INVISIBLE);

library/src/main/java/com/developer/filepicker/model/DialogProperties.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.developer.filepicker.model;
22

3+
import android.graphics.Color;
4+
35
import java.io.File;
46

57
/**
@@ -9,6 +11,11 @@
911
*/
1012
public class DialogProperties {
1113

14+
/**
15+
* Internal sentinel used when a color should fall back to the library default.
16+
*/
17+
public static final int COLOR_NOT_SET = Integer.MIN_VALUE;
18+
1219
public int selection_mode;
1320
public int selection_type;
1421
public File root;
@@ -43,6 +50,30 @@ public class DialogProperties {
4350
*/
4451
public long min_file_size = -1L;
4552

53+
/**
54+
* Checked checkbox fill color.
55+
*
56+
* Default COLOR_NOT_SET means the picker will use R.color.colorAccent.
57+
*/
58+
public int checkbox_checked_color = COLOR_NOT_SET;
59+
60+
/**
61+
* Unchecked checkbox outer/background color.
62+
*/
63+
public int checkbox_unchecked_color = Color.parseColor("#C1C1C1");
64+
65+
/**
66+
* Checked checkbox tick/checkmark color.
67+
*/
68+
public int checkbox_checkmark_color = Color.WHITE;
69+
70+
/**
71+
* Unchecked checkbox inner fill color.
72+
*
73+
* Change this if the unchecked checkbox blends into a white/light background.
74+
*/
75+
public int checkbox_unchecked_inner_color = Color.WHITE;
76+
4677
public DialogProperties() {
4778
selection_mode = DialogConfigs.SINGLE_MODE;
4879
selection_type = DialogConfigs.FILE_SELECT;
@@ -55,5 +86,11 @@ public DialogProperties() {
5586
// v10.1.2 file size filters
5687
max_file_size = -1L;
5788
min_file_size = -1L;
89+
90+
// v10.1.3 checkbox color customization
91+
checkbox_checked_color = COLOR_NOT_SET;
92+
checkbox_unchecked_color = Color.parseColor("#C1C1C1");
93+
checkbox_checkmark_color = Color.WHITE;
94+
checkbox_unchecked_inner_color = Color.WHITE;
5895
}
5996
}

library/src/main/java/com/developer/filepicker/widget/MaterialCheckbox.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.view.View;
1212

1313
import com.developer.filepicker.R;
14+
import com.developer.filepicker.model.DialogProperties;
1415

1516
/**
1617
* Lightweight custom checkbox used by the file picker rows.
@@ -24,6 +25,11 @@ public class MaterialCheckbox extends View {
2425
private boolean checked;
2526
private OnCheckedChangeListener onCheckedChangeListener;
2627

28+
private int checkedColor = DialogProperties.COLOR_NOT_SET;
29+
private int uncheckedColor = Color.parseColor("#C1C1C1");
30+
private int checkmarkColor = Color.WHITE;
31+
private int uncheckedInnerColor = Color.WHITE;
32+
2733
public MaterialCheckbox(Context context) {
2834
super(context);
2935
initView();
@@ -67,22 +73,22 @@ protected void onDraw(Canvas canvas) {
6773

6874
if (checked) {
6975
paint.setStyle(Paint.Style.FILL);
70-
paint.setColor(getColorCompat(R.color.colorAccent));
76+
paint.setColor(resolveCheckedColor());
7177
canvas.drawRoundRect(bounds, minDim / 8f, minDim / 8f, paint);
7278

73-
paint.setColor(Color.WHITE);
79+
paint.setColor(checkmarkColor);
7480
paint.setStrokeWidth(Math.max(2f, minDim / 10f));
7581
paint.setStyle(Paint.Style.STROKE);
7682
paint.setStrokeCap(Paint.Cap.ROUND);
7783
paint.setStrokeJoin(Paint.Join.ROUND);
7884
canvas.drawPath(tick, paint);
7985
} else {
8086
paint.setStyle(Paint.Style.FILL);
81-
paint.setColor(Color.parseColor("#C1C1C1"));
87+
paint.setColor(uncheckedColor);
8288
canvas.drawRoundRect(bounds, minDim / 8f, minDim / 8f, paint);
8389

8490
bounds.set(minDim / 5f, minDim / 5f, minDim - (minDim / 5f), minDim - (minDim / 5f));
85-
paint.setColor(Color.WHITE);
91+
paint.setColor(uncheckedInnerColor);
8692
canvas.drawRect(bounds, paint);
8793
}
8894
}
@@ -121,6 +127,27 @@ public void setOnCheckedChangedListener(OnCheckedChangeListener onCheckedChangeL
121127
this.onCheckedChangeListener = onCheckedChangeListener;
122128
}
123129

130+
/**
131+
* Applies checkbox colors from DialogProperties.
132+
*/
133+
public void setCheckboxColors(int checkedColor,
134+
int uncheckedColor,
135+
int checkmarkColor,
136+
int uncheckedInnerColor) {
137+
this.checkedColor = checkedColor;
138+
this.uncheckedColor = uncheckedColor;
139+
this.checkmarkColor = checkmarkColor;
140+
this.uncheckedInnerColor = uncheckedInnerColor;
141+
invalidate();
142+
}
143+
144+
private int resolveCheckedColor() {
145+
if (checkedColor == DialogProperties.COLOR_NOT_SET) {
146+
return getColorCompat(R.color.colorAccent);
147+
}
148+
return checkedColor;
149+
}
150+
124151
private int getColorCompat(int colorRes) {
125152
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
126153
return getResources().getColor(colorRes, getContext().getTheme());

sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.developer.filepicker.file"
99
minSdkVersion 23
1010
targetSdkVersion 37
11-
versionCode 17
12-
versionName "10.1.2"
11+
versionCode 18
12+
versionName "10.1.3"
1313
}
1414
buildTypes {
1515
release {

sample/src/main/java/com/developer/filepicker/file/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.Manifest;
66
import android.content.Intent;
77
import android.content.pm.PackageManager;
8+
import android.graphics.Color;
89
import android.net.Uri;
910
import android.os.Build;
1011
import android.os.Bundle;

0 commit comments

Comments
 (0)