diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index 09482f5aa..9aa0fa625 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -4,10 +4,7 @@ import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.RecyclerView import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.dialogs.FilePickerDialog -import com.simplemobiletools.commons.extensions.beGoneIf -import com.simplemobiletools.commons.extensions.beVisibleIf -import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.adapters.DirectoryAdapter @@ -36,10 +33,22 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri .setNegativeButton(R.string.cancel, null) .setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } .create().apply { - activity.setupDialogStuff(view, this, R.string.select_destination) + activity.setupDialogStuff(view, this, R.string.select_destination) { + view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden) + view.directories_show_hidden.setOnClickListener { + activity.handleHiddenFolderPasswordProtection { + view.directories_show_hidden.beGone() + fetchDirectories(true) + } + } + } } - activity.getCachedDirectories { + fetchDirectories(false) + } + + private fun fetchDirectories(forceShowHidden: Boolean) { + activity.getCachedDirectories(forceShowHidden = forceShowHidden) { if (it.isNotEmpty()) { activity.runOnUiThread { gotDirectories(activity.addTempFolderIfNeeded(it)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index a00548a84..846e44b21 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -334,7 +334,7 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo .into(target) } -fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, directoryDao: DirectoryDao = galleryDB.DirectoryDao(), callback: (ArrayList) -> Unit) { +fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, directoryDao: DirectoryDao = galleryDB.DirectoryDao(), forceShowHidden: Boolean = false, callback: (ArrayList) -> Unit) { Thread { val directories = try { directoryDao.getAll() as ArrayList @@ -346,7 +346,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: directories.removeAll { it.isRecycleBin() } } - val shouldShowHidden = config.shouldShowHidden + val shouldShowHidden = config.shouldShowHidden || forceShowHidden val excludedPaths = config.excludedFolders val includedPaths = config.includedFolders var filteredDirectories = directories.filter { it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden) } as ArrayList diff --git a/app/src/main/res/layout/dialog_directory_picker.xml b/app/src/main/res/layout/dialog_directory_picker.xml index 565382785..5c45c16de 100644 --- a/app/src/main/res/layout/dialog_directory_picker.xml +++ b/app/src/main/res/layout/dialog_directory_picker.xml @@ -1,43 +1,61 @@ - + android:layout_height="match_parent"> - - - - - - - - - + android:paddingTop="@dimen/activity_margin"> - + - - + + + + + + + + + + + + + + + +