rename copy path getter method for common usage & simplify copy path checks

This commit is contained in:
fatih ergin 2023-06-22 00:47:36 +03:00
parent 411c732fa8
commit ab6eb93394

View file

@ -170,7 +170,14 @@ class PickDirectoryDialog(
private fun showOtherFolder() { private fun showOtherFolder() {
activity.hideKeyboard(searchEditText) activity.hideKeyboard(searchEditText)
FilePickerDialog(activity, getOtherFolderOpeningPath(), !isPickingCopyMoveDestination && !isPickingFolderForWidget, showHidden, true, true) { FilePickerDialog(
activity,
getDefaultCopyDestinationPath(sourcePath),
!isPickingCopyMoveDestination && !isPickingFolderForWidget,
showHidden,
true,
true
) {
config.lastCopyPath = it config.lastCopyPath = it
activity.handleLockedFolderOpening(it) { success -> activity.handleLockedFolderOpening(it) { success ->
if (success) { if (success) {
@ -180,17 +187,19 @@ class PickDirectoryDialog(
} }
} }
private fun getOtherFolderOpeningPath(): String { private fun getDefaultCopyDestinationPath(currentPath: String): String {
val lastCopyPath = config.lastCopyPath val lastCopyPath = config.lastCopyPath
val lastCopyPathVisible = { return if (activity.getDoesFilePathExist(lastCopyPath)) {
showHidden || !lastCopyPath.split(File.separator).any { it.startsWith(".") && it.length > 1 } val isLastCopyPathVisible = !lastCopyPath.split(File.separator).any { it.startsWith(".") && it.length > 1 }
}
return if (activity.getDoesFilePathExist(lastCopyPath) && lastCopyPathVisible()) { if (showHidden || isLastCopyPathVisible) {
lastCopyPath lastCopyPath
} else { } else {
sourcePath currentPath
}
} else {
currentPath
} }
} }