move last used copy path helpers to common

This commit is contained in:
fatih ergin 2023-06-25 12:53:41 +03:00
parent 4cc164668c
commit 688cdece7d
3 changed files with 3 additions and 24 deletions

View file

@ -78,7 +78,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:d6cddfa7d8' implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'

View file

@ -20,7 +20,6 @@ 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,
@ -172,7 +171,7 @@ class PickDirectoryDialog(
activity.hideKeyboard(searchEditText) activity.hideKeyboard(searchEditText)
FilePickerDialog( FilePickerDialog(
activity, activity,
getDefaultCopyDestinationPath(sourcePath), activity.getDefaultCopyDestinationPath(showHidden, sourcePath),
!isPickingCopyMoveDestination && !isPickingFolderForWidget, !isPickingCopyMoveDestination && !isPickingFolderForWidget,
showHidden, showHidden,
true, true,
@ -187,22 +186,6 @@ 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>

View file

@ -8,7 +8,7 @@ import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.AlbumCover
import java.util.* import java.util.Arrays
class Config(context: Context) : BaseConfig(context) { class Config(context: Context) : BaseConfig(context) {
companion object { companion object {
@ -363,10 +363,6 @@ 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()