Repository navigation
fix(android): napplet file inputs open the file picker - #154
Merged
Merged
Conversation
Tapping an <input type="file"> in a napplet (lightertrek's CSV import) did nothing, and once it did open, a field with accept=".csv,text/csv" let no file be chosen. WebView shows a picker only when the app implements WebChromeClient.onShowFileChooser, which the napplet window did not, and FileChooserParams.createIntent passes only the first accept entry on, as a MIME type, so ".csv" matched no file. The window now implements onShowFileChooser, launching the system picker through an activity-result contract and handing the result to that window only. fileChooserIntent/acceptedMimeTypes map every accept entry: extensions to MIME types (CSV also under the names Android files it as), and anything unknown opens the picker to all files rather than none. SystemAskTest allowlists NappletActivity.kt for registerForActivityResult: the document picker asks Android for no permission.
Origami74
force-pushed
the
fix/napplet-file-chooser
branch
from
October 19, 2026 13:48
387d644 to
4d0bf09
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An
<input type="file">in a napplet opens the system file picker, and itsacceptlist is honoured.Why
WebView shows a picker only when the app implements
WebChromeClient.onShowFileChooser; the napplet window did not, so file fields did nothing. AndFileChooserParams.createIntentpasses only the firstacceptentry on, as a MIME type:accept=".csv,text/csv"asked for files of type ".csv" and nothing could be chosen.How
NappletActivitysets aWebChromeClientwithonShowFileChooser, launching the picker through an activity-result contract; the result goes to that window only, as a browser hands a picked file to the page that asked.fileChooserIntent/acceptedMimeTypesmap everyacceptentry: extensions to MIME types (CSV also under the names Android files it as), anything unknown opens the picker to all files rather than none.SystemAskTestallowlistsNappletActivity.ktforregisterForActivityResult: the document picker is user-initiated and asks Android for no permission.CHANGELOG.md[Unreleased]→ Fixed: "A napplet's file field opens the file picker."Testing
testDebugUnitTestpasses, includingSystemAskTest(which failed CI before the allowlist line) andFileChooserTest(3 unit tests);compileDebugKotlinpasses.text/comma-separated-values) is selectable.