From 3e3fb0c5800b3888025517fcf9835bfe2517d548 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 13 Feb 2022 11:02:51 +0100 Subject: [PATCH] fix a glitch with the inability to display hidden files anymore --- .../pro/activities/PhotoVideoActivity.kt | 37 +++++++++++-------- .../gallery/pro/fragments/PhotoFragment.kt | 4 ++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 62ee4e013..9d7f59908 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE 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.R import com.simplemobiletools.gallery.pro.extensions.* @@ -101,15 +102,18 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { val realPath = intent.extras!!.getString(REAL_FILE_PATH) if (realPath != null && getDoesFilePathExist(realPath)) { - if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { - if (isFileTypeVisible(realPath)) { - bottom_actions.beGone() - sendViewPagerIntent(realPath) - finish() - return + val avoidShowingHiddenFiles = isRPlus() && File(realPath).isHidden + if (!avoidShowingHiddenFiles) { + if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { + if (isFileTypeVisible(realPath)) { + bottom_actions.beGone() + sendViewPagerIntent(realPath) + finish() + return + } + } else { + filename = realPath.getFilenameFromPath() } - } else { - filename = realPath.getFilenameFromPath() } } } @@ -124,13 +128,16 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList return } else { val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" - if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(path)) { - if (isFileTypeVisible(path)) { - bottom_actions.beGone() - rescanPaths(arrayListOf(mUri!!.path!!)) - sendViewPagerIntent(path) - finish() - return + val avoidShowingHiddenFiles = isRPlus() && File(path).isHidden + if (!avoidShowingHiddenFiles) { + if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(path)) { + if (isFileTypeVisible(path)) { + bottom_actions.beGone() + rescanPaths(arrayListOf(mUri!!.path!!)) + sendViewPagerIntent(path) + finish() + return + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 572538ec8..6b00ef5d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -41,6 +41,7 @@ import com.github.penfeizhou.animation.webp.WebPDrawable import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread +import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity import com.simplemobiletools.gallery.pro.activities.PhotoActivity @@ -165,6 +166,9 @@ class PhotoFragment : ViewPagerFragment() { if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) { mMedium.path = context!!.getRealPathFromURI(Uri.parse(mOriginalPath)) ?: mMedium.path + if (isRPlus() && mMedium.path.startsWith("/storage/") && mMedium.isHidden()) { + mMedium.path = mOriginalPath + } if (mMedium.path.isEmpty()) { var out: FileOutputStream? = null