add copy/move
This commit is contained in:
parent
9ea00c32f2
commit
9a555cc2f9
|
@ -13,7 +13,9 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.simplemobiletools.filemanager.Config
|
import com.simplemobiletools.filemanager.Config
|
||||||
import com.simplemobiletools.filemanager.R
|
import com.simplemobiletools.filemanager.R
|
||||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.dialogs.CopyDialog
|
||||||
import com.simplemobiletools.filemanager.dialogs.RenameItemDialog
|
import com.simplemobiletools.filemanager.dialogs.RenameItemDialog
|
||||||
|
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
||||||
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
|
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.filepicker.extensions.formatSize
|
import com.simplemobiletools.filepicker.extensions.formatSize
|
||||||
import com.simplemobiletools.filepicker.extensions.isGif
|
import com.simplemobiletools.filepicker.extensions.isGif
|
||||||
|
@ -61,6 +63,10 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List<FileDirItem>,
|
||||||
shareFiles()
|
shareFiles()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.cab_copy_move -> {
|
||||||
|
displayCopyDialog()
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.cab_delete -> {
|
R.id.cab_delete -> {
|
||||||
askConfirmDelete()
|
askConfirmDelete()
|
||||||
true
|
true
|
||||||
|
@ -130,6 +136,28 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List<FileDirItem>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun displayCopyDialog() {
|
||||||
|
val files = ArrayList<File>()
|
||||||
|
val positions = multiSelector.selectedPositions
|
||||||
|
positions.forEach { files.add(File(mItems[it].path)) }
|
||||||
|
|
||||||
|
CopyDialog(activity, files, object : CopyMoveTask.CopyMoveListener {
|
||||||
|
override fun copySucceeded(deleted: Boolean, copiedAll: Boolean) {
|
||||||
|
if (deleted) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
listener?.refreshItems()
|
||||||
|
actMode?.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun copyFailed() {
|
||||||
|
activity.toast(R.string.copy_move_failed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
ConfirmationDialog(activity, listener = object : ConfirmationDialog.OnConfirmedListener {
|
ConfirmationDialog(activity, listener = object : ConfirmationDialog.OnConfirmedListener {
|
||||||
override fun onConfirmed() {
|
override fun onConfirmed() {
|
||||||
|
|
|
@ -15,9 +15,7 @@ import com.simplemobiletools.filemanager.PATH
|
||||||
import com.simplemobiletools.filemanager.R
|
import com.simplemobiletools.filemanager.R
|
||||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||||
import com.simplemobiletools.filemanager.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.adapters.ItemsAdapter
|
||||||
import com.simplemobiletools.filemanager.dialogs.CopyDialog
|
|
||||||
import com.simplemobiletools.filemanager.dialogs.CreateNewItemDialog
|
import com.simplemobiletools.filemanager.dialogs.CreateNewItemDialog
|
||||||
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
|
||||||
import com.simplemobiletools.filepicker.extensions.*
|
import com.simplemobiletools.filepicker.extensions.*
|
||||||
import com.simplemobiletools.filepicker.models.FileDirItem
|
import com.simplemobiletools.filepicker.models.FileDirItem
|
||||||
import com.simplemobiletools.filepicker.views.RecyclerViewDivider
|
import com.simplemobiletools.filepicker.views.RecyclerViewDivider
|
||||||
|
@ -174,52 +172,6 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
|
||||||
return type + "/*"
|
return type + "/*"
|
||||||
}
|
}
|
||||||
|
|
||||||
/*override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.cab_copy -> {
|
|
||||||
displayCopyDialog()
|
|
||||||
mode.finish()
|
|
||||||
}
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private fun displayCopyDialog() {
|
|
||||||
val fileIndexes = getSelectedItemIndexes()
|
|
||||||
if (fileIndexes.isEmpty())
|
|
||||||
return
|
|
||||||
|
|
||||||
val files = ArrayList<File>(fileIndexes.size)
|
|
||||||
fileIndexes.mapTo(files) { File(mItems[it].path) }
|
|
||||||
|
|
||||||
CopyDialog(activity as SimpleActivity, files, object : CopyMoveTask.CopyMoveListener {
|
|
||||||
override fun copySucceeded(deleted: Boolean, copiedAll: Boolean) {
|
|
||||||
if (deleted) {
|
|
||||||
context.toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial)
|
|
||||||
} else {
|
|
||||||
context.toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial)
|
|
||||||
}
|
|
||||||
fillItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun copyFailed() {
|
|
||||||
context.toast(R.string.copy_move_failed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSelectedItemIndexes(): List<Int> {
|
|
||||||
/*val items = items_list.checkedItemPositions
|
|
||||||
val cnt = items.size()
|
|
||||||
val selectedItems = (0..cnt - 1)
|
|
||||||
.filter { items.valueAt(it) }
|
|
||||||
.map { items.keyAt(it) }
|
|
||||||
return selectedItems*/
|
|
||||||
return ArrayList()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun prepareForDeleting(paths: ArrayList<String>) {
|
override fun prepareForDeleting(paths: ArrayList<String>) {
|
||||||
activity.toast(R.string.deleting)
|
activity.toast(R.string.deleting)
|
||||||
mToBeDeleted = paths
|
mToBeDeleted = paths
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
android:title="@string/share"
|
android:title="@string/share"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_copy"
|
android:id="@+id/cab_copy_move"
|
||||||
android:icon="@mipmap/copy"
|
android:icon="@mipmap/copy"
|
||||||
android:title="@string/copy_move"
|
android:title="@string/copy_move"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
Loading…
Reference in New Issue