apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.67k stars 1.54k forks source link

Restore selected files when Activity restores after being killed #1536

Open tunnela opened 1 year ago

tunnela commented 1 year ago

Feature Request

Motivation Behind Feature

Currently, if you select file(s) via the <input type="file"> element and the system decides to kill the Activity, the selected files will not be reachable when the Activity restores. The problem can be reproduced by enabling Android > Settings > Developer Options > Don't keep activities.

Feature Description

A new CordovaPlugin is needed, which correctly returns the selected files with Cordova's resume event. CordovaPlugin at:

SystemWebChromeClient.java#L231-L253

...needs to be replaced with this new CordovaPlugin.

Alternatives or Workarounds

I created a new Cordova plugin to solve this problem. See it here:

https://github.com/tunnela/cordova-plugin-pending-files

However, the implementation is not optimal, as I had to create a new class that extends the SystemWebChromeClient class of the cordova-android package and which is set as the new WebChromeClient when the my plugin is initialized. This may cause unexpected behavior. Therefore the new CordovaPlugin should be part of the cordova-android.

tunnela commented 1 year ago

Does anyone have time to implement this feature based on my https://github.com/tunnela/cordova-plugin-pending-files plugin? I'm currently so overwhelmed with other projects that it would be great if someone else could do it. Thanks!