Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 464482bf authored by tibbi's avatar tibbi
Browse files

updating some dialog and documentfile related things

parent db42b536
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.11.47'
        propVersionName = '3.11.48'
        kotlin_version = '1.2.21'
        support_libs = '27.0.2'
    }
+6 −6
Original line number Diff line number Diff line
@@ -183,8 +183,7 @@ open class BaseSimpleActivity : AppCompatActivity() {
            return
        }

        val destinationFolder = File(destination)
        if (!destinationFolder.exists() && getSomeDocumentFile(destination) == null) {
        if (!doesFilePathExist(destination)) {
            toast(R.string.invalid_destination)
            return
        }
@@ -203,6 +202,7 @@ open class BaseSimpleActivity : AppCompatActivity() {
                    val updatedFiles = ArrayList<FileDirItem>(fileDirItems.size * 2)
                    updatedFiles.addAll(fileDirItems)
                    try {
                        val destinationFolder = File(destination)
                        for (oldFileDirItem in fileDirItems) {
                            val newFile = File(destinationFolder, oldFileDirItem.name)
                            if (!newFile.exists() && File(oldFileDirItem.path).renameTo(newFile)) {
@@ -244,15 +244,15 @@ open class BaseSimpleActivity : AppCompatActivity() {
        }

        val file = files[index]
        val newFile = File(destinationFileDirItem.path, file.name)
        if (newFile.exists()) {
            FileConflictDialog(this, newFile) { resolution, applyForAll ->
        val newFileDirItem = FileDirItem("${destinationFileDirItem.path}/${file.name}", file.name, file.isDirectory)
        if (doesFilePathExist(newFileDirItem.path)) {
            FileConflictDialog(this, newFileDirItem) { resolution, applyForAll ->
                if (applyForAll) {
                    conflictResolutions.clear()
                    conflictResolutions[""] = resolution
                    checkConflict(files, destinationFileDirItem, files.size, conflictResolutions, callback)
                } else {
                    conflictResolutions[newFile.absolutePath] = resolution
                    conflictResolutions[newFileDirItem.path] = resolution
                    checkConflict(files, destinationFileDirItem, index + 1, conflictResolutions, callback)
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -232,9 +232,9 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
            while (bytes >= 0) {
                out!!.write(buffer, 0, bytes)
                copiedSize += bytes
                mCurrentProgress += bytes
                bytes = inputStream.read(buffer)
            }
            mCurrentProgress += copiedSize

            if (source.size == copiedSize) {
                mTransferredFiles.add(source)
+7 −4
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import java.io.File
class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) {
    init {
        val view = activity.layoutInflater.inflate(R.layout.dialog_create_new_folder, null)
        view.folder_path.text = activity.humanizePath(path).trimEnd('/') + "/"
        view.folder_path.text = "${activity.humanizePath(path)}/"

        AlertDialog.Builder(activity)
                .setPositiveButton(R.string.ok, null)
@@ -45,9 +45,12 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String,
            when {
                activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
                    try {
                        val documentFile = activity.getDocumentFile(path)
                        documentFile?.createDirectory(path.getFilenameFromPath())
                        val documentFile = activity.getDocumentFile(path.getParentPath())
                        if (documentFile?.createDirectory(path.getFilenameFromPath()) != null) {
                            sendSuccess(alertDialog, path)
                        } else {
                            activity.toast(R.string.unknown_error_occurred)
                        }
                    } catch (e: SecurityException) {
                        activity.showErrorToast(e)
                    }
+5 −5
Original line number Diff line number Diff line
@@ -11,18 +11,18 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.CONFLICT_MERGE
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
import com.simplemobiletools.commons.models.FileDirItem
import kotlinx.android.synthetic.main.dialog_file_conflict.view.*
import java.io.File

class FileConflictDialog(val activity: Activity, val file: File, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) {
class FileConflictDialog(val activity: Activity, val fileDirItem: FileDirItem, val callback: (resolution: Int, applyForAll: Boolean) -> Unit) {
    val view = activity.layoutInflater.inflate(R.layout.dialog_file_conflict, null)!!

    init {
        view.apply {
            val stringBase = if (file.isDirectory) R.string.folder_already_exists else R.string.file_already_exists
            conflict_dialog_title.text = String.format(activity.getString(stringBase), file.name)
            val stringBase = if (fileDirItem.isDirectory) R.string.folder_already_exists else R.string.file_already_exists
            conflict_dialog_title.text = String.format(activity.getString(stringBase), fileDirItem.name)
            conflict_dialog_apply_to_all.isChecked = activity.baseConfig.lastConflictApplyToAll
            conflict_dialog_radio_merge.beVisibleIf(file.isDirectory)
            conflict_dialog_radio_merge.beVisibleIf(fileDirItem.isDirectory)

            val resolutionButton = when (activity.baseConfig.lastConflictResolution) {
                CONFLICT_OVERWRITE -> conflict_dialog_radio_overwrite
Loading