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 b20435c21..46b19c78b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -233,38 +233,6 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get getDirectories() } - override fun refreshItems() { - getDirectories() - } - - private fun displayCopyDialog() { - val files = ArrayList() - /*val items = directories_grid.checkedItemPositions - val cnt = items.size() - for (i in 0..cnt - 1) { - if (items.valueAt(i)) { - val id = items.keyAt(i) - val dir = File(mDirs[id].path) - files.addAll(dir.listFiles()) - } - } - - CopyDialog(this, files, object : CopyMoveTask.CopyMoveListener { - override fun copySucceeded(deleted: Boolean, copiedAll: Boolean) { - if (deleted) { - getDirectories() - toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial) - } else { - toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial) - } - } - - override fun copyFailed() { - toast(R.string.copy_move_failed) - } - })*/ - } - private fun isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent)) private fun isPickVideoIntent(intent: Intent) = isPickIntent(intent) && (hasVideoContentData(intent) || isVideoType(intent)) @@ -340,10 +308,6 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get mode.finish() true } - R.id.cab_copy_move -> { - displayCopyDialog() - true - } else -> false } } @@ -373,4 +337,8 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get } directories_grid.adapter = adapter } + + override fun refreshItems() { + getDirectories() + } } 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 3c22cd4fa..2d1424c6d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -10,6 +10,7 @@ import com.bignerdranch.android.multiselector.SwappingHolder import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.signature.StringSignature +import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder import com.simplemobiletools.filepicker.extensions.scanPaths import com.simplemobiletools.filepicker.extensions.toast @@ -17,6 +18,7 @@ import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog import com.simplemobiletools.gallery.Config import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity +import com.simplemobiletools.gallery.dialogs.CopyDialog import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.directory_item.view.* @@ -43,7 +45,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { showProperties() @@ -55,10 +57,16 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { hideDirs() + mode.finish() true } R.id.cab_unhide -> { unhideDir() + mode.finish() + true + } + R.id.cab_copy_move -> { + displayCopyDialog() true } else -> false @@ -133,13 +141,33 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList() + val positions = multiSelector.selectedPositions + positions.forEach { files.add(File(dirs[it].path)) } + + CopyDialog(activity, files, object : CopyMoveTask.CopyMoveListener { + override fun copySucceeded(deleted: Boolean, copiedAll: Boolean) { + if (deleted) { + listener?.refreshItems() + activity.toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial) + } else { + activity.toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial) + } + actMode?.finish() + } + + override fun copyFailed() { + activity.toast(R.string.copy_move_failed) + } + }) } private fun getSelectedPaths(): HashSet {