You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When opening the native file chooser of android from an html with multiple accept mime types, only the first mime type is being used to filter the allowed files.
For example, <input type="file" accept="image/png, image/gif" /> will only allow you to choose a file of type png and not gif.
In addition, if the "accept" attribute is not specified at all, no files can be selected at all.
What is expected to happen?
When there are multiple mime types in the accept attribute, all of mime types should be allowed to be chosen from the native file chooser.
What does actually happen?
Only the first mime type is accepted and all other file types are disabled and can't be chosen.
Information
To reproduce, just create a new cordova-android project, in the index.html file, add the following: <input type="file" accept="image/png, image/gif" />
Run the project on a device of emulator and try to select a gif file.
Command or Code
The issue is in the SystemWebChromeClient class, the accept types need to be added as extra arguments to the intent that is bring created by the fileChooserParams.
i.e., the following should fix the issue: intent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
The function with the fixed code should look like this:
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
....
Intent intent = fileChooserParams.createIntent();
if(fileChooserParams.getAcceptTypes() != null) {
intent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
}
....
}
Problem
When opening the native file chooser of android from an html with multiple accept mime types, only the first mime type is being used to filter the allowed files.
For example,
<input type="file" accept="image/png, image/gif" />
will only allow you to choose a file of type png and not gif.In addition, if the "accept" attribute is not specified at all, no files can be selected at all.
What is expected to happen?
When there are multiple mime types in the accept attribute, all of mime types should be allowed to be chosen from the native file chooser.
What does actually happen?
Only the first mime type is accepted and all other file types are disabled and can't be chosen.
Information
To reproduce, just create a new cordova-android project, in the index.html file, add the following:
<input type="file" accept="image/png, image/gif" />
Run the project on a device of emulator and try to select a gif file.
Command or Code
The issue is in the SystemWebChromeClient class, the accept types need to be added as extra arguments to the intent that is bring created by the fileChooserParams.
i.e., the following should fix the issue:
intent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
The function with the fixed code should look like this:
Environment, Platform, Device
Cordova-android: 8.1.0
Cordova-CLI: 9.0.0
Device: Samsung Galaxy S9
Checklist
The text was updated successfully, but these errors were encountered: