add copy/move
This commit is contained in:
parent
c58811a8ce
commit
66ba8f735a
2 changed files with 36 additions and 34 deletions
|
@ -314,30 +314,6 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
|
||||||
|
|
||||||
private fun isSetWallpaperIntent() = intent.getBooleanExtra(Constants.SET_WALLPAPER_INTENT, false)
|
private fun isSetWallpaperIntent() = intent.getBooleanExtra(Constants.SET_WALLPAPER_INTENT, false)
|
||||||
|
|
||||||
private fun displayCopyDialog() {
|
|
||||||
/*val items = media_grid.checkedItemPositions
|
|
||||||
val cnt = items.size()
|
|
||||||
val files = (0..cnt - 1)
|
|
||||||
.filter { items.valueAt(it) }
|
|
||||||
.map { items.keyAt(it) }
|
|
||||||
.mapTo(ArrayList<File>()) { File(mMedia[it].path) }
|
|
||||||
|
|
||||||
CopyDialog(this, files, object : CopyMoveTask.CopyMoveListener {
|
|
||||||
override fun copySucceeded(deleted: Boolean, copiedAll: Boolean) {
|
|
||||||
if (deleted) {
|
|
||||||
refreshDir()
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val curItemPath = mMedia[position].path
|
val curItemPath = mMedia[position].path
|
||||||
if (isSetWallpaperIntent()) {
|
if (isSetWallpaperIntent()) {
|
||||||
|
@ -377,16 +353,6 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.cab_copy_move -> {
|
|
||||||
displayCopyDialog()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||||
if (mIsSnackbarShown) {
|
if (mIsSnackbarShown) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
|
@ -395,6 +361,10 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun refreshItems() {
|
||||||
|
refreshDir()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRefresh() {
|
override fun onRefresh() {
|
||||||
refreshDir()
|
refreshDir()
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,21 @@ 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.dialogs.ConfirmationDialog
|
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
|
||||||
|
import com.simplemobiletools.filepicker.extensions.toast
|
||||||
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
|
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.extensions.beVisibleIf
|
import com.simplemobiletools.gallery.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.gallery.extensions.shareMedia
|
import com.simplemobiletools.gallery.extensions.shareMedia
|
||||||
import com.simplemobiletools.gallery.extensions.shareMedium
|
import com.simplemobiletools.gallery.extensions.shareMedium
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.photo_video_item.view.*
|
import kotlinx.android.synthetic.main.photo_video_item.view.*
|
||||||
import kotlinx.android.synthetic.main.photo_video_tmb.view.*
|
import kotlinx.android.synthetic.main.photo_video_tmb.view.*
|
||||||
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) :
|
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) :
|
||||||
|
@ -52,6 +56,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
shareMedia()
|
shareMedia()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
R.id.cab_copy_move -> {
|
||||||
|
displayCopyDialog()
|
||||||
|
return true
|
||||||
|
}
|
||||||
R.id.cab_delete -> {
|
R.id.cab_delete -> {
|
||||||
askConfirmDelete()
|
askConfirmDelete()
|
||||||
true
|
true
|
||||||
|
@ -95,6 +103,28 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun displayCopyDialog() {
|
||||||
|
val files = ArrayList<File>()
|
||||||
|
val positions = multiSelector.selectedPositions
|
||||||
|
positions.forEach { files.add(File(media[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() {
|
||||||
|
@ -189,6 +219,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MediaOperationsListener {
|
interface MediaOperationsListener {
|
||||||
|
fun refreshItems()
|
||||||
|
|
||||||
fun prepareForDeleting(paths: ArrayList<String>)
|
fun prepareForDeleting(paths: ArrayList<String>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue