check if hidden folders are temporarily shown in a couple more places

This commit is contained in:
tibbi 2017-03-22 23:38:34 +01:00
parent 785a8bf589
commit bc73f0d807
10 changed files with 18 additions and 12 deletions

View file

@ -56,7 +56,7 @@ class ExcludedFoldersActivity : SimpleActivity() {
}
private fun addExcludedFolder() {
FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) {
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
config.addExcludedFolder(it)
updateExcludedFolders()
}

View file

@ -57,7 +57,7 @@ class IncludedFoldersActivity : SimpleActivity() {
}
private fun addIncludedFolder() {
FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) {
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
config.addIncludedFolder(it)
updateIncludedFolders()
scanPath(it) {}

View file

@ -113,6 +113,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mStoredAnimateGifs = config.animateGifs
}
override fun onStop() {
super.onStop()
config.temporarilyShowHidden = false
}
override fun onDestroy() {
super.onDestroy()
config.isFirstRun = false
@ -158,7 +163,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) {
config.temporarilyShowHidden = false
gotDirectories(it)
}
mCurrAsyncTask!!.execute()

View file

@ -177,7 +177,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private fun hideFolder() {
addNoMedia(mPath) {
runOnUiThread {
if (!config.showHiddenFolders)
if (!config.shouldShowHidden)
finish()
else
invalidateOptionsMenu()

View file

@ -149,11 +149,11 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
private fun showProperties() {
val selections = multiSelector.selectedPositions
if (selections.size <= 1) {
PropertiesDialog(activity, dirs[selections[0]].path, config.showHiddenFolders)
PropertiesDialog(activity, dirs[selections[0]].path, config.shouldShowHidden)
} else {
val paths = ArrayList<String>()
selections.forEach { paths.add(dirs[it].path) }
PropertiesDialog(activity, paths, config.showHiddenFolders)
PropertiesDialog(activity, paths, config.shouldShowHidden)
}
}

View file

@ -108,11 +108,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
private fun showProperties() {
val selections = multiSelector.selectedPositions
if (selections.size <= 1) {
PropertiesDialog(activity, media[selections[0]].path, config.showHiddenFolders)
PropertiesDialog(activity, media[selections[0]].path, config.shouldShowHidden)
} else {
val paths = ArrayList<String>()
selections.forEach { paths.add(media[it].path) }
PropertiesDialog(activity, paths, config.showHiddenFolders)
PropertiesDialog(activity, paths, config.shouldShowHidden)
}
}

View file

@ -71,7 +71,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
private fun groupDirectories(media: ArrayList<Medium>): Map<String, Directory> {
val hidden = context.resources.getString(R.string.hidden)
val directories = LinkedHashMap<String, Directory>()
val showHidden = config.showHiddenFolders || config.temporarilyShowHidden
val showHidden = config.shouldShowHidden
for ((name, path, isVideo, dateModified, dateTaken, size) in media) {
if (shouldStop)
cancel(true)

View file

@ -43,7 +43,7 @@ class PickAlbumDialog(val activity: SimpleActivity, val sourcePath: String, val
}
fun showOtherFolder() {
val showHidden = activity.config.showHiddenFolders
val showHidden = activity.config.shouldShowHidden
FilePickerDialog(activity, sourcePath, false, showHidden, true) {
callback.invoke(it)
}

View file

@ -70,7 +70,7 @@ fun Context.getParents(): ArrayList<String> {
val noMediaFolders = getNoMediaFolders()
val parents = ArrayList<String>()
if (config.showHiddenFolders || config.temporarilyShowHidden) {
if (config.shouldShowHidden) {
parentsSet.addAll(noMediaFolders)
}
@ -79,7 +79,7 @@ fun Context.getParents(): ArrayList<String> {
parentsSet.filterTo(parents, {
val file = File(it)
if (file.isDirectory && file.canonicalFile == file.absoluteFile) { // filter out symbolic links too
if (!config.showHiddenFolders && !config.temporarilyShowHidden) {
if (!config.shouldShowHidden) {
isFolderVisible(it, noMediaFolders)
} else
true

View file

@ -40,6 +40,8 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(HIDE_FOLDER_TOOLTIP_SHOWN, false)
set(wasShown) = prefs.edit().putBoolean(HIDE_FOLDER_TOOLTIP_SHOWN, wasShown).apply()
var shouldShowHidden = showHiddenFolders || temporarilyShowHidden
var showHiddenFolders: Boolean
get() = prefs.getBoolean(SHOW_HIDDEN_FOLDERS, false)
set(showHiddenFolders) = prefs.edit().putBoolean(SHOW_HIDDEN_FOLDERS, showHiddenFolders).apply()