fix #1474, improve the handling of third party intents and type filters

This commit is contained in:
tibbi 2019-06-23 23:07:36 +02:00
parent b1f2ab8a13
commit bf7b0d0386

View file

@ -97,9 +97,11 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
val realPath = intent.extras!!.getString(REAL_FILE_PATH)
if (realPath != null && File(realPath).exists()) {
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
sendViewPagerIntent(realPath)
finish()
return
if (isFileTypeVisible(realPath)) {
sendViewPagerIntent(realPath)
finish()
return
}
} else {
filename = realPath.getFilenameFromPath()
}
@ -116,10 +118,12 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} else {
val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) {
rescanPaths(arrayListOf(mUri!!.path))
sendViewPagerIntent(path)
finish()
return
if (isFileTypeVisible(path)) {
rescanPaths(arrayListOf(mUri!!.path))
sendViewPagerIntent(path)
finish()
return
}
}
}
@ -253,6 +257,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
PropertiesDialog(this, mUri!!.path)
}
private fun isFileTypeVisible(path: String): Boolean {
val filter = config.filterMedia
return !(path.isImageFast() && filter and TYPE_IMAGES == 0 ||
path.isVideoFast() && filter and TYPE_VIDEOS == 0 ||
path.isGif() && filter and TYPE_GIFS == 0 ||
path.isRawFast() && filter and TYPE_RAWS == 0 ||
path.isSvg() && filter and TYPE_SVGS == 0)
}
private fun initBottomActions() {
initBottomActionsLayout()
initBottomActionButtons()