mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 04:28:00 +01:00
remember last used copy destination on "Select destination" picker -> "Other folder"
This commit is contained in:
parent
b972770986
commit
b84faf1763
3 changed files with 27 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.models.Directory
|
||||
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
||||
import java.io.File
|
||||
|
||||
class PickDirectoryDialog(
|
||||
val activity: BaseSimpleActivity,
|
||||
|
@ -38,7 +39,7 @@ class PickDirectoryDialog(
|
|||
private var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
||||
private var showHidden = activity.config.shouldShowHidden
|
||||
private var currentPathPrefix = ""
|
||||
private val config = view.context.config
|
||||
private val config = activity.config
|
||||
private val searchView = view.folder_search_view
|
||||
private val searchEditText = view.findViewById<EditText>(R.id.top_toolbar_search)
|
||||
private val searchViewAppBarLayout = view.findViewById<View>(R.id.top_app_bar_layout)
|
||||
|
@ -169,7 +170,8 @@ class PickDirectoryDialog(
|
|||
|
||||
private fun showOtherFolder() {
|
||||
activity.hideKeyboard(searchEditText)
|
||||
FilePickerDialog(activity, sourcePath, !isPickingCopyMoveDestination && !isPickingFolderForWidget, showHidden, true, true) {
|
||||
FilePickerDialog(activity, getOtherFolderOpeningPath(), !isPickingCopyMoveDestination && !isPickingFolderForWidget, showHidden, true, true) {
|
||||
config.lastCopyPath = it
|
||||
activity.handleLockedFolderOpening(it) { success ->
|
||||
if (success) {
|
||||
callback(it)
|
||||
|
@ -178,6 +180,24 @@ class PickDirectoryDialog(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getOtherFolderOpeningPath(): String {
|
||||
val lastCopyPath = config.lastCopyPath
|
||||
|
||||
val lastCopyPathExist = {
|
||||
activity.getDoesFilePathExist(lastCopyPath)
|
||||
}
|
||||
|
||||
val lastCopyPathVisible = {
|
||||
showHidden || !lastCopyPath.split(File.separator).any { it.startsWith(".") && it.length > 1 }
|
||||
}
|
||||
|
||||
return if (lastCopyPathExist() && lastCopyPathVisible()) {
|
||||
lastCopyPath
|
||||
} else {
|
||||
sourcePath
|
||||
}
|
||||
}
|
||||
|
||||
private fun gotDirectories(newDirs: ArrayList<Directory>) {
|
||||
if (allDirectories.isEmpty()) {
|
||||
allDirectories = newDirs.clone() as ArrayList<Directory>
|
||||
|
|
|
@ -363,6 +363,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getString(LAST_FILEPICKER_PATH, "")!!
|
||||
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
|
||||
get() = prefs.getBoolean(TEMP_SKIP_DELETE_CONFIRMATION, false)
|
||||
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 WAS_NEW_APP_SHOWN = "was_new_app_shown_clock"
|
||||
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_RECYCLE_BIN = "temp_skip_recycle_bin"
|
||||
const val BOTTOM_ACTIONS = "bottom_actions"
|
||||
|
|
Loading…
Reference in a new issue