mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
a few more Move adjustments
This commit is contained in:
@ -6,16 +6,15 @@ import android.support.v4.util.Pair
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import com.simplemobiletools.filemanager.Config
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.Utils
|
||||
import com.simplemobiletools.filemanager.activities.MainActivity
|
||||
import com.simplemobiletools.filemanager.asynctasks.CopyTask
|
||||
import com.simplemobiletools.filemanager.extensions.isPathOnSD
|
||||
import com.simplemobiletools.filemanager.extensions.rescanItem
|
||||
import com.simplemobiletools.filemanager.extensions.toast
|
||||
import com.simplemobiletools.filepicker.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.filepicker.extensions.getBasePath
|
||||
import com.simplemobiletools.filepicker.extensions.humanizePath
|
||||
import kotlinx.android.synthetic.main.copy_item.view.*
|
||||
import java.io.File
|
||||
@ -88,23 +87,23 @@ class CopyDialog(val activity: Activity, val files: List<File>, val copyListener
|
||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_copy) {
|
||||
context.toast(R.string.copying)
|
||||
val pair = Pair<List<File>, File>(files, destinationDir)
|
||||
CopyTask(copyListener, context).execute(pair)
|
||||
CopyTask(copyListener, context, false).execute(pair)
|
||||
dismiss()
|
||||
} else {
|
||||
if (sourcePath.getBasePath(context) == destinationPath.getBasePath(context)) {
|
||||
if (context.isPathOnSD(sourcePath) || context.isPathOnSD(destinationPath)) {
|
||||
context.toast(R.string.moving)
|
||||
val pair = Pair<List<File>, File>(files, destinationDir)
|
||||
CopyTask(copyListener, context, true).execute(pair)
|
||||
dismiss()
|
||||
} else {
|
||||
for (f in files) {
|
||||
val destination = File(destinationDir, f.name)
|
||||
f.renameTo(destination)
|
||||
context.rescanItem(destination)
|
||||
}
|
||||
|
||||
context.toast(R.string.moving_success)
|
||||
dismiss()
|
||||
listener.onSuccess()
|
||||
} else {
|
||||
context.toast(R.string.copying_no_delete, Toast.LENGTH_LONG)
|
||||
val pair = Pair<List<File>, File>(files, destinationDir)
|
||||
CopyTask(copyListener, context).execute(pair)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -3,9 +3,10 @@ package com.simplemobiletools.filemanager.extensions
|
||||
import android.content.Context
|
||||
import android.media.MediaScannerConnection
|
||||
import android.widget.Toast
|
||||
import com.simplemobiletools.filepicker.extensions.getSDCardPath
|
||||
import java.io.File
|
||||
|
||||
fun Context.toast(id: Int, length: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, resources.getString(id), length).show()
|
||||
fun Context.toast(id: Int) = Toast.makeText(this, resources.getString(id), Toast.LENGTH_SHORT).show()
|
||||
|
||||
fun Context.rescanItem(item: File) {
|
||||
if (item.isDirectory) {
|
||||
@ -16,3 +17,5 @@ fun Context.rescanItem(item: File) {
|
||||
|
||||
MediaScannerConnection.scanFile(this, arrayOf(item.absolutePath), null, null)
|
||||
}
|
||||
|
||||
fun Context.isPathOnSD(path: String) = path.startsWith(getSDCardPath())
|
||||
|
Reference in New Issue
Block a user