diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index ad77fa735..38d8cafc1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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, isFromCache: Boolean) { - val directories = ArrayList() - 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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt index 6cfd6eb38..f30d65e31 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -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): ArrayList { + val directories = ArrayList() + 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 + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 87f0129cc..6318293ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -405,6 +405,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun copyMoveTo(isCopyOperation: Boolean) { val files = ArrayList(1).apply { add(getCurrentFile()) } tryCopyMoveFilesTo(files, isCopyOperation) { + config.tempFolderPath = "" if (!isCopyOperation) { reloadViewPager() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 7e7a10d01..08e08e439 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -234,6 +234,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, selectedPositions.forEach { files.add(File(media[it].path)) } activity.tryCopyMoveFilesTo(files, isCopyOperation) { + config.tempFolderPath = "" if (!isCopyOperation) { listener?.refreshItems() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index 39d0ca7f2..a52a395cd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -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() } }