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

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

Merge pull request #31 from SimpleMobileTools/master

upd
parents 3b512b19 3eeb78ea
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '4.0.21'
        kotlin_version = '1.2.41'
        propVersionName = '4.1.11'
        kotlin_version = '1.2.50'
        support_libs = '27.1.1'
    }

@@ -18,7 +18,7 @@ buildscript {
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+10 −2
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.drawable.ColorDrawable
@@ -92,6 +93,14 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
        else -> super.onOptionsItemSelected(item)
    }

    override fun attachBaseContext(newBase: Context) {
        if (newBase.baseConfig.useEnglish) {
            super.attachBaseContext(MyContextWrapper(newBase).wrap(newBase, "en"))
        } else {
            super.attachBaseContext(newBase)
        }
    }

    fun updateBackgroundColor(color: Int = baseConfig.backgroundColor) {
        window.decorView.setBackgroundColor(color)
    }
@@ -265,13 +274,12 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
                                if (!baseConfig.keepLastModified) {
                                    newFile.setLastModified(System.currentTimeMillis())
                                }
                                updateInMediaStore(oldFileDirItem.path, newFile.absolutePath)
                                updatedFiles.add(newFile.toFileDirItem(applicationContext))
                            }
                        }

                        val updatedPaths = updatedFiles.map { it.path } as ArrayList<String>
                        scanPaths(updatedPaths) {
                        scanPathsRecursively(updatedPaths) {
                            runOnUiThread {
                                copyMoveListener.copySucceeded(false, fileDirItems.size * 2 == updatedFiles.size, destination)
                            }
+2 −2
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal

            if (source.size == copiedSize) {
                mTransferredFiles.add(source)
                activity.scanPath(destination.path) {
                activity.scanPathRecursively(destination.path) {
                    if (activity.baseConfig.keepLastModified) {
                        copyOldLastModified(source.path, destination.path)
                    }
@@ -277,7 +277,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
                }

                selectionArgs = arrayOf(destinationPath)
                activity.scanPath(destinationPath) {
                activity.scanPathRecursively(destinationPath) {
                    activity.applicationContext.contentResolver.update(uri, values, selection, selectionArgs)
                }
            }
+10 −10
Original line number Diff line number Diff line
@@ -488,20 +488,20 @@ private fun deleteRecursively(file: File): Boolean {
    return file.delete()
}

fun Activity.scanFile(file: File, callback: (() -> Unit)? = null) {
    applicationContext.scanFile(file, callback)
fun Activity.scanFileRecursively(file: File, callback: (() -> Unit)? = null) {
    applicationContext.scanFileRecursively(file, callback)
}

fun Activity.scanPath(path: String, callback: (() -> Unit)? = null) {
    applicationContext.scanPath(path, callback)
fun Activity.scanPathRecursively(path: String, callback: (() -> Unit)? = null) {
    applicationContext.scanPathRecursively(path, callback)
}

fun Activity.scanFiles(files: ArrayList<File>, callback: (() -> Unit)? = null) {
    applicationContext.scanFiles(files, callback)
fun Activity.scanFilesRecursively(files: ArrayList<File>, callback: (() -> Unit)? = null) {
    applicationContext.scanFilesRecursively(files, callback)
}

fun Activity.scanPaths(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
    applicationContext.scanPaths(paths, callback)
fun Activity.scanPathsRecursively(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
    applicationContext.scanPathsRecursively(paths, callback)
}

fun Activity.rescanPaths(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
@@ -551,13 +551,13 @@ fun BaseSimpleActivity.renameFile(oldPath: String, newPath: String, callback: ((
                runOnUiThread {
                    callback?.invoke(true)
                }
                scanPathRecursively(newPath)
            }
        } else {
            if (!baseConfig.keepLastModified) {
                File(newPath).setLastModified(System.currentTimeMillis())
            }
            updateInMediaStore(oldPath, newPath)
            scanPaths(arrayListOf(oldPath, newPath)) {
            scanPathsRecursively(arrayListOf(newPath)) {
                runOnUiThread {
                    callback?.invoke(true)
                }
+7 −7
Original line number Diff line number Diff line
@@ -220,15 +220,15 @@ fun Context.getDocumentFile(path: String): DocumentFile? {

fun Context.getSomeDocumentFile(path: String) = getFastDocumentFile(path) ?: getDocumentFile(path)

fun Context.scanFile(file: File, callback: (() -> Unit)? = null) {
    scanFiles(arrayListOf(file), callback)
fun Context.scanFileRecursively(file: File, callback: (() -> Unit)? = null) {
    scanFilesRecursively(arrayListOf(file), callback)
}

fun Context.scanPath(path: String, callback: (() -> Unit)? = null) {
    scanPaths(arrayListOf(path), callback)
fun Context.scanPathRecursively(path: String, callback: (() -> Unit)? = null) {
    scanPathsRecursively(arrayListOf(path), callback)
}

fun Context.scanFiles(files: ArrayList<File>, callback: (() -> Unit)? = null) {
fun Context.scanFilesRecursively(files: ArrayList<File>, callback: (() -> Unit)? = null) {
    val allPaths = ArrayList<String>()
    for (file in files) {
        allPaths.addAll(getPaths(file))
@@ -236,7 +236,7 @@ fun Context.scanFiles(files: ArrayList<File>, callback: (() -> Unit)? = null) {
    rescanPaths(allPaths, callback)
}

fun Context.scanPaths(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
fun Context.scanPathsRecursively(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
    val allPaths = ArrayList<String>()
    for (path in paths) {
        allPaths.addAll(getPaths(File(path)))
@@ -270,7 +270,7 @@ fun Context.getFileUri(path: String) = when {
    else -> MediaStore.Files.getContentUri("external")
}

// these functions update the mediastore instantly, MediaScannerConnection.scanFile takes some time to really get applied
// these functions update the mediastore instantly, MediaScannerConnection.scanFileRecursively takes some time to really get applied
fun Context.deleteFromMediaStore(path: String): Boolean {
    if (getDoesFilePathExist(path) || getIsPathDirectory(path)) {
        return false
Loading