mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Set clip data when sharing content URIs (closes #4198)
This commit is contained in:
		| @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.notification | ||||
|  | ||||
| import android.app.PendingIntent | ||||
| import android.content.BroadcastReceiver | ||||
| import android.content.ClipData | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.net.Uri | ||||
| @@ -120,14 +121,13 @@ class NotificationReceiver : BroadcastReceiver() { | ||||
|      * @param notificationId id of notification | ||||
|      */ | ||||
|     private fun shareImage(context: Context, path: String, notificationId: Int) { | ||||
|         // Create intent | ||||
|         val intent = Intent(Intent.ACTION_SEND).apply { | ||||
|             val uri = File(path).getUriCompat(context) | ||||
|             putExtra(Intent.EXTRA_STREAM, uri) | ||||
|             clipData = ClipData.newRawUri(null, uri) | ||||
|             type = "image/*" | ||||
|             flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION | ||||
|         } | ||||
|         // Dismiss notification | ||||
|         dismissNotification(context, notificationId) | ||||
|         // Launch share activity | ||||
|         context.startActivity(intent) | ||||
| @@ -143,6 +143,7 @@ class NotificationReceiver : BroadcastReceiver() { | ||||
|     private fun shareBackup(context: Context, uri: Uri, notificationId: Int) { | ||||
|         val sendIntent = Intent(Intent.ACTION_SEND).apply { | ||||
|             putExtra(Intent.EXTRA_STREAM, uri) | ||||
|             clipData = ClipData.newRawUri(null, uri) | ||||
|             type = "application/json" | ||||
|             flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION | ||||
|         } | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader | ||||
| import android.annotation.SuppressLint | ||||
| import android.annotation.TargetApi | ||||
| import android.app.ProgressDialog | ||||
| import android.content.ClipData | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.content.pm.ActivityInfo | ||||
| @@ -595,10 +596,11 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>() | ||||
|         val manga = presenter.manga ?: return | ||||
|         val chapter = page.chapter.chapter | ||||
|  | ||||
|         val stream = file.getUriCompat(this) | ||||
|         val uri = file.getUriCompat(this) | ||||
|         val intent = Intent(Intent.ACTION_SEND).apply { | ||||
|             putExtra(Intent.EXTRA_TEXT, getString(R.string.share_page_info, manga.title, chapter.name, page.number)) | ||||
|             putExtra(Intent.EXTRA_STREAM, stream) | ||||
|             putExtra(Intent.EXTRA_STREAM, uri) | ||||
|             clipData = ClipData.newRawUri(null, uri) | ||||
|             flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION | ||||
|             type = "image/*" | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user