Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-621 android: Added multiple selection for filepicker #651

Merged

Conversation

MatusFiala
Copy link
Contributor

@MatusFiala MatusFiala commented Feb 7, 2019

Platforms affected

Android

What does this PR do?

Allows filepicker to select multiple files.

What testing has been done on this change?

Checked locally

Notes on testing on devices

Tested on following devices:

  • Moto G5 (Android 7.0)
  • Nexus 5X (Android 8.1)
  • Samsung Galaxy Tab S4 (Android 8.1)
  • Sony Xperia XZ2 Compact (Android 9.0)
  • Nexus 7 (Android 6.0.1)
  • Sony Xperia Z2 (Android 5.1.1)

The multiple file selection works basically, but behaves different on different devices/software.

Device difference:

On the Moto G5 and Samsung Tab it behaves like expected. Simply use long press (on file explorer, media-gallery, etc ) to start multiple selection.
The Nexus starts the filepicker with multiple selection enabled without using long-press.

Software-difference (on Samsung Tab):

  • normal file-picker: Works like expected
  • Google pictures-app: Starts with multiple selection enabled
  • Samsung Gallery: Multiple selection does not work when using as filepicker

Software-difference (on Sony Xperia XZ2 Compact + Z2):

  • normal file-picker: Works like expected
  • Google pictures-app: Starts with multiple selection enabled
  • Sony Picture Gallery: Multiple selection does not work when using as filepicker

The reason for this different behaviour is due to the different retun value of the filepicker-intent.
Normally when selecting one file, the intent writes the URL to the 'normal' data field, and when multiple files are selected to the clipData array. This works fine with the Samsung tab and Moto G5. But the intent of the Nexus always writes the first selected file to the data field, even though multiple files are selected. That's why I first check the clipData before the normal data.

Used this stackoverflow anser as inspiration: https://stackoverflow.com/questions/39390781/crosswalk-cordova-android-multiple-file-select

Update 25.03

Tested all nadorid versions from 5 - 9. Always the same behavior:

  • normal filepicker works perfect
  • brand specific file picker can only choose 1 object
  • Google Fotos has multiple selection always activated

Checklist

  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

@brodycj
Copy link
Contributor

brodycj commented Feb 11, 2019

I would favor a solution where onShowFileChooser would be handled by one or more plugins.

@dpogue
Copy link
Member

dpogue commented Feb 11, 2019

You should not need plugins for <input type="file" multiple> to work. That's basic web functionality

@brodycj
Copy link
Contributor

brodycj commented Feb 11, 2019

Right.

So the Android WebChromeClient interface provides us a way to customize how we should handle this functionality, and we blindly start a built-in file chooser. I wonder if we should consider a way to do this in a more flexible manner?

@artuska
Copy link

artuska commented Feb 18, 2019

When this PR will be merged?

@janpio
Copy link
Member

janpio commented Feb 18, 2019

When it is fully tested and reviewed. Can you confirm this feature works (on all Android versions) and doesn't break anything else? Having this information would make testing much easier.

@KeySeeDev
Copy link

KeySeeDev commented Feb 20, 2019

Works great on android 8.1.0

@MatusFiala
Copy link
Contributor Author

What do you need for a merge? Do you need another tests for Androdi 5, 6 and 9 (7 and 8.1 already tested)? How can I help?

EtienneLem added a commit to missive/cordova-android that referenced this pull request Mar 8, 2019
Copy link
Member

@dpogue dpogue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but I agree we'd need confirmation of testing on various Android versions (and ideally various phone brands too - Google, Samsung, LG, etc.)

@dpogue dpogue added this to the 8.0.1 milestone Mar 15, 2019
@MatusFiala
Copy link
Contributor Author

Tested on Sony Xperia XZ2 Compact (Android 9).
Same behavior as the Samsung Tab.
Normal filepicker works, brand specific filepicker does not support multiple selection.

I am gonna test Android 5 and 6 next week. Just need some devices.

@MatusFiala
Copy link
Contributor Author

Finally found some devices with Android 5 and 6.
Tested devices:

  • Nexus 7 (Android 6.0.1)
  • Sony Xperia Z2 (Android 5.1.1)

Same behaviour as every other device.

  • normal filepicker works perfect
  • brand specific file picker can only choose 1 object
  • Google Fotos has multiple selection always activated

@erisu erisu merged commit 42c0cba into apache:master Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants