do not allow picking the source folder as the destination at copy/move
This commit is contained in:
parent
9cae71b7ab
commit
4b104fc8d6
2 changed files with 10 additions and 4 deletions
|
@ -24,7 +24,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
||||||
var destinationPath = ""
|
var destinationPath = ""
|
||||||
|
|
||||||
view.destination.setOnClickListener {
|
view.destination.setOnClickListener {
|
||||||
PickAlbumDialog(activity) {
|
PickAlbumDialog(activity, sourcePath) {
|
||||||
destinationPath = it
|
destinationPath = it
|
||||||
view.destination.text = activity.humanizePath(it)
|
view.destination.text = activity.humanizePath(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.support.v7.widget.RecyclerView
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
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.adapters.DirectoryAdapter
|
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||||
|
@ -13,7 +14,7 @@ import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_album_picker.view.*
|
import kotlinx.android.synthetic.main.dialog_album_picker.view.*
|
||||||
|
|
||||||
class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String) -> Unit) {
|
class PickAlbumDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) {
|
||||||
var directoriesGrid: RecyclerView
|
var directoriesGrid: RecyclerView
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -29,8 +30,13 @@ class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String)
|
||||||
|
|
||||||
GetDirectoriesAsynctask(activity, false, false) {
|
GetDirectoriesAsynctask(activity, false, false) {
|
||||||
val adapter = DirectoryAdapter(activity, it, null) {
|
val adapter = DirectoryAdapter(activity, it, null) {
|
||||||
callback.invoke(it.path)
|
if (it.path.trimEnd('/') == sourcePath) {
|
||||||
dismiss()
|
activity.toast(R.string.source_and_destination_same)
|
||||||
|
return@DirectoryAdapter
|
||||||
|
} else {
|
||||||
|
callback.invoke(it.path)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
directoriesGrid.adapter = adapter
|
directoriesGrid.adapter = adapter
|
||||||
}.execute()
|
}.execute()
|
||||||
|
|
Loading…
Reference in a new issue