Skip to content

Commit 8e67656

Browse files
committed
remember last used copy destination on "Select a folder" picker
1 parent a88a271 commit 8e67656

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ android {
6464
}
6565

6666
dependencies {
67-
implementation 'com.github.SimpleMobileTools:Simple-Commons:4c83ec8740'
67+
implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592'
6868
implementation 'com.github.tibbi:PdfViewPager:d2af24208d'
6969
implementation 'com.github.Stericson:RootTools:df729dcb13'
7070
implementation 'com.github.Stericson:RootShell:1.6'

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ItemsAdapter(
8585
setupDragListener(true)
8686
initDrawables()
8787
updateFontSizes()
88-
dateFormat = activity.config.dateFormat
88+
dateFormat = config.dateFormat
8989
timeFormat = activity.getTimeFormat()
9090
}
9191

@@ -223,19 +223,21 @@ class ItemsAdapter(
223223
paths.size == 1 -> {
224224
val oldPath = paths.first()
225225
RenameItemDialog(activity, oldPath) {
226-
activity.config.moveFavorite(oldPath, it)
226+
config.moveFavorite(oldPath, it)
227227
activity.runOnUiThread {
228228
listener?.refreshFragment()
229229
finishActMode()
230230
}
231231
}
232232
}
233+
233234
fileDirItems.any { it.isDirectory } -> RenameItemsDialog(activity, paths) {
234235
activity.runOnUiThread {
235236
listener?.refreshFragment()
236237
finishActMode()
237238
}
238239
}
240+
239241
else -> RenameDialog(activity, paths, false) {
240242
activity.runOnUiThread {
241243
listener?.refreshFragment()
@@ -247,10 +249,10 @@ class ItemsAdapter(
247249

248250
private fun showProperties() {
249251
if (selectedKeys.size <= 1) {
250-
PropertiesDialog(activity, getFirstSelectedItemPath(), activity.config.shouldShowHidden)
252+
PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden)
251253
} else {
252254
val paths = getSelectedFileDirItems().map { it.path }
253-
PropertiesDialog(activity, paths, activity.config.shouldShowHidden)
255+
PropertiesDialog(activity, paths, config.shouldShowHidden)
254256
}
255257
}
256258

@@ -338,7 +340,7 @@ class ItemsAdapter(
338340
@SuppressLint("NewApi")
339341
private fun addFileUris(path: String, paths: ArrayList<String>) {
340342
if (activity.getIsPathDirectory(path)) {
341-
val shouldShowHidden = activity.config.shouldShowHidden
343+
val shouldShowHidden = config.shouldShowHidden
342344
when {
343345
activity.isRestrictedSAFOnlyRoot(path) -> {
344346
activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files ->
@@ -403,11 +405,20 @@ class ItemsAdapter(
403405
val files = getSelectedFileDirItems()
404406
val firstFile = files[0]
405407
val source = firstFile.getParentPath()
406-
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
408+
FilePickerDialog(
409+
activity,
410+
activity.getDefaultCopyDestinationPath(config.shouldShowHidden, source),
411+
false,
412+
config.shouldShowHidden,
413+
true,
414+
true,
415+
showFavoritesButton = true
416+
) {
417+
config.lastCopyPath = it
407418
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
408419
copyMoveRootItems(files, it, isCopyOperation)
409420
} else {
410-
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) {
421+
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden) {
411422
if (!isCopyOperation) {
412423
files.forEach { sourceFileDir ->
413424
val sourcePath = sourceFileDir.path
@@ -737,7 +748,7 @@ class ItemsAdapter(
737748
val files = ArrayList<FileDirItem>(selectedKeys.size)
738749
val positions = ArrayList<Int>()
739750
selectedKeys.forEach {
740-
activity.config.removeFavorite(getItemWithKey(it)?.path ?: "")
751+
config.removeFavorite(getItemWithKey(it)?.path ?: "")
741752
val key = it
742753
val position = listItems.indexOfFirst { it.path.hashCode() == key }
743754
if (position != -1) {
@@ -779,13 +790,13 @@ class ItemsAdapter(
779790
}
780791

781792
fun updateDateTimeFormat() {
782-
dateFormat = activity.config.dateFormat
793+
dateFormat = config.dateFormat
783794
timeFormat = activity.getTimeFormat()
784795
notifyDataSetChanged()
785796
}
786797

787798
fun updateDisplayFilenamesInGrid() {
788-
displayFilenamesInGrid = activity.config.displayFilenames
799+
displayFilenamesInGrid = config.displayFilenames
789800
notifyDataSetChanged()
790801
}
791802

0 commit comments

Comments
 (0)