fix #264, add a "Show Hidden" button at the copy destination

This commit is contained in:
tibbi 2018-10-19 23:16:06 +02:00
parent eacb7d0541
commit 23b8ec36c7
3 changed files with 69 additions and 42 deletions

View file

@ -4,10 +4,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beGoneIf import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.adapters.DirectoryAdapter import com.simplemobiletools.gallery.adapters.DirectoryAdapter
@ -36,10 +33,22 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } .setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() }
.create().apply { .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()) { if (it.isNotEmpty()) {
activity.runOnUiThread { activity.runOnUiThread {
gotDirectories(activity.addTempFolderIfNeeded(it)) gotDirectories(activity.addTempFolderIfNeeded(it))

View file

@ -334,7 +334,7 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
.into(target) .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 { Thread {
val directories = try { val directories = try {
directoryDao.getAll() as ArrayList<Directory> directoryDao.getAll() as ArrayList<Directory>
@ -346,7 +346,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
directories.removeAll { it.isRecycleBin() } directories.removeAll { it.isRecycleBin() }
} }
val shouldShowHidden = config.shouldShowHidden val shouldShowHidden = config.shouldShowHidden || forceShowHidden
val excludedPaths = config.excludedFolders val excludedPaths = config.excludedFolders
val includedPaths = config.includedFolders val includedPaths = config.includedFolders
var filteredDirectories = directories.filter { it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden) } as ArrayList<Directory> var filteredDirectories = directories.filter { it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden) } as ArrayList<Directory>

View file

@ -1,4 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?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 <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
@ -21,8 +28,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="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"/> <include layout="@layout/fastscroller_handle_vertical"/>
@ -32,12 +39,23 @@
android:id="@+id/directories_horizontal_fastscroller" android:id="@+id/directories_horizontal_fastscroller"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:paddingTop="@dimen/normal_margin"> android:paddingTop="@dimen/normal_margin">
<include layout="@layout/fastscroller_handle_horizontal"/> <include layout="@layout/fastscroller_handle_horizontal"/>
</com.simplemobiletools.commons.views.FastScroller> </com.simplemobiletools.commons.views.FastScroller>
</RelativeLayout> </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>