add dir copying/moving
This commit is contained in:
parent
53aa8e86d7
commit
af246cdcf0
2 changed files with 35 additions and 39 deletions
|
@ -233,38 +233,6 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get
|
||||||
getDirectories()
|
getDirectories()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshItems() {
|
|
||||||
getDirectories()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun displayCopyDialog() {
|
|
||||||
val files = ArrayList<File>()
|
|
||||||
/*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 isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent))
|
||||||
|
|
||||||
private fun isPickVideoIntent(intent: Intent) = isPickIntent(intent) && (hasVideoContentData(intent) || isVideoType(intent))
|
private fun isPickVideoIntent(intent: Intent) = isPickIntent(intent) && (hasVideoContentData(intent) || isVideoType(intent))
|
||||||
|
@ -340,10 +308,6 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get
|
||||||
mode.finish()
|
mode.finish()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.cab_copy_move -> {
|
|
||||||
displayCopyDialog()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,4 +337,8 @@ class MainActivity : SimpleActivity(), SwipeRefreshLayout.OnRefreshListener, Get
|
||||||
}
|
}
|
||||||
directories_grid.adapter = adapter
|
directories_grid.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun refreshItems() {
|
||||||
|
getDirectories()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.bignerdranch.android.multiselector.SwappingHolder
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.signature.StringSignature
|
import com.bumptech.glide.signature.StringSignature
|
||||||
|
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
||||||
import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
|
import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
|
||||||
import com.simplemobiletools.filepicker.extensions.scanPaths
|
import com.simplemobiletools.filepicker.extensions.scanPaths
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
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.Config
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import kotlinx.android.synthetic.main.directory_item.view.*
|
import kotlinx.android.synthetic.main.directory_item.view.*
|
||||||
|
@ -43,7 +45,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
return when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.cab_properties -> {
|
R.id.cab_properties -> {
|
||||||
showProperties()
|
showProperties()
|
||||||
|
@ -55,10 +57,16 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
R.id.cab_hide -> {
|
R.id.cab_hide -> {
|
||||||
hideDirs()
|
hideDirs()
|
||||||
|
mode.finish()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.cab_unhide -> {
|
R.id.cab_unhide -> {
|
||||||
unhideDir()
|
unhideDir()
|
||||||
|
mode.finish()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
R.id.cab_copy_move -> {
|
||||||
|
displayCopyDialog()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
|
@ -133,15 +141,35 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
private fun hideDirs() {
|
private fun hideDirs() {
|
||||||
config.addHiddenDirectories(getSelectedPaths())
|
config.addHiddenDirectories(getSelectedPaths())
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unhideDir() {
|
private fun unhideDir() {
|
||||||
config.removeHiddenDirectories(getSelectedPaths())
|
config.removeHiddenDirectories(getSelectedPaths())
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun displayCopyDialog() {
|
||||||
|
val files = ArrayList<File>()
|
||||||
|
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()
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun copyFailed() {
|
||||||
|
activity.toast(R.string.copy_move_failed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private fun getSelectedPaths(): HashSet<String> {
|
private fun getSelectedPaths(): HashSet<String> {
|
||||||
val positions = multiSelector.selectedPositions
|
val positions = multiSelector.selectedPositions
|
||||||
val paths = HashSet<String>()
|
val paths = HashSet<String>()
|
||||||
|
|
Loading…
Reference in a new issue