element-hq / element-hq/element-android

EXTRA_TEXT is ignored when receiving EXTRA_STREAM Intent

Open
#3,637 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3.7k
Forks
917
PR merge metrics
No merged PRs in 30d

Description

#### Describe the bug
An app can create an `ACTION_SEND Intent` to share a file and/or text to another app. This `Intent` can provide an `InputStream` to get the actual file via `EXTRA_STREAM`. This `Intent` can also include `EXTRA_TEXT` to describe what the shared file is. Apps like K-9Mail, Gmail, Signal, etc. correctly handle this case and include both the file itself and the related text in the draft message. Element only attaches the file and ignores the text.

This is used in F-Droid to share apps. The text is the name/description of the app and the URL that points to the app's page on f-droid.org. The `EXTRA_STREAM` is the actual APK if available. Having all together means that the user can choose to share a message or the actual APK, depending on the receiving app.

#### To Reproduce

1. Create an `Intent` and open the Share chooser.
2. Select Element

Here's the code for creating the Share chooser:

```java
Intent intent = new Intent(Intent.ACTION_SEND);
Uri streamUri = getUri(context, packageName); // points to ContentProvider in F-Droid
// the streamUri could be any file that's easy to include, e.g. an image
intent.setType("application/zip");
intent.putExtra(Intent.EXTRA_STREAM, streamUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_SUBJECT, "Shared from F-Droid: " + app.name + ".apk");
intent.putExtra(Intent.EXTRA_TITLE, app.name + ".apk");
String extraText = String.format("%s (%s)\nhttps://f-droid.org/packages/%s/",
app.name, app.summary, app.packageName);
intent.putExtra(Intent.EXTRA_TEXT, extraText);
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.menu_share));
startActivity(chooserIntent);
```

This feature will also be included in F-Droid v1.14, go to Settings --> Manage installed apps --> Click on an app --> Click share.

#### Expected behavior

Should create a draft message with the text from `EXTRA_TEXT` with the data in `EXTRA_STREAM` there as an attachment.

#### Screenshots

![Screenshot_20210706-120943](https://user-images.githubusercontent.com/143465/124583970-36e3b580-de43-11eb-93e0-0b60d460b442.png)
![Screenshot_20210706-121441](https://user-images.githubusercontent.com/143465/124584258-8f1ab780-de43-11eb-9861-f6ee5501850a.png)

FYI @n8fr8

#### More info and discussion

* https://gitlab.com/fdroid/fdroidclient/-/merge_requests/929
* https://gitlab.com/fdroid/fdroidclient/-/issues/1918

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.