Skip to content

Commit

Permalink
fix: Android browser component now works with multi-file selection. (#…
Browse files Browse the repository at this point in the history
…3788)

Ticket: #3787
  • Loading branch information
shannah authored Feb 25, 2024
1 parent 7126a57 commit d6000a5
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7982,10 +7982,29 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_SELECT_FILE || requestCode == FILECHOOSER_RESULTCODE) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (requestCode == REQUEST_SELECT_FILE) {
if (uploadMessage == null) {
return;
if (uploadMessage == null) return;
Uri[] results = null;

// Check that the response is a good one
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
// If there is not data, then we may have taken a photo
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();

if (clipData != null) {
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
} else if (dataString != null) {
results = new Uri[]{Uri.parse(dataString)};
}
}
}
uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));

uploadMessage.onReceiveValue(results);
uploadMessage = null;
}
}
Expand Down

0 comments on commit d6000a5

Please sign in to comment.