Fix image preview in share sheet (#2389)

This commit is contained in:
cketti 2022-03-16 18:46:26 +01:00 committed by GitHub
parent e05fdc6d7b
commit e6f7d9d5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -36,6 +36,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import android.widget.Toast import android.widget.Toast
import androidx.core.app.ShareCompat
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
@ -252,11 +253,11 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
} }
private fun shareFile(file: File, mimeType: String?) { private fun shareFile(file: File, mimeType: String?) {
val sendIntent = Intent() ShareCompat.IntentBuilder(this)
sendIntent.action = Intent.ACTION_SEND .setType(mimeType)
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(applicationContext, "$APPLICATION_ID.fileprovider", file)) .addStream(FileProvider.getUriForFile(applicationContext, "$APPLICATION_ID.fileprovider", file))
sendIntent.type = mimeType .setChooserTitle(R.string.send_media_to)
startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.send_media_to))) .startChooser()
} }
private var isCreating: Boolean = false private var isCreating: Boolean = false