Merge pull request #2882 from fatihergin/feature/remember-last-used-copy-destination
remember last used copy destination on "Select destination" -> "Other folder"
This commit is contained in:
commit
e7c776b812
3 changed files with 32 additions and 2 deletions
|
@ -20,6 +20,7 @@ import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Directory
|
import com.simplemobiletools.gallery.pro.models.Directory
|
||||||
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class PickDirectoryDialog(
|
class PickDirectoryDialog(
|
||||||
val activity: BaseSimpleActivity,
|
val activity: BaseSimpleActivity,
|
||||||
|
@ -38,7 +39,7 @@ class PickDirectoryDialog(
|
||||||
private var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
private var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
private var showHidden = activity.config.shouldShowHidden
|
private var showHidden = activity.config.shouldShowHidden
|
||||||
private var currentPathPrefix = ""
|
private var currentPathPrefix = ""
|
||||||
private val config = view.context.config
|
private val config = activity.config
|
||||||
private val searchView = view.folder_search_view
|
private val searchView = view.folder_search_view
|
||||||
private val searchEditText = view.findViewById<EditText>(R.id.top_toolbar_search)
|
private val searchEditText = view.findViewById<EditText>(R.id.top_toolbar_search)
|
||||||
private val searchViewAppBarLayout = view.findViewById<View>(R.id.top_app_bar_layout)
|
private val searchViewAppBarLayout = view.findViewById<View>(R.id.top_app_bar_layout)
|
||||||
|
@ -169,7 +170,15 @@ class PickDirectoryDialog(
|
||||||
|
|
||||||
private fun showOtherFolder() {
|
private fun showOtherFolder() {
|
||||||
activity.hideKeyboard(searchEditText)
|
activity.hideKeyboard(searchEditText)
|
||||||
FilePickerDialog(activity, sourcePath, !isPickingCopyMoveDestination && !isPickingFolderForWidget, showHidden, true, true) {
|
FilePickerDialog(
|
||||||
|
activity,
|
||||||
|
getDefaultCopyDestinationPath(sourcePath),
|
||||||
|
!isPickingCopyMoveDestination && !isPickingFolderForWidget,
|
||||||
|
showHidden,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
) {
|
||||||
|
config.lastCopyPath = it
|
||||||
activity.handleLockedFolderOpening(it) { success ->
|
activity.handleLockedFolderOpening(it) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
callback(it)
|
callback(it)
|
||||||
|
@ -178,6 +187,22 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDefaultCopyDestinationPath(currentPath: String): String {
|
||||||
|
val lastCopyPath = config.lastCopyPath
|
||||||
|
|
||||||
|
return if (activity.getDoesFilePathExist(lastCopyPath)) {
|
||||||
|
val isLastCopyPathVisible = !lastCopyPath.split(File.separator).any { it.startsWith(".") && it.length > 1 }
|
||||||
|
|
||||||
|
if (showHidden || isLastCopyPathVisible) {
|
||||||
|
lastCopyPath
|
||||||
|
} else {
|
||||||
|
currentPath
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun gotDirectories(newDirs: ArrayList<Directory>) {
|
private fun gotDirectories(newDirs: ArrayList<Directory>) {
|
||||||
if (allDirectories.isEmpty()) {
|
if (allDirectories.isEmpty()) {
|
||||||
allDirectories = newDirs.clone() as ArrayList<Directory>
|
allDirectories = newDirs.clone() as ArrayList<Directory>
|
||||||
|
|
|
@ -363,6 +363,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getString(LAST_FILEPICKER_PATH, "")!!
|
get() = prefs.getString(LAST_FILEPICKER_PATH, "")!!
|
||||||
set(lastFilepickerPath) = prefs.edit().putString(LAST_FILEPICKER_PATH, lastFilepickerPath).apply()
|
set(lastFilepickerPath) = prefs.edit().putString(LAST_FILEPICKER_PATH, lastFilepickerPath).apply()
|
||||||
|
|
||||||
|
var lastCopyPath: String
|
||||||
|
get() = prefs.getString(LAST_COPY_PATH, "")!!
|
||||||
|
set(lastCopyPath) = prefs.edit().putString(LAST_COPY_PATH, lastCopyPath).apply()
|
||||||
|
|
||||||
var tempSkipDeleteConfirmation: Boolean
|
var tempSkipDeleteConfirmation: Boolean
|
||||||
get() = prefs.getBoolean(TEMP_SKIP_DELETE_CONFIRMATION, false)
|
get() = prefs.getBoolean(TEMP_SKIP_DELETE_CONFIRMATION, false)
|
||||||
set(tempSkipDeleteConfirmation) = prefs.edit().putBoolean(TEMP_SKIP_DELETE_CONFIRMATION, tempSkipDeleteConfirmation).apply()
|
set(tempSkipDeleteConfirmation) = prefs.edit().putBoolean(TEMP_SKIP_DELETE_CONFIRMATION, tempSkipDeleteConfirmation).apply()
|
||||||
|
|
|
@ -56,6 +56,7 @@ const val HIDE_EXTENDED_DETAILS = "hide_extended_details"
|
||||||
const val ALLOW_INSTANT_CHANGE = "allow_instant_change"
|
const val ALLOW_INSTANT_CHANGE = "allow_instant_change"
|
||||||
const val WAS_NEW_APP_SHOWN = "was_new_app_shown_clock"
|
const val WAS_NEW_APP_SHOWN = "was_new_app_shown_clock"
|
||||||
const val LAST_FILEPICKER_PATH = "last_filepicker_path"
|
const val LAST_FILEPICKER_PATH = "last_filepicker_path"
|
||||||
|
const val LAST_COPY_PATH = "last_copy_path"
|
||||||
const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation"
|
const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation"
|
||||||
const val TEMP_SKIP_RECYCLE_BIN = "temp_skip_recycle_bin"
|
const val TEMP_SKIP_RECYCLE_BIN = "temp_skip_recycle_bin"
|
||||||
const val BOTTOM_ACTIONS = "bottom_actions"
|
const val BOTTOM_ACTIONS = "bottom_actions"
|
||||||
|
|
Loading…
Reference in a new issue