[Android] Fix share title
Nicolas Pomepuy
git at videolan.org
Tue Apr 13 06:48:09 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 6 11:54:45 2021 +0200| [22364416a221acbdcbada83d0d2e7d44d8514393] | committer: Nicolas Pomepuy
Fix share title
> https://code.videolan.org/videolan/vlc-android/commit/22364416a221acbdcbada83d0d2e7d44d8514393
---
application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index 14d190291..c19adb896 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -84,15 +84,16 @@ suspend fun AppCompatActivity.share(media: MediaWrapper) {
if (validFile) {
intentShareFile.type = if (media.type == TYPE_VIDEO) "video/*" else "audio/*"
intentShareFile.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, "$packageName.provider", fileWithinMyDir))
- intentShareFile.putExtra(Intent.EXTRA_SUBJECT, title)
- intentShareFile.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message))
- startActivity(Intent.createChooser(intentShareFile, getString(R.string.share_file, title)))
+ intentShareFile.putExtra(Intent.EXTRA_SUBJECT, media.title)
+ intentShareFile.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message, media.title))
+ startActivity(Intent.createChooser(intentShareFile, getString(R.string.share_file, media.title)))
} else Snackbar.make(findViewById(android.R.id.content), R.string.invalid_file, Snackbar.LENGTH_LONG).show()
}
fun FragmentActivity.share(medias: List<MediaWrapper>) = lifecycleScope.launch {
val intentShareFile = Intent(Intent.ACTION_SEND_MULTIPLE)
val uris = arrayListOf<Uri>()
+ val title = if (medias.size == 1) medias[0].title else resources.getQuantityString(R.plurals.media_quantity, medias.size, medias.size)
withContext(Dispatchers.IO) {
medias.filter { it.uri.path != null && File(it.uri.path!!).exists() }.forEach {
val file = File(it.uri.path!!)
@@ -105,7 +106,7 @@ fun FragmentActivity.share(medias: List<MediaWrapper>) = lifecycleScope.launch {
intentShareFile.type = "*/*"
intentShareFile.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
intentShareFile.putExtra(Intent.EXTRA_SUBJECT, title)
- intentShareFile.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message))
+ intentShareFile.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_message, title))
startActivity(Intent.createChooser(intentShareFile, getString(R.string.share_file, title)))
} else Snackbar.make(findViewById(android.R.id.content), R.string.invalid_file, Snackbar.LENGTH_LONG).show()
}
More information about the Android
mailing list