Skip to content

Commit bda0325

Browse files
authored
Merge pull request #713 from fatihergin/feature/remember-last-used-copy-destination
remember last used copy destination on "Select a folder" picker
2 parents a88a271 + f6332b0 commit bda0325

File tree

12 files changed

+44
-30
lines changed

12 files changed

+44
-30
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/activities/FavoritesActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
6565
}
6666

6767
private fun addFavorite() {
68-
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, canAddShowHiddenButton = true) {
68+
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), canAddShowHiddenButton = true) {
6969
config.addFavorite(it)
7070
updateFavorites()
7171
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class MainActivity : SimpleActivity() {
188188
findItem(R.id.go_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
189189
findItem(R.id.set_as_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
190190

191-
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
191+
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden() && currentFragment !is StorageFragment
192192
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden && currentFragment !is StorageFragment
193193

194194
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID && currentFragment !is StorageFragment

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.simplemobiletools.filemanager.pro.helpers.*
2929
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
3030
import com.simplemobiletools.filemanager.pro.models.ListItem
3131
import kotlinx.android.synthetic.main.activity_mimetypes.*
32-
import java.util.*
32+
import java.util.Locale
3333

3434
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
3535
private var isSearchOpen = false
@@ -86,7 +86,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
8686
mimetypes_toolbar.menu.apply {
8787
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
8888

89-
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
89+
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden()
9090
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
9191

9292
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID
@@ -255,7 +255,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
255255

256256
private fun getProperFileDirItems(callback: (ArrayList<FileDirItem>) -> Unit) {
257257
val fileDirItems = ArrayList<FileDirItem>()
258-
val showHidden = config.shouldShowHidden
258+
val showHidden = config.shouldShowHidden()
259259
val uri = MediaStore.Files.getContentUri("external")
260260
val projection = arrayOf(
261261
MediaStore.Files.FileColumns.MIME_TYPE,

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SaveAsActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.simplemobiletools.commons.helpers.NavigationIcon
99
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1010
import com.simplemobiletools.filemanager.pro.R
1111
import com.simplemobiletools.filemanager.pro.extensions.config
12-
import kotlinx.android.synthetic.main.activity_save_as.*
12+
import kotlinx.android.synthetic.main.activity_save_as.activity_save_as_toolbar
1313
import java.io.File
1414

1515
class SaveAsActivity : SimpleActivity() {
@@ -18,7 +18,7 @@ class SaveAsActivity : SimpleActivity() {
1818
setContentView(R.layout.activity_save_as)
1919

2020
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
21-
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, showFAB = true, showFavoritesButton = true) {
21+
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
2222
val destination = it
2323
handleSAFDialog(destination) {
2424
toast(R.string.saving)

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

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/CompressAsDialog.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
77
import com.simplemobiletools.commons.extensions.*
88
import com.simplemobiletools.filemanager.pro.R
99
import com.simplemobiletools.filemanager.pro.extensions.config
10-
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
10+
import kotlinx.android.synthetic.main.dialog_compress_as.view.filename_value
11+
import kotlinx.android.synthetic.main.dialog_compress_as.view.folder
1112

1213
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
1314
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
@@ -23,7 +24,7 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
2324

2425
folder.setText(activity.humanizePath(realPath))
2526
folder.setOnClickListener {
26-
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
27+
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden(), true, true, showFavoritesButton = true) {
2728
folder.setText(activity.humanizePath(it))
2829
realPath = it
2930
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
9999

100100
scrollStates[currentPath] = getScrollState()!!
101101
currentPath = realPath
102-
showHidden = context!!.config.shouldShowHidden
102+
showHidden = context!!.config.shouldShowHidden()
103103
showProgressBar()
104104
getItems(currentPath) { originalPath, listItems ->
105105
if (currentPath != originalPath) {
@@ -180,13 +180,13 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
180180
return@handleAndroidSAFDialog
181181
}
182182
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
183-
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
183+
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden(), getProperChildCount) { fileItems ->
184184
callback(path, getListItemsFromFileDirItems(fileItems))
185185
}
186186
}
187187
} else if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
188188
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
189-
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) {
189+
context!!.getOTGItems(path, config.shouldShowHidden(), getProperFileSize) {
190190
callback(path, getListItemsFromFileDirItems(it))
191191
}
192192
} else if (!config.enableRootAccess || !context!!.isPathOnRoot(path)) {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import com.simplemobiletools.filemanager.pro.extensions.config
2121
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
2222
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
2323
import com.simplemobiletools.filemanager.pro.models.ListItem
24-
import kotlinx.android.synthetic.main.recents_fragment.view.*
24+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_list
25+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_placeholder
26+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_swipe_refresh
2527
import java.io.File
2628

2729
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
@@ -134,7 +136,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
134136
}
135137

136138
private fun getRecents(callback: (recents: ArrayList<ListItem>) -> Unit) {
137-
val showHidden = context?.config?.shouldShowHidden ?: return
139+
val showHidden = context?.config?.shouldShowHidden() ?: return
138140
val listItems = arrayListOf<ListItem>()
139141

140142
val uri = Files.getContentUri("external")

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
318318

319319
private fun getAllFiles(): ArrayList<FileDirItem> {
320320
val fileDirItems = ArrayList<FileDirItem>()
321-
val showHidden = context?.config?.shouldShowHidden ?: return fileDirItems
321+
val showHidden = context?.config?.shouldShowHidden() ?: return fileDirItems
322322
val uri = MediaStore.Files.getContentUri("external")
323323
val projection = arrayOf(
324324
MediaStore.Files.FileColumns.DATA,

0 commit comments

Comments
 (0)