Parcourir la source

Set share image mimetype with wildcard

len il y a 8 ans
Parent
commit
12dcc2c31f

+ 3 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt

@@ -478,13 +478,12 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
         if (page.status != Page.READY)
             return
 
-        val shareIntent = Intent().apply {
-            action = Intent.ACTION_SEND
+        val intent = Intent(Intent.ACTION_SEND).apply {
             putExtra(Intent.EXTRA_STREAM, page.uri)
             flags = Intent.FLAG_ACTIVITY_NEW_TASK
-            type = "image/jpeg"
+            type = "image/*"
         }
-        startActivity(Intent.createChooser(shareIntent, resources.getText(R.string.action_share)))
+        startActivity(Intent.createChooser(intent, getString(R.string.action_share)))
     }
 
     /**

+ 6 - 8
app/src/main/java/eu/kanade/tachiyomi/ui/reader/notification/ImageNotificationReceiver.kt

@@ -45,13 +45,12 @@ class ImageNotificationReceiver : BroadcastReceiver() {
      * @param path path of file
      */
     private fun shareImage(context: Context, path: String) {
-        val shareIntent = Intent().apply {
-            action = Intent.ACTION_SEND
+        val intent = Intent(Intent.ACTION_SEND).apply {
+            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
             putExtra(Intent.EXTRA_STREAM, Uri.parse(path))
-            type = "image/jpeg"
+            type = "image/*"
         }
-        context.startActivity(Intent.createChooser(shareIntent, context.resources.getText(R.string.action_share))
-                .apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK })
+        context.startActivity(Intent.createChooser(intent, context.getString(R.string.action_share)))
     }
 
     /**
@@ -60,10 +59,9 @@ class ImageNotificationReceiver : BroadcastReceiver() {
      * @param path path of file
      */
     private fun showImage(context: Context, path: String) {
-        val intent = Intent().apply {
-            action = Intent.ACTION_VIEW
+        val intent = Intent(Intent.ACTION_VIEW).apply {
             flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
-            val uri = FileProvider.getUriForFile(context,"eu.kanade.tachiyomi.provider",File(path))
+            val uri = FileProvider.getUriForFile(context, "eu.kanade.tachiyomi.provider", File(path))
             setDataAndType(uri, "image/*")
         }
         context.startActivity(intent)