send real filepath as an extra with View intent
This commit is contained in:
parent
4c0b773e94
commit
c520c8c557
3 changed files with 11 additions and 7 deletions
|
@ -24,7 +24,6 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.views.MyScalableRecyclerView
|
||||
import com.simplemobiletools.gallery.BuildConfig
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
|
@ -505,8 +504,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
val file = File(path)
|
||||
val isVideo = file.isVideoFast()
|
||||
if (isVideo) {
|
||||
val uri = getFilePublicUri(file, BuildConfig.APPLICATION_ID)
|
||||
openFile(uri)
|
||||
openFile(Uri.fromFile(file))
|
||||
} else {
|
||||
Intent(this, ViewPagerActivity::class.java).apply {
|
||||
putExtra(MEDIUM, path)
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
|||
import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY
|
||||
import com.simplemobiletools.gallery.helpers.IS_VIEW_INTENT
|
||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
import com.simplemobiletools.gallery.helpers.REAL_FILE_PATH
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import kotlinx.android.synthetic.main.fragment_holder.*
|
||||
import java.io.File
|
||||
|
@ -50,6 +51,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
|
||||
private fun checkIntent(savedInstanceState: Bundle? = null) {
|
||||
mUri = intent.data ?: return
|
||||
if (intent.extras.containsKey(REAL_FILE_PATH)) {
|
||||
mUri = intent.extras.get(REAL_FILE_PATH) as Uri
|
||||
}
|
||||
|
||||
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
|
||||
|
||||
if (mUri.scheme == "file") {
|
||||
|
|
|
@ -18,10 +18,7 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.gallery.BuildConfig
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import com.simplemobiletools.gallery.views.MySquareImageView
|
||||
|
@ -90,6 +87,10 @@ fun Activity.openFile(uri: Uri) {
|
|||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
putExtra(IS_FROM_GALLERY, true)
|
||||
|
||||
if (isNougatPlus()) {
|
||||
putExtra(REAL_FILE_PATH, uri)
|
||||
}
|
||||
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
val chooser = Intent.createChooser(this, getString(R.string.open_with))
|
||||
startActivity(chooser)
|
||||
|
|
Loading…
Reference in a new issue