Skip to content

Commit 1730be0

Browse files
Added support for programmatic dialog sizing and updated version to 10.1.1
1 parent 99b3b54 commit 1730be0

5 files changed

Lines changed: 304 additions & 13 deletions

File tree

Readme.md

Lines changed: 215 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
**A lightweight Android file and directory picker library for Java/Kotlin Android apps.**
88

99
[![API](https://img.shields.io/badge/API-23%2B-brightgreen.svg?style=flat)](#requirements)
10-
[![Version](https://img.shields.io/badge/version-10.0.0-blue.svg)](#installation)
10+
[![Version](https://img.shields.io/badge/version-10.1.1-blue.svg)](#installation)
1111
[![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg)](https://opensource.org/licenses/Apache-2.0)
1212
[![Maven Central](https://img.shields.io/badge/Maven%20Central-FilePicker-blue)](#installation)
1313
[![AndroidX](https://img.shields.io/badge/AndroidX-supported-brightgreen)](#requirements)
@@ -21,7 +21,7 @@ Select files, folders, or both from device storage with single-selection and mul
2121
## Table of Contents
2222

2323
- [Overview](#overview)
24-
- [What is new in v10.0.0](#what-is-new-in-v1000)
24+
- [What is new in v10.1.1](#what-is-new-in-v1011)
2525
- [Important Android storage reality](#important-android-storage-reality)
2626
- [Requirements](#requirements)
2727
- [Installation](#installation)
@@ -30,6 +30,7 @@ Select files, folders, or both from device storage with single-selection and mul
3030
- [Manifest setup](#manifest-setup)
3131
- [Basic usage](#basic-usage)
3232
- [Customizing dialog theme](#customizing-dialog-theme)
33+
- [Changing dialog width and height](#changing-dialog-width-and-height)
3334
- [Complete Java example](#complete-java-example)
3435
- [DialogProperties reference](#dialogproperties-reference)
3536
- [DialogConfigs reference](#dialogconfigs-reference)
@@ -42,7 +43,7 @@ Select files, folders, or both from device storage with single-selection and mul
4243
- [Handling Android 14+ partial photo/video access](#handling-android-14-partial-photovideo-access)
4344
- [Play Store safe integration options](#play-store-safe-integration-options)
4445
- [Troubleshooting](#troubleshooting)
45-
- [Migration guide from v9.x to v10.0.0](#migration-guide-from-v9x-to-v1000)
46+
- [Migration guide from v9.x to v10.1.1](#migration-guide-from-v9x-to-v1011)
4647
- [Security and privacy recommendations](#security-and-privacy-recommendations)
4748
- [FAQ](#faq)
4849
- [Contributing](#contributing)
@@ -76,9 +77,17 @@ dialog.setDialogSelectionListener(files -> {
7677
7778
---
7879

79-
## What is new in v10.0.0
80+
## What is new in v10.1.1
8081

81-
Version `10.0.0` focuses on modern Android support, stability, and clearer storage behavior.
82+
Version `10.1.1` focuses on modern Android support, stability, clearer storage behavior, and better dialog customization.
83+
84+
### New in v10.1.1
85+
86+
- Added programmatic dialog width and height customization.
87+
- Added responsive percentage-based dialog sizing for tablets, foldables, landscape mode, and ultra-wide screens.
88+
- Added direct layout-param based sizing support using `ViewGroup.LayoutParams.MATCH_PARENT`, `WRAP_CONTENT`, or exact pixel values.
89+
- Documented the GitHub issue solution for changing dialog width and height before showing the picker.
90+
- Improved README examples for dialog theme and dialog size customization.
8291

8392
### Core improvements
8493

@@ -141,7 +150,7 @@ Official references:
141150
| Returns | Direct file paths |
142151
| Best use case | File manager, document manager, backup/restore, local file tools, developer utilities |
143152

144-
> **minSdk note:** FilePicker v10.0.0 is documented for `minSdk 23`. Android 5.0 and 5.1 support has been removed from this README and should not be advertised in badges, Gradle metadata, or release notes.
153+
> **minSdk note:** FilePicker v10.1.1 is documented for `minSdk 23`. Android 5.0 and 5.1 support has been removed from this README and should not be advertised in badges, Gradle metadata, or release notes.
145154
146155
---
147156

@@ -165,7 +174,7 @@ Add the dependency in your app module:
165174

166175
```gradle
167176
dependencies {
168-
implementation "io.github.tutorialsandroid:filepicker:10.0.0"
177+
implementation "io.github.tutorialsandroid:filepicker:10.1.1"
169178
}
170179
```
171180

@@ -508,6 +517,146 @@ FilePickerDialog dialog = new FilePickerDialog(
508517
- For deep UI changes such as row layout, icon size, text sizes, or spacing, customize the library layout resources in your app or fork the library.
509518
- Do not use a full-screen activity theme as the dialog theme unless you intentionally want full-screen behavior.
510519

520+
---
521+
522+
## Changing dialog width and height
523+
524+
This section answers a common GitHub issue/question: **"Change Width and Height"**.
525+
526+
From `v10.1.1`, `FilePickerDialog` supports programmatic dialog sizing. This is useful for:
527+
528+
- Ultra-wide screens
529+
- Landscape mode
530+
- Tablets
531+
- Foldables
532+
- ChromeOS devices
533+
- Custom kiosk-style layouts
534+
- Apps that need a wider picker UI than the default Android dialog width
535+
536+
You should call the size method **before** `dialog.show()`.
537+
538+
### Set size using screen percentage
539+
540+
Use this when you want responsive sizing across different screen sizes.
541+
542+
```java
543+
DialogProperties properties = new DialogProperties();
544+
545+
FilePickerDialog dialog = new FilePickerDialog(MainActivity.this, properties);
546+
547+
dialog.setTitle("Select File");
548+
dialog.setPositiveBtnName("Select");
549+
dialog.setNegativeBtnName("Cancel");
550+
551+
// 85% of screen width and 75% of screen height
552+
dialog.setDialogSizeByPercent(0.85f, 0.75f);
553+
554+
dialog.show();
555+
```
556+
557+
### Set width only and keep default height
558+
559+
```java
560+
dialog.setDialogSizeByPercent(0.90f, -1f);
561+
dialog.show();
562+
```
563+
564+
### Set height only and keep default width
565+
566+
```java
567+
dialog.setDialogSizeByPercent(-1f, 0.75f);
568+
dialog.show();
569+
```
570+
571+
### Use direct layout params
572+
573+
Use this when you want exact Android layout behavior.
574+
575+
```java
576+
dialog.setDialogSize(
577+
ViewGroup.LayoutParams.MATCH_PARENT,
578+
ViewGroup.LayoutParams.WRAP_CONTENT
579+
);
580+
581+
dialog.show();
582+
```
583+
584+
Required import:
585+
586+
```java
587+
import android.view.ViewGroup;
588+
```
589+
590+
### Use exact pixel values
591+
592+
```java
593+
dialog.setDialogSize(1200, 700);
594+
dialog.show();
595+
```
596+
597+
> Pixel values are not recommended for normal apps because they may look different on different screen densities. Prefer `setDialogSizeByPercent()` for responsive UI.
598+
599+
### Complete width/height example
600+
601+
```java
602+
DialogProperties properties = new DialogProperties();
603+
properties.selection_mode = DialogConfigs.SINGLE_MODE;
604+
properties.selection_type = DialogConfigs.FILE_SELECT;
605+
properties.root = new File(DialogConfigs.DEFAULT_DIR);
606+
properties.offset = new File(DialogConfigs.DEFAULT_DIR);
607+
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
608+
properties.extensions = null;
609+
properties.show_hidden_files = false;
610+
611+
FilePickerDialog dialog = new FilePickerDialog(MainActivity.this, properties);
612+
613+
dialog.setTitle("Select a File");
614+
dialog.setPositiveBtnName("Select");
615+
dialog.setNegativeBtnName("Cancel");
616+
617+
// Makes the dialog wider on landscape, tablet, foldable, and ultra-wide displays.
618+
dialog.setDialogSizeByPercent(0.85f, 0.75f);
619+
620+
dialog.setDialogSelectionListener(files -> {
621+
for (String path : files) {
622+
// Use selected path
623+
}
624+
});
625+
626+
dialog.show();
627+
```
628+
629+
### Dialog size API
630+
631+
| Method | Description |
632+
|---|---|
633+
| `setDialogSize(int width, int height)` | Sets dialog width and height using Android layout params or exact pixel values |
634+
| `setDialogSizeByPercent(float widthPercent, float heightPercent)` | Sets dialog width and height using screen percentage |
635+
| `ViewGroup.LayoutParams.MATCH_PARENT` | Makes the dialog use maximum available width/height |
636+
| `ViewGroup.LayoutParams.WRAP_CONTENT` | Keeps default content-based size |
637+
| `-1f` in percent method | Keeps that dimension unchanged/default |
638+
639+
### Recommended values
640+
641+
| Use case | Recommended value |
642+
|---|---|
643+
| Normal phones | Default dialog size |
644+
| Landscape phones | `setDialogSizeByPercent(0.90f, 0.80f)` |
645+
| Tablets | `setDialogSizeByPercent(0.75f, 0.80f)` |
646+
| Ultra-wide screens | `setDialogSizeByPercent(0.85f, 0.75f)` |
647+
| Full-width picker | `setDialogSize(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)` |
648+
649+
### Important notes
650+
651+
- Call `setDialogSize()` or `setDialogSizeByPercent()` before `dialog.show()`.
652+
- If called after `dialog.show()`, the dialog should update immediately.
653+
- Use percentage-based sizing for responsive UI.
654+
- Use direct layout params only when you need exact Android layout behavior.
655+
- Avoid hardcoded pixels unless you are building for a fixed-size device.
656+
- Dialog sizing changes the outer dialog window size, not the internal row layout.
657+
- For deeper layout changes such as row height, icon size, padding, or text size, customize the library XML layout resources or fork the UI layer.
658+
659+
511660
---
512661

513662
## Complete Java example
@@ -583,6 +732,10 @@ public class MainActivity extends AppCompatActivity {
583732
filePickerDialog.setPositiveBtnName("Select");
584733
filePickerDialog.setNegativeBtnName("Cancel");
585734

735+
// Optional v10.1.1 feature:
736+
// Make the dialog wider/taller on landscape, tablet, foldable, or ultra-wide screens.
737+
filePickerDialog.setDialogSizeByPercent(0.85f, 0.75f);
738+
586739
filePickerDialog.setDialogSelectionListener(files -> {
587740
for (String path : files) {
588741
Toast.makeText(this, "Selected: " + path, Toast.LENGTH_SHORT).show();
@@ -1001,6 +1154,24 @@ If your APK is used internally, enterprise-side-loaded, or outside Google Play,
10011154

10021155
## Troubleshooting
10031156

1157+
### Dialog looks too small on tablets, landscape, or ultra-wide screens
1158+
1159+
Use the v10.1.1 dialog sizing API before showing the picker:
1160+
1161+
```java
1162+
dialog.setDialogSizeByPercent(0.85f, 0.75f);
1163+
dialog.show();
1164+
```
1165+
1166+
For full-width behavior:
1167+
1168+
```java
1169+
dialog.setDialogSize(
1170+
ViewGroup.LayoutParams.MATCH_PARENT,
1171+
ViewGroup.LayoutParams.WRAP_CONTENT
1172+
);
1173+
```
1174+
10041175
### Dialog opens but folder is empty
10051176

10061177
Possible causes:
@@ -1067,12 +1238,12 @@ Possible causes:
10671238

10681239
---
10691240

1070-
## Migration guide from v9.x to v10.0.0
1241+
## Migration guide from v9.x to v10.1.1
10711242

10721243
### 1. Update dependency
10731244

10741245
```gradle
1075-
implementation "io.github.tutorialsandroid:filepicker:10.0.0"
1246+
implementation "io.github.tutorialsandroid:filepicker:10.1.1"
10761247
```
10771248

10781249
### 2. Replace old permission code
@@ -1122,7 +1293,24 @@ Ask yourself:
11221293

11231294
Only use `MANAGE_EXTERNAL_STORAGE` when the answer is policy-safe.
11241295

1125-
### 5. Test on real devices
1296+
### 5. Update dialog size usage if needed
1297+
1298+
If your old app looked too narrow on landscape, tablet, foldable, or ultra-wide screens, use the v10.1.1 sizing API:
1299+
1300+
```java
1301+
dialog.setDialogSizeByPercent(0.85f, 0.75f);
1302+
```
1303+
1304+
or:
1305+
1306+
```java
1307+
dialog.setDialogSize(
1308+
ViewGroup.LayoutParams.MATCH_PARENT,
1309+
ViewGroup.LayoutParams.WRAP_CONTENT
1310+
);
1311+
```
1312+
1313+
### 6. Test on real devices
11261314

11271315
Test at least:
11281316

@@ -1197,6 +1385,23 @@ Modern Android restricts access to many app-private and protected directories. E
11971385

11981386
No.
11991387

1388+
### Can I change dialog width and height?
1389+
1390+
Yes. From v10.1.1, use:
1391+
1392+
```java
1393+
dialog.setDialogSizeByPercent(0.85f, 0.75f);
1394+
```
1395+
1396+
or:
1397+
1398+
```java
1399+
dialog.setDialogSize(
1400+
ViewGroup.LayoutParams.MATCH_PARENT,
1401+
ViewGroup.LayoutParams.WRAP_CONTENT
1402+
);
1403+
```
1404+
12001405
### Does this library upload files?
12011406

12021407
No. This library only provides local file/folder selection UI. Your app decides what to do with selected paths.

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.0.0'
7+
PUBLISH_VERSION = '10.1.1'
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'

0 commit comments

Comments
 (0)