android: sharing of files with plain text (#3011)

This commit is contained in:
Stanislav Dmitrenko 2023-09-04 20:37:53 +03:00 committed by GitHub
parent 4793173465
commit c7f1af8742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,7 +141,12 @@ fun processExternalIntent(intent: Intent?) {
when {
intent.type == "text/plain" -> {
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
if (text != null) {
val uri = intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri
if (uri != null) {
// Shared file that contains plain text, like `*.log` file
chatModel.sharedContent.value = SharedContent.File(text ?: "", uri.toURI())
} else if (text != null) {
// Shared just a text
chatModel.sharedContent.value = SharedContent.Text(text)
}
}