From e6f7d9d5af4efeddcca7e46582536d2fe0d9735a Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 16 Mar 2022 18:46:26 +0100 Subject: [PATCH] Fix image preview in share sheet (#2389) --- .../java/com/keylesspalace/tusky/ViewMediaActivity.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index e5a3f35f2..64d29577b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -36,6 +36,7 @@ import android.view.MenuItem import android.view.View import android.webkit.MimeTypeMap import android.widget.Toast +import androidx.core.app.ShareCompat import androidx.core.content.FileProvider import androidx.fragment.app.FragmentActivity import androidx.lifecycle.Lifecycle @@ -252,11 +253,11 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener } private fun shareFile(file: File, mimeType: String?) { - val sendIntent = Intent() - sendIntent.action = Intent.ACTION_SEND - sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(applicationContext, "$APPLICATION_ID.fileprovider", file)) - sendIntent.type = mimeType - startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.send_media_to))) + ShareCompat.IntentBuilder(this) + .setType(mimeType) + .addStream(FileProvider.getUriForFile(applicationContext, "$APPLICATION_ID.fileprovider", file)) + .setChooserTitle(R.string.send_media_to) + .startChooser() } private var isCreating: Boolean = false