use the copy function of the Commons library
This commit is contained in:
parent
40ce55a55e
commit
69aacd57d3
3 changed files with 27 additions and 6 deletions
|
@ -32,7 +32,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.16.9'
|
||||
compile 'com.simplemobiletools:commons:2.17.2'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.bignerdranch.android.multiselector.SwappingHolder
|
|||
import com.bumptech.glide.Glide
|
||||
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.formatSize
|
||||
|
@ -73,7 +74,8 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||
R.id.cab_rename -> displayRenameDialog()
|
||||
R.id.cab_properties -> showProperties()
|
||||
R.id.cab_share -> shareFiles()
|
||||
R.id.cab_copy_move -> displayCopyDialog()
|
||||
R.id.cab_copy_to -> copyMoveTo(true)
|
||||
R.id.cab_move_to -> copyMoveTo(false)
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
else -> return false
|
||||
}
|
||||
|
@ -162,6 +164,22 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||
})
|
||||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val files = ArrayList<File>()
|
||||
val positions = multiSelector.selectedPositions
|
||||
positions.forEach { files.add(File(mItems[it].path)) }
|
||||
|
||||
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
||||
FilePickerDialog(activity, source, false, config.showHidden, true) {
|
||||
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false) {
|
||||
if (!isCopyOperation) {
|
||||
listener?.refreshItems()
|
||||
}
|
||||
actMode?.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
actMode?.finish()
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/cab_copy_move"
|
||||
android:icon="@drawable/ic_copy"
|
||||
android:title="@string/copy_move"
|
||||
app:showAsAction="ifRoom"/>
|
||||
android:id="@+id/cab_copy_to"
|
||||
android:title="@string/copy_to"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/cab_move_to"
|
||||
android:title="@string/move_to"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
|
|
Loading…
Reference in a new issue