fix #335, properly show hidden files if open through a file manager

This commit is contained in:
tibbi 2017-08-28 20:43:39 +02:00
parent 7046fc9ed4
commit 60ed21702f
2 changed files with 23 additions and 2 deletions

View file

@ -72,7 +72,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsGetAnyContentIntent || mIsSetWallpaperIntent
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
mDirs = ArrayList<Directory>()
mDirs = ArrayList()
mStoredAnimateGifs = config.animateGifs
mStoredCropThumbnails = config.cropThumbnails
mStoredScrollHorizontally = config.scrollHorizontally

View file

@ -98,7 +98,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
return
}
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true && File(mPath).isHidden) {
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true && isShowHiddenFlagNeeded()) {
if (!config.isPasswordProtectionOn) {
config.temporarilyShowHidden = true
}
@ -443,6 +443,27 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
out.close()
}
private fun isShowHiddenFlagNeeded(): Boolean {
val file = File(mPath)
if (file.isHidden)
return true
var parent = file.parentFile
while (true) {
if (parent.isHidden || parent.listFiles()?.contains(File(NOMEDIA)) == true) {
return true
}
if (parent.absolutePath == "/") {
break
}
parent = parent.parentFile
}
return false
}
private fun getCurrentFragment() = (view_pager.adapter as MyPagerAdapter).getCurrentFragment(view_pager.currentItem)
private fun showProperties() {