update Commons with some OTG improvements
This commit is contained in:
parent
8ef70a8fe5
commit
c340b9860e
|
@ -45,7 +45,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.11.15'
|
||||
implementation 'com.simplemobiletools:commons:3.11.35'
|
||||
|
||||
implementation files('../libs/RootTools.jar')
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ class MainActivity : SimpleActivity() {
|
|||
val file = File(path)
|
||||
if (file.exists() && !file.isDirectory) {
|
||||
newPath = file.parent
|
||||
} else if (!file.exists()) {
|
||||
} else if (!file.exists() && !isPathOnOTG(newPath)) {
|
||||
newPath = internalStoragePath
|
||||
}
|
||||
|
||||
|
|
|
@ -175,10 +175,10 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val files = ArrayList<File>()
|
||||
selectedPositions.forEach { files.add(File(fileDirItems[it].path)) }
|
||||
val files = ArrayList<FileDirItem>()
|
||||
selectedPositions.forEach { files.add(FileDirItem(fileDirItems[it].path, fileDirItems[it].name)) }
|
||||
|
||||
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
||||
val source = if (!files[0].isDirectory) File(files[0].path).parent else files[0].path
|
||||
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true) {
|
||||
if (activity.isPathOnRoot(source)) {
|
||||
copyRootItems(files, it)
|
||||
|
@ -191,12 +191,12 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
}
|
||||
}
|
||||
|
||||
private fun copyRootItems(files: ArrayList<File>, destinationPath: String) {
|
||||
private fun copyRootItems(files: ArrayList<FileDirItem>, destinationPath: String) {
|
||||
activity.toast(R.string.copying)
|
||||
Thread {
|
||||
var fileCnt = files.count()
|
||||
files.forEach {
|
||||
if (RootTools.copyFile(it.absolutePath, destinationPath, false, true)) {
|
||||
if (RootTools.copyFile(it.path, destinationPath, false, true)) {
|
||||
fileCnt--
|
||||
}
|
||||
}
|
||||
|
@ -354,14 +354,14 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
return
|
||||
}
|
||||
|
||||
val files = ArrayList<File>(selectedPositions.size)
|
||||
val files = ArrayList<FileDirItem>(selectedPositions.size)
|
||||
val removeFiles = ArrayList<FileDirItem>(selectedPositions.size)
|
||||
val SAFFile = File(fileDirItems[selectedPositions.first()].path)
|
||||
|
||||
activity.handleSAFDialog(SAFFile) {
|
||||
selectedPositions.sortedDescending().forEach {
|
||||
val file = fileDirItems[it]
|
||||
files.add(File(file.path))
|
||||
files.add(FileDirItem(file.path, file.name))
|
||||
removeFiles.add(file)
|
||||
activity.config.removeFavorite(file.path)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package com.simplemobiletools.filemanager.extensions
|
|||
|
||||
import android.content.Context
|
||||
import com.simplemobiletools.commons.extensions.hasExternalSDCard
|
||||
import com.simplemobiletools.commons.extensions.isPathOnOTG
|
||||
import com.simplemobiletools.filemanager.helpers.Config
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || (hasExternalSDCard() && path.startsWith(config.sdCardPath)))
|
||||
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (hasExternalSDCard() && path.startsWith(config.sdCardPath)))
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.views.Breadcrumbs
|
||||
|
@ -114,7 +115,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
return
|
||||
}
|
||||
|
||||
var realPath = path.trimEnd('/')
|
||||
var realPath = if (path == OTG_PATH) OTG_PATH else path.trimEnd('/')
|
||||
if (realPath.isEmpty()) {
|
||||
realPath = "/"
|
||||
}
|
||||
|
@ -174,7 +175,11 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
skipItemUpdating = false
|
||||
Thread {
|
||||
if (activity?.isActivityDestroyed() == false) {
|
||||
if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
|
||||
if (context!!.isPathOnOTG(path)) {
|
||||
context!!.getOTGItems(path) {
|
||||
callback(path, it)
|
||||
}
|
||||
} else if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
|
||||
getRegularItemsOf(path, callback)
|
||||
} else {
|
||||
RootHelpers().getFiles(activity as SimpleActivity, path, callback)
|
||||
|
@ -281,7 +286,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
|
||||
override fun breadcrumbClicked(id: Int) {
|
||||
if (id == 0) {
|
||||
StoragePickerDialog(activity!!, currentPath) {
|
||||
StoragePickerDialog(activity as SimpleActivity, currentPath) {
|
||||
openPath(it)
|
||||
}
|
||||
} else {
|
||||
|
@ -294,9 +299,9 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
openPath(currentPath)
|
||||
}
|
||||
|
||||
override fun deleteFiles(files: ArrayList<File>) {
|
||||
override fun deleteFiles(files: ArrayList<FileDirItem>) {
|
||||
val hasFolder = files.any { it.isDirectory }
|
||||
if (context!!.isPathOnRoot(files.firstOrNull()?.absolutePath ?: context!!.config.internalStoragePath)) {
|
||||
if (context!!.isPathOnRoot(files.firstOrNull()?.path ?: context!!.config.internalStoragePath)) {
|
||||
files.forEach {
|
||||
RootTools.deleteFileOrDirectory(it.path, false)
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.simplemobiletools.filemanager.interfaces
|
||||
|
||||
import java.io.File
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import java.util.*
|
||||
|
||||
interface ItemOperationsListener {
|
||||
fun refreshItems()
|
||||
|
||||
fun deleteFiles(files: ArrayList<File>)
|
||||
fun deleteFiles(files: ArrayList<FileDirItem>)
|
||||
|
||||
fun selectedPaths(paths: ArrayList<String>)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue