remember last used copy destination on "Select a folder" picker

This commit is contained in:
fatih ergin 2023-06-21 23:20:29 +03:00
parent a88a271cc2
commit 8e67656719
2 changed files with 22 additions and 11 deletions

View File

@ -64,7 +64,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:4c83ec8740' implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592'
implementation 'com.github.tibbi:PdfViewPager:d2af24208d' implementation 'com.github.tibbi:PdfViewPager:d2af24208d'
implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6' implementation 'com.github.Stericson:RootShell:1.6'

View File

@ -85,7 +85,7 @@ class ItemsAdapter(
setupDragListener(true) setupDragListener(true)
initDrawables() initDrawables()
updateFontSizes() updateFontSizes()
dateFormat = activity.config.dateFormat dateFormat = config.dateFormat
timeFormat = activity.getTimeFormat() timeFormat = activity.getTimeFormat()
} }
@ -223,19 +223,21 @@ class ItemsAdapter(
paths.size == 1 -> { paths.size == 1 -> {
val oldPath = paths.first() val oldPath = paths.first()
RenameItemDialog(activity, oldPath) { RenameItemDialog(activity, oldPath) {
activity.config.moveFavorite(oldPath, it) config.moveFavorite(oldPath, it)
activity.runOnUiThread { activity.runOnUiThread {
listener?.refreshFragment() listener?.refreshFragment()
finishActMode() finishActMode()
} }
} }
} }
fileDirItems.any { it.isDirectory } -> RenameItemsDialog(activity, paths) { fileDirItems.any { it.isDirectory } -> RenameItemsDialog(activity, paths) {
activity.runOnUiThread { activity.runOnUiThread {
listener?.refreshFragment() listener?.refreshFragment()
finishActMode() finishActMode()
} }
} }
else -> RenameDialog(activity, paths, false) { else -> RenameDialog(activity, paths, false) {
activity.runOnUiThread { activity.runOnUiThread {
listener?.refreshFragment() listener?.refreshFragment()
@ -247,10 +249,10 @@ class ItemsAdapter(
private fun showProperties() { private fun showProperties() {
if (selectedKeys.size <= 1) { if (selectedKeys.size <= 1) {
PropertiesDialog(activity, getFirstSelectedItemPath(), activity.config.shouldShowHidden) PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden)
} else { } else {
val paths = getSelectedFileDirItems().map { it.path } val paths = getSelectedFileDirItems().map { it.path }
PropertiesDialog(activity, paths, activity.config.shouldShowHidden) PropertiesDialog(activity, paths, config.shouldShowHidden)
} }
} }
@ -338,7 +340,7 @@ class ItemsAdapter(
@SuppressLint("NewApi") @SuppressLint("NewApi")
private fun addFileUris(path: String, paths: ArrayList<String>) { private fun addFileUris(path: String, paths: ArrayList<String>) {
if (activity.getIsPathDirectory(path)) { if (activity.getIsPathDirectory(path)) {
val shouldShowHidden = activity.config.shouldShowHidden val shouldShowHidden = config.shouldShowHidden
when { when {
activity.isRestrictedSAFOnlyRoot(path) -> { activity.isRestrictedSAFOnlyRoot(path) -> {
activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files -> activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files ->
@ -403,11 +405,20 @@ class ItemsAdapter(
val files = getSelectedFileDirItems() val files = getSelectedFileDirItems()
val firstFile = files[0] val firstFile = files[0]
val source = firstFile.getParentPath() val source = firstFile.getParentPath()
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) { FilePickerDialog(
activity,
activity.getDefaultCopyDestinationPath(config.shouldShowHidden, source),
false,
config.shouldShowHidden,
true,
true,
showFavoritesButton = true
) {
config.lastCopyPath = it
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) { if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
copyMoveRootItems(files, it, isCopyOperation) copyMoveRootItems(files, it, isCopyOperation)
} else { } else {
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) { activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden) {
if (!isCopyOperation) { if (!isCopyOperation) {
files.forEach { sourceFileDir -> files.forEach { sourceFileDir ->
val sourcePath = sourceFileDir.path val sourcePath = sourceFileDir.path
@ -737,7 +748,7 @@ class ItemsAdapter(
val files = ArrayList<FileDirItem>(selectedKeys.size) val files = ArrayList<FileDirItem>(selectedKeys.size)
val positions = ArrayList<Int>() val positions = ArrayList<Int>()
selectedKeys.forEach { selectedKeys.forEach {
activity.config.removeFavorite(getItemWithKey(it)?.path ?: "") config.removeFavorite(getItemWithKey(it)?.path ?: "")
val key = it val key = it
val position = listItems.indexOfFirst { it.path.hashCode() == key } val position = listItems.indexOfFirst { it.path.hashCode() == key }
if (position != -1) { if (position != -1) {
@ -779,13 +790,13 @@ class ItemsAdapter(
} }
fun updateDateTimeFormat() { fun updateDateTimeFormat() {
dateFormat = activity.config.dateFormat dateFormat = config.dateFormat
timeFormat = activity.getTimeFormat() timeFormat = activity.getTimeFormat()
notifyDataSetChanged() notifyDataSetChanged()
} }
fun updateDisplayFilenamesInGrid() { fun updateDisplayFilenamesInGrid() {
displayFilenamesInGrid = activity.config.displayFilenames displayFilenamesInGrid = config.displayFilenames
notifyDataSetChanged() notifyDataSetChanged()
} }