fix a glitch with the inability to display hidden files anymore

This commit is contained in:
tibbi 2022-02-13 11:02:51 +01:00
parent 0605e8944e
commit 3e3fb0c580
2 changed files with 26 additions and 15 deletions

View file

@ -14,6 +14,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.BuildConfig
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.extensions.*
@ -101,15 +102,18 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
val realPath = intent.extras!!.getString(REAL_FILE_PATH) val realPath = intent.extras!!.getString(REAL_FILE_PATH)
if (realPath != null && getDoesFilePathExist(realPath)) { if (realPath != null && getDoesFilePathExist(realPath)) {
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { val avoidShowingHiddenFiles = isRPlus() && File(realPath).isHidden
if (isFileTypeVisible(realPath)) { if (!avoidShowingHiddenFiles) {
bottom_actions.beGone() if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
sendViewPagerIntent(realPath) if (isFileTypeVisible(realPath)) {
finish() bottom_actions.beGone()
return sendViewPagerIntent(realPath)
finish()
return
}
} else {
filename = realPath.getFilenameFromPath()
} }
} else {
filename = realPath.getFilenameFromPath()
} }
} }
} }
@ -124,13 +128,16 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
return return
} else { } else {
val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(path)) { val avoidShowingHiddenFiles = isRPlus() && File(path).isHidden
if (isFileTypeVisible(path)) { if (!avoidShowingHiddenFiles) {
bottom_actions.beGone() if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(path)) {
rescanPaths(arrayListOf(mUri!!.path!!)) if (isFileTypeVisible(path)) {
sendViewPagerIntent(path) bottom_actions.beGone()
finish() rescanPaths(arrayListOf(mUri!!.path!!))
return sendViewPagerIntent(path)
finish()
return
}
} }
} }
} }

View file

@ -41,6 +41,7 @@ import com.github.penfeizhou.animation.webp.WebPDrawable
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
import com.simplemobiletools.gallery.pro.activities.PhotoActivity import com.simplemobiletools.gallery.pro.activities.PhotoActivity
@ -165,6 +166,9 @@ class PhotoFragment : ViewPagerFragment() {
if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) { if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) {
mMedium.path = context!!.getRealPathFromURI(Uri.parse(mOriginalPath)) ?: mMedium.path mMedium.path = context!!.getRealPathFromURI(Uri.parse(mOriginalPath)) ?: mMedium.path
if (isRPlus() && mMedium.path.startsWith("/storage/") && mMedium.isHidden()) {
mMedium.path = mOriginalPath
}
if (mMedium.path.isEmpty()) { if (mMedium.path.isEmpty()) {
var out: FileOutputStream? = null var out: FileOutputStream? = null