add remembering last copy path helpers

This commit is contained in:
fatih ergin 2023-06-24 18:04:14 +03:00
parent 4c83ec8740
commit b90a933569
3 changed files with 21 additions and 0 deletions

View file

@ -991,3 +991,19 @@ fun Context.getFileUrisFromFileDirItems(fileDirItems: List<FileDirItem>): List<U
return fileUris return fileUris
} }
fun Context.getDefaultCopyDestinationPath(showHidden: Boolean, currentPath: String): String {
val lastCopyPath = baseConfig.lastCopyPath
return if (getDoesFilePathExist(lastCopyPath)) {
val isLastCopyPathVisible = !lastCopyPath.split(File.separator).any { it.startsWith(".") && it.length > 1 }
if (showHidden || isLastCopyPathVisible) {
lastCopyPath
} else {
currentPath
}
} else {
currentPath
}
}

View file

@ -195,6 +195,10 @@ open class BaseConfig(val context: Context) {
fun getFolderProtectionType(path: String) = prefs.getInt("$PROTECTED_FOLDER_TYPE$path", PROTECTION_NONE) fun getFolderProtectionType(path: String) = prefs.getInt("$PROTECTED_FOLDER_TYPE$path", PROTECTION_NONE)
var lastCopyPath: String
get() = prefs.getString(LAST_COPY_PATH, "")!!
set(lastCopyPath) = prefs.edit().putString(LAST_COPY_PATH, lastCopyPath).apply()
var keepLastModified: Boolean var keepLastModified: Boolean
get() = prefs.getBoolean(KEEP_LAST_MODIFIED, true) get() = prefs.getBoolean(KEEP_LAST_MODIFIED, true)
set(keepLastModified) = prefs.edit().putBoolean(KEEP_LAST_MODIFIED, keepLastModified).apply() set(keepLastModified) = prefs.edit().putBoolean(KEEP_LAST_MODIFIED, keepLastModified).apply()

View file

@ -121,6 +121,7 @@ const val WAS_CUSTOM_THEME_SWITCH_DESCRIPTION_SHOWN = "was_custom_theme_switch_d
const val SHOW_INFO_BUBBLE = "show_info_bubble" const val SHOW_INFO_BUBBLE = "show_info_bubble"
const val LAST_CONFLICT_RESOLUTION = "last_conflict_resolution" const val LAST_CONFLICT_RESOLUTION = "last_conflict_resolution"
const val LAST_CONFLICT_APPLY_TO_ALL = "last_conflict_apply_to_all" const val LAST_CONFLICT_APPLY_TO_ALL = "last_conflict_apply_to_all"
const val LAST_COPY_PATH = "last_copy_path"
const val HAD_THANK_YOU_INSTALLED = "had_thank_you_installed" const val HAD_THANK_YOU_INSTALLED = "had_thank_you_installed"
const val SKIP_DELETE_CONFIRMATION = "skip_delete_confirmation" const val SKIP_DELETE_CONFIRMATION = "skip_delete_confirmation"
const val ENABLE_PULL_TO_REFRESH = "enable_pull_to_refresh" const val ENABLE_PULL_TO_REFRESH = "enable_pull_to_refresh"