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) val realPath = intent.extras!!.getString(REAL_FILE_PATH)
if (realPath != null && File(realPath).exists()) { if (realPath != null && File(realPath).exists()) {
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
if (isFileTypeVisible(realPath)) {
sendViewPagerIntent(realPath) sendViewPagerIntent(realPath)
finish() finish()
return return
}
} else { } else {
filename = realPath.getFilenameFromPath() filename = realPath.getFilenameFromPath()
} }
@ -116,12 +118,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} else { } else {
val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) { if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) {
if (isFileTypeVisible(path)) {
rescanPaths(arrayListOf(mUri!!.path)) rescanPaths(arrayListOf(mUri!!.path))
sendViewPagerIntent(path) sendViewPagerIntent(path)
finish() finish()
return return
} }
} }
}
checkNotchSupport() checkNotchSupport()
showSystemUI(true) showSystemUI(true)
@ -253,6 +257,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
PropertiesDialog(this, mUri!!.path) 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() { private fun initBottomActions() {
initBottomActionsLayout() initBottomActionsLayout()
initBottomActionButtons() initBottomActionButtons()