apache / apache/cordova-android

Feature Request: Support showDirectoryPicker and showSaveFilePicker in SystemWebChromeClient for WebView 132+

Open
#1,776 7 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

Description

# Feature Request

Modify the `onShowFileChooser` method within the `SystemWebChromeClient` class to implement corresponding folder selection or save functionality when the `fileChooserParams` parameter is set to MODE_OPEN_FOLDER or MODE_SAVE.

## Motivation Behind Feature

In WebView versions 132 and above, resolve the errors where JavaScript's `showDirectoryPicker` and `showSaveFilePicker` methods result in "The user aborted a request" responses.

## Feature Description

In WebView versions 132 and above, support has been introduced for the following new methods:
- [showDirectoryPicker](https://developer.mozilla.org/en-US/docs/Web/API/Window/showDirectoryPicker)
- [showSaveFilePicker](https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker)
- [showOpenFilePicker](https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker)

I have observed that `showOpenFilePicker` works correctly, but `showDirectoryPicker` and `showSaveFilePicker` return errors indicating "The user aborted a request".

Upon examining the source code, I found that the `onShowFileChooser` method within the `SystemWebChromeClient` class can support these functionalities based on the `fileChooserParams` parameter. However, Cordova currently lacks support for these features.

### Are there any drawbacks? Will this break anything for existing users?

It is important to consider potential compatibility issues with existing applications. The implementation should be carefully tested to ensure it does not introduce regressions.

## Alternatives or Workarounds

Proposed Solution:
Modify the `onShowFileChooser` method within the `SystemWebChromeClient` class so that it implements the appropriate folder selection or save operations when the `fileChooserParams` parameter indicates MODE_OPEN_FOLDER or MODE_SAVE.

However, I have not attempted this solution myself due to my limited expertise in this area.

Contributor guide

Open the contributing guide

Research direction

Start with the SystemWebChromeClient.onShowFileChooser method and inspect how its fileChooserParams values are handled. Confirm the Android WebView 132+ behavior for MODE_OPEN_FOLDER and MODE_SAVE, then verify that directory selection and saving work without regressing the existing file-picker behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, javascript
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
49/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.