Fix url sharing

This commit is contained in:
Jobobby04 2022-11-16 16:59:10 -05:00
parent af36b6a677
commit f52785cbbd

View File

@ -13,11 +13,14 @@ fun Uri.toShareIntent(context: Context, type: String = "image/*", message: Strin
val uri = this val uri = this
val shareIntent = Intent(Intent.ACTION_SEND).apply { val shareIntent = Intent(Intent.ACTION_SEND).apply {
if (message != null) putExtra(Intent.EXTRA_TEXT, message) if (uri.scheme == "http" || uri.scheme == "https") putExtra(Intent.EXTRA_TEXT, uri.toString())
putExtra(Intent.EXTRA_STREAM, uri) if (uri.scheme == "content") {
if (message != null) putExtra(Intent.EXTRA_TEXT, message)
putExtra(Intent.EXTRA_STREAM, uri)
}
clipData = ClipData.newRawUri(null, uri) clipData = ClipData.newRawUri(null, uri)
setType(type)
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setType(type)
} }
return Intent.createChooser(shareIntent, context.getString(R.string.action_share)).apply { return Intent.createChooser(shareIntent, context.getString(R.string.action_share)).apply {