remove the leftovers of the previous copy/move dialog
This commit is contained in:
parent
69aacd57d3
commit
8c457f0a4c
|
@ -10,7 +10,6 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
||||||
import com.bignerdranch.android.multiselector.MultiSelector
|
import com.bignerdranch.android.multiselector.MultiSelector
|
||||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
|
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
|
@ -22,7 +21,6 @@ import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
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.extensions.config
|
import com.simplemobiletools.filemanager.extensions.config
|
||||||
import kotlinx.android.synthetic.main.list_item.view.*
|
import kotlinx.android.synthetic.main.list_item.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -142,28 +140,6 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val files = ArrayList<File>()
|
val files = ArrayList<File>()
|
||||||
val positions = multiSelector.selectedPositions
|
val positions = multiSelector.selectedPositions
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
package com.simplemobiletools.filemanager.dialogs
|
|
||||||
|
|
||||||
import android.support.v4.util.Pair
|
|
||||||
import android.support.v7.app.AlertDialog
|
|
||||||
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
|
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
|
||||||
import com.simplemobiletools.commons.extensions.*
|
|
||||||
import com.simplemobiletools.filemanager.R
|
|
||||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.filemanager.extensions.config
|
|
||||||
import kotlinx.android.synthetic.main.dialog_copy_item.view.*
|
|
||||||
import java.io.File
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val copyMoveListener: CopyMoveTask.CopyMoveListener) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
val context = activity
|
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_copy_item, null)
|
|
||||||
val sourcePath = files[0].parent.trimEnd('/')
|
|
||||||
var destinationPath = ""
|
|
||||||
|
|
||||||
val config = context.config
|
|
||||||
view.destination.setOnClickListener {
|
|
||||||
FilePickerDialog(activity, sourcePath, false, config.showHidden, true) {
|
|
||||||
destinationPath = it
|
|
||||||
view.destination.text = context.humanizePath(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder(context)
|
|
||||||
.setPositiveButton(R.string.ok, null)
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.create().apply {
|
|
||||||
activity.setupDialogStuff(view, this, R.string.copy_move)
|
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
|
||||||
if (destinationPath == context.resources.getString(R.string.select_destination) || destinationPath.isEmpty()) {
|
|
||||||
context.toast(R.string.please_select_destination)
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourcePath == destinationPath.trimEnd('/')) {
|
|
||||||
context.toast(R.string.source_and_destination_same)
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
val destinationDir = File(destinationPath)
|
|
||||||
if (!destinationDir.exists()) {
|
|
||||||
context.toast(R.string.invalid_destination)
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
if (files.size == 1) {
|
|
||||||
if (File(destinationPath, files[0].name).exists()) {
|
|
||||||
context.toast(R.string.name_taken)
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activity.handleSAFDialog(destinationDir) {
|
|
||||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_copy) {
|
|
||||||
context.toast(R.string.copying)
|
|
||||||
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
|
|
||||||
CopyMoveTask(context, false, false, copyMoveListener).execute(pair)
|
|
||||||
dismiss()
|
|
||||||
} else {
|
|
||||||
if (context.isPathOnSD(sourcePath) || context.isPathOnSD(destinationPath)) {
|
|
||||||
activity.handleSAFDialog(files[0]) {
|
|
||||||
context.toast(R.string.moving)
|
|
||||||
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
|
|
||||||
CopyMoveTask(context, true, false, copyMoveListener).execute(pair)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val updatedFiles = ArrayList<File>(files.size * 2)
|
|
||||||
updatedFiles.addAll(files)
|
|
||||||
for (file in files) {
|
|
||||||
val destination = File(destinationDir, file.name)
|
|
||||||
if (!destination.exists() && file.renameTo(destination))
|
|
||||||
updatedFiles.add(destination)
|
|
||||||
}
|
|
||||||
|
|
||||||
context.scanFiles(updatedFiles) {
|
|
||||||
activity.runOnUiThread {
|
|
||||||
copyMoveListener.copySucceeded(true, files.size * 2 == updatedFiles.size)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
view.destination.performClick()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/dialog_holder"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingLeft="@dimen/activity_margin"
|
|
||||||
android:paddingRight="@dimen/activity_margin"
|
|
||||||
android:paddingTop="@dimen/activity_margin">
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
|
||||||
android:id="@+id/destination_label"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/destination"
|
|
||||||
android:textSize="@dimen/smaller_text_size"/>
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
|
||||||
android:id="@+id/destination"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
|
||||||
android:layout_marginLeft="@dimen/activity_margin"
|
|
||||||
android:paddingBottom="@dimen/small_margin"
|
|
||||||
android:paddingRight="@dimen/small_margin"
|
|
||||||
android:paddingTop="@dimen/small_margin"
|
|
||||||
android:text="@string/click_select_destination"/>
|
|
||||||
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/dialog_radio_group"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:checkedButton="@+id/dialog_radio_copy">
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
|
||||||
android:id="@+id/dialog_radio_copy"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="@dimen/medium_margin"
|
|
||||||
android:text="@string/copy"/>
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
|
||||||
android:id="@+id/dialog_radio_move"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/move"/>
|
|
||||||
</RadioGroup>
|
|
||||||
</LinearLayout>
|
|
Loading…
Reference in New Issue