Set share image mimetype with wildcard

This commit is contained in:
len 2016-11-27 15:44:59 +01:00
parent bb89b72a81
commit 12dcc2c31f
2 changed files with 9 additions and 12 deletions

View File

@ -478,13 +478,12 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
if (page.status != Page.READY) if (page.status != Page.READY)
return return
val shareIntent = Intent().apply { val intent = Intent(Intent.ACTION_SEND).apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, page.uri) putExtra(Intent.EXTRA_STREAM, page.uri)
flags = Intent.FLAG_ACTIVITY_NEW_TASK 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)))
} }
/** /**

View File

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