mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 03:55:06 +01:00
Use chooser intent for sharing saved pages
This commit is contained in:
parent
f2fca0f13d
commit
649209890d
@ -131,7 +131,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
*/
|
||||
private fun shareImage(context: Context, path: String, notificationId: Int) {
|
||||
dismissNotification(context, notificationId)
|
||||
context.startActivity(File(path).getUriCompat(context).toShareIntent())
|
||||
context.startActivity(File(path).getUriCompat(context).toShareIntent(context))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +143,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
*/
|
||||
private fun shareFile(context: Context, uri: Uri, fileMimeType: String, notificationId: Int) {
|
||||
dismissNotification(context, notificationId)
|
||||
context.startActivity(uri.toShareIntent(fileMimeType))
|
||||
context.startActivity(uri.toShareIntent(context, fileMimeType))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -688,12 +688,7 @@ class MangaController :
|
||||
useCoverAsBitmap(activity) { coverBitmap ->
|
||||
val cover = presenter.shareCover(activity, coverBitmap)
|
||||
val uri = cover.getUriCompat(activity)
|
||||
startActivity(
|
||||
Intent.createChooser(
|
||||
uri.toShareIntent(),
|
||||
activity.getString(R.string.action_share)
|
||||
)
|
||||
)
|
||||
startActivity(uri.toShareIntent(activity))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
|
@ -1,15 +1,22 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
fun Uri.toShareIntent(type: String = "image/*"): Intent {
|
||||
fun Uri.toShareIntent(context: Context, type: String = "image/*"): Intent {
|
||||
val uri = this
|
||||
return Intent(Intent.ACTION_SEND).apply {
|
||||
|
||||
val shareIntent = Intent(Intent.ACTION_SEND).apply {
|
||||
putExtra(Intent.EXTRA_STREAM, uri)
|
||||
clipData = ClipData.newRawUri(null, uri)
|
||||
setType(type)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
|
||||
return Intent.createChooser(shareIntent, context.getString(R.string.action_share)).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user