show the temp folder at Copy/move dialog too

This commit is contained in:
tibbi 2017-09-05 22:18:46 +02:00
parent 189f9b7410
commit 54a4d29233
6 changed files with 21 additions and 15 deletions

View file

@ -211,7 +211,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mLoadedInitialPhotos = true
mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) {
addTempFolderIfNeeded(it, false)
gotDirectories(addTempFolderIfNeeded(it), false)
}
mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
}
@ -316,22 +316,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) {
CreateNewFolderDialog(this, it) {
config.tempFolderPath = it
addTempFolderIfNeeded(mDirs, true)
gotDirectories(addTempFolderIfNeeded(mDirs), true)
}
}
}
private fun addTempFolderIfNeeded(dirs: ArrayList<Directory>, isFromCache: Boolean) {
val directories = ArrayList<Directory>()
val tempFolderPath = config.tempFolderPath
if (tempFolderPath.isNotEmpty()) {
val newFolder = Directory(tempFolderPath, "", tempFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
directories.add(newFolder)
}
directories.addAll(dirs)
gotDirectories(directories, isFromCache)
}
private fun increaseColumnCount() {
config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount
invalidateOptionsMenu()

View file

@ -1,9 +1,12 @@
package com.simplemobiletools.gallery.activities
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getFilenameFromPath
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.dialogs.PickDirectoryDialog
import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.models.Directory
import java.io.File
import java.util.*
@ -19,4 +22,15 @@ open class SimpleActivity : BaseSimpleActivity() {
copyMoveFilesTo(files, source.trimEnd('/'), it, isCopyOperation, true, callback)
}
}
fun addTempFolderIfNeeded(dirs: ArrayList<Directory>): ArrayList<Directory> {
val directories = ArrayList<Directory>()
val tempFolderPath = config.tempFolderPath
if (tempFolderPath.isNotEmpty()) {
val newFolder = Directory(tempFolderPath, "", tempFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
directories.add(newFolder)
}
directories.addAll(dirs)
return directories
}
}

View file

@ -405,6 +405,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun copyMoveTo(isCopyOperation: Boolean) {
val files = ArrayList<File>(1).apply { add(getCurrentFile()) }
tryCopyMoveFilesTo(files, isCopyOperation) {
config.tempFolderPath = ""
if (!isCopyOperation) {
reloadViewPager()
}

View file

@ -234,6 +234,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
}
activity.tryCopyMoveFilesTo(files, isCopyOperation) {
config.tempFolderPath = ""
listener?.refreshItems()
actMode?.finish()
}

View file

@ -174,6 +174,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
selectedPositions.forEach { files.add(File(media[it].path)) }
activity.tryCopyMoveFilesTo(files, isCopyOperation) {
config.tempFolderPath = ""
if (!isCopyOperation) {
listener?.refreshItems()
}

View file

@ -38,11 +38,11 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String,
val dirs = activity.getCachedDirectories()
if (dirs.isNotEmpty()) {
gotDirectories(dirs)
gotDirectories(activity.addTempFolderIfNeeded(dirs))
}
GetDirectoriesAsynctask(activity, false, false) {
gotDirectories(it)
gotDirectories(activity.addTempFolderIfNeeded(it))
}.execute()
}
}