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() { private fun addExcludedFolder() {
FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) { FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
config.addExcludedFolder(it) config.addExcludedFolder(it)
updateExcludedFolders() updateExcludedFolders()
} }

View file

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

View file

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

View file

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

View file

@ -149,11 +149,11 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
private fun showProperties() { private fun showProperties() {
val selections = multiSelector.selectedPositions val selections = multiSelector.selectedPositions
if (selections.size <= 1) { if (selections.size <= 1) {
PropertiesDialog(activity, dirs[selections[0]].path, config.showHiddenFolders) PropertiesDialog(activity, dirs[selections[0]].path, config.shouldShowHidden)
} else { } else {
val paths = ArrayList<String>() val paths = ArrayList<String>()
selections.forEach { paths.add(dirs[it].path) } 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() { private fun showProperties() {
val selections = multiSelector.selectedPositions val selections = multiSelector.selectedPositions
if (selections.size <= 1) { if (selections.size <= 1) {
PropertiesDialog(activity, media[selections[0]].path, config.showHiddenFolders) PropertiesDialog(activity, media[selections[0]].path, config.shouldShowHidden)
} else { } else {
val paths = ArrayList<String>() val paths = ArrayList<String>()
selections.forEach { paths.add(media[it].path) } 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> { private fun groupDirectories(media: ArrayList<Medium>): Map<String, Directory> {
val hidden = context.resources.getString(R.string.hidden) val hidden = context.resources.getString(R.string.hidden)
val directories = LinkedHashMap<String, Directory>() val directories = LinkedHashMap<String, Directory>()
val showHidden = config.showHiddenFolders || config.temporarilyShowHidden val showHidden = config.shouldShowHidden
for ((name, path, isVideo, dateModified, dateTaken, size) in media) { for ((name, path, isVideo, dateModified, dateTaken, size) in media) {
if (shouldStop) if (shouldStop)
cancel(true) cancel(true)

View file

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

View file

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

View file

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