Fix file sharing to properly handle EXTRA_STREAM Parcelable

- Add support for EXTRA_STREAM as Parcelable URI instead of just String
- Check for streamParcelable first, then fall back to string extras
- Add logging to show both String and Parcelable EXTRA_STREAM values
- This should fix the issue where file sharing was receiving description text
instead of actual file content

The logs showed that EXTRA_STREAM was null as String but the file content
should be available as a Parcelable URI.
This commit is contained in:
Trevor
2025-08-19 11:56:30 -05:00
parent 6f4d7fd6b9
commit 71f626e8e0
@@ -715,9 +715,19 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
Intent.ACTION_SEND -> {
val streamExtra = intent.getStringExtra(Intent.EXTRA_STREAM);
val textExtra = intent.getStringExtra(Intent.EXTRA_TEXT);
Logger.i(TAG, "Share Received - EXTRA_STREAM: $streamExtra");
val streamParcelable = intent.getParcelableExtra<android.net.Uri>(Intent.EXTRA_STREAM);
Logger.i(TAG, "Share Received - EXTRA_STREAM (String): $streamExtra");
Logger.i(TAG, "Share Received - EXTRA_STREAM (Parcelable): $streamParcelable");
Logger.i(TAG, "Share Received - EXTRA_TEXT: $textExtra");
targetData = streamExtra ?: textExtra;
// Try to get the actual file content
targetData = when {
streamParcelable != null -> streamParcelable.toString()
streamExtra != null -> streamExtra
textExtra != null -> textExtra
else -> null
}
Logger.i(TAG, "Share Received - Final targetData: " + targetData);
}