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

Android and Web Share Target have different model for text sharing #81

Open
HenryJian opened this issue Apr 18, 2019 · 1 comment
Open

Comments

@HenryJian
Copy link

The current WST specs distinguishes between sharing a text file (WST v2) and sharing naked text (WST v1). However, Android doesn't make such distinction. An apk with a <data android:mimeType="text/plain"/> inside its <intent-filter> will respond to both text file sharing and naked text sharing.

This causes problems for installed web apps on Android (through "add to home screen" on Chrome):

  1. WST handles text files but not naked text:
    When a user shares naked text, the installed web app shows up in the list of share targets, , but it won't do anything because WST isn't expecting naked text.

  2. WST handles naked text but not text files:
    Similarly, when a user shares text files, the installed web app shows up in the list of share targets, but it won't do anything because WST isn't expecting text files.

One solution to this is the user agent convert between text files and naked text behind the scene.
For case 1, user agent writes the naked text to a text file. Caveat: filename will be empty.
For case 2, user agent reads the file to get the naked text.
Caveats:
First, if user shares multiple files, form data/url search param will have multiple entries with the same "share-text" key. Thus, on the receiving end, form_data.get("share-text") or url_search_param.get("share-text") will return an array, instead of a string.
Second, if data is encoded in url search parameter and user shares a big file, we may need to truncate file content because of url size limit

@ewilligers
Copy link
Collaborator

ewilligers commented Apr 26, 2019

For case 1, we can generate a temporary file name: share 123456 .txt

For case 2, we can append the text file contents into a single string, and truncate. This keeps with the existing Web Share design of the text field being a single string.

Truncation occurs if method=GET. We can add a warning to the spec (PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants