mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
fix #264, add a "Show Hidden" button at the copy destination
This commit is contained in:
parent
eacb7d0541
commit
23b8ec36c7
3 changed files with 69 additions and 42 deletions
|
@ -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))
|
||||
|
|
|
@ -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<Directory>) -> Unit) {
|
||||
fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, directoryDao: DirectoryDao = galleryDB.DirectoryDao(), forceShowHidden: Boolean = false, callback: (ArrayList<Directory>) -> Unit) {
|
||||
Thread {
|
||||
val directories = try {
|
||||
directoryDao.getAll() as ArrayList<Directory>
|
||||
|
@ -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<Directory>
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/directories_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
@ -21,8 +28,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingLeft="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical"/>
|
||||
|
||||
|
@ -32,12 +39,23 @@
|
|||
android:id="@+id/directories_horizontal_fastscroller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:paddingTop="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_horizontal"/>
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||
android:id="@+id/directories_show_hidden"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_unhide"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
Loading…
Reference in a new issue