fix #1028, disable the Move operation on items at the recycle bin

This commit is contained in:
tibbi 2018-10-28 20:09:20 +01:00
parent 9f14626f84
commit a37170662c
3 changed files with 19 additions and 3 deletions

View File

@ -48,7 +48,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.2.11'
implementation 'com.simplemobiletools:commons:5.2.13'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'

View File

@ -25,6 +25,7 @@ import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.view.animation.DecelerateInterpolator
import android.widget.Toast
import androidx.viewpager.widget.ViewPager
import com.bumptech.glide.Glide
import com.simplemobiletools.commons.dialogs.PropertiesDialog
@ -524,6 +525,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun copyMoveTo(isCopyOperation: Boolean) {
val currPath = getCurrentPath()
if (!isCopyOperation && currPath.startsWith(recycleBinPath)) {
toast(R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG)
return
}
val fileDirItems = arrayListOf(FileDirItem(currPath, currPath.getFilenameFromPath()))
tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
config.tempFolderPath = ""

View File

@ -8,6 +8,7 @@ import android.provider.MediaStore
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.bumptech.glide.Glide
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
@ -277,9 +278,18 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
private fun copyMoveTo(isCopyOperation: Boolean) {
val paths = getSelectedPaths()
val fileDirItems = paths.map {
val recycleBinPath = activity.recycleBinPath
val fileDirItems = paths.asSequence().filter { isCopyOperation || !it.startsWith(recycleBinPath) }.map {
FileDirItem(it, it.getFilenameFromPath())
} as ArrayList
}.toMutableList() as ArrayList
if (!isCopyOperation && paths.any { it.startsWith(recycleBinPath) }) {
activity.toast(R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG)
}
if (fileDirItems.isEmpty()) {
return
}
activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
config.tempFolderPath = ""