|
@@ -13,8 +13,15 @@ fun Uri.toShareIntent(context: Context, type: String = "image/*", message: Strin
|
|
|
val uri = this
|
|
|
|
|
|
val shareIntent = Intent(Intent.ACTION_SEND).apply {
|
|
|
- if (message != null) putExtra(Intent.EXTRA_TEXT, message)
|
|
|
- putExtra(Intent.EXTRA_STREAM, uri)
|
|
|
+ when (uri.scheme) {
|
|
|
+ "http", "https" -> {
|
|
|
+ putExtra(Intent.EXTRA_TEXT, uri.toString())
|
|
|
+ }
|
|
|
+ "content" -> {
|
|
|
+ message?.let { putExtra(Intent.EXTRA_TEXT, it) }
|
|
|
+ putExtra(Intent.EXTRA_STREAM, uri)
|
|
|
+ }
|
|
|
+ }
|
|
|
clipData = ClipData.newRawUri(null, uri)
|
|
|
setType(type)
|
|
|
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|