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

Unverified Commit e43ffc4e authored by solokot's avatar solokot Committed by GitHub
Browse files

Merge pull request #22 from SimpleMobileTools/master

upd
parents 950a95c4 9b82d0d3
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.16.1'
        propVersionName = '3.16.11'
        kotlin_version = '1.2.30'
        support_libs = '27.1.0'
    }
+5 −5
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.io.File
import java.util.*

open class BaseSimpleActivity : AppCompatActivity() {
    var copyMoveCallback: (() -> Unit)? = null
    var copyMoveCallback: ((destinationPath: String) -> Unit)? = null
    var actionOnPermission: ((granted: Boolean) -> Unit)? = null
    var isAskingPermissions = false
    var useDynamicTheme = true
@@ -190,7 +190,7 @@ open class BaseSimpleActivity : AppCompatActivity() {
    }

    fun copyMoveFilesTo(fileDirItems: ArrayList<FileDirItem>, source: String, destination: String, isCopyOperation: Boolean, copyPhotoVideoOnly: Boolean,
                        copyHidden: Boolean, callback: () -> Unit) {
                        copyHidden: Boolean, callback: (destinationPath: String) -> Unit) {
        if (source == destination) {
            toast(R.string.source_and_destination_same)
            return
@@ -230,7 +230,7 @@ open class BaseSimpleActivity : AppCompatActivity() {
                        val updatedPaths = updatedFiles.map { it.path } as ArrayList<String>
                        scanPaths(updatedPaths) {
                            runOnUiThread {
                                copyMoveListener.copySucceeded(false, fileDirItems.size * 2 == updatedFiles.size)
                                copyMoveListener.copySucceeded(false, fileDirItems.size * 2 == updatedFiles.size, destination)
                            }
                        }
                    } catch (e: Exception) {
@@ -294,13 +294,13 @@ open class BaseSimpleActivity : AppCompatActivity() {
    }

    val copyMoveListener = object : CopyMoveListener {
        override fun copySucceeded(copyOnly: Boolean, copiedAll: Boolean) {
        override fun copySucceeded(copyOnly: Boolean, copiedAll: Boolean, destinationPath: String) {
            if (copyOnly) {
                toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial)
            } else {
                toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial)
            }
            copyMoveCallback?.invoke()
            copyMoveCallback?.invoke(destinationPath)
            copyMoveCallback = null
        }

+5 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
    private var mDocuments = LinkedHashMap<String, DocumentFile?>()
    private var mFiles = ArrayList<FileDirItem>()
    private var mFileCountToCopy = 0
    private var mDestinationPath = ""

    // progress indication
    private var mNotificationManager: NotificationManager
@@ -58,6 +59,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal

        val pair = params[0]
        mFiles = pair.first!!
        mDestinationPath = pair.second!!
        mFileCountToCopy = mFiles.size
        mNotifId = (System.currentTimeMillis() / 1000).toInt()
        mMaxSize = 0
@@ -65,7 +67,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
            if (file.size == 0L) {
                file.size = file.getProperSize(activity, copyHidden)
            }
            val newPath = "${pair.second}/${file.name}"
            val newPath = "$mDestinationPath/${file.name}"
            val fileExists = if (newPath.startsWith(OTG_PATH)) activity.getFastDocumentFile(newPath)?.exists()
                    ?: false else File(newPath).exists()
            if (getConflictResolution(newPath) != CONFLICT_SKIP || !fileExists) {
@@ -80,7 +82,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal

        for (file in mFiles) {
            try {
                val newPath = "${pair.second}/${file.name}"
                val newPath = "$mDestinationPath/${file.name}"
                val newFileDirItem = FileDirItem(newPath, newPath.getFilenameFromPath(), file.isDirectory)
                if (activity.getDoesFilePathExist(newPath)) {
                    val resolution = getConflictResolution(newPath)
@@ -113,7 +115,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
        val listener = mListener?.get() ?: return

        if (success) {
            listener.copySucceeded(copyOnly, mTransferredFiles.size >= mFileCountToCopy)
            listener.copySucceeded(copyOnly, mTransferredFiles.size >= mFileCountToCopy, mDestinationPath)
        } else {
            listener.copyFailed()
        }
+1 −3
Original line number Diff line number Diff line
@@ -67,9 +67,7 @@ class RenameItemDialog(val activity: BaseSimpleActivity, val path: String, val c
                            updatedPaths.add(newPath)
                            activity.renameFile(path, newPath) {
                                if (it) {
                                    activity.scanPaths(updatedPaths) {
                                    callback(newPath)
                                    }
                                    dismiss()
                                } else {
                                    activity.toast(R.string.unknown_error_occurred)
+6 −1
Original line number Diff line number Diff line
@@ -595,8 +595,13 @@ fun BaseSimpleActivity.getFileOutputStream(fileDirItem: FileDirItem, allowCreati
            }
        }
    } else {
        val file = File(fileDirItem.path)
        if (!file.parentFile.exists()) {
            file.parentFile.mkdirs()
        }

        try {
            callback(FileOutputStream(File(fileDirItem.path)))
            callback(FileOutputStream(file))
        } catch (e: Exception) {
            callback(null)
        }
Loading