mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-02 19:47:09 +01:00
add a helper function for fetching root items
This commit is contained in:
parent
4ad01751af
commit
80d834e7eb
@ -40,6 +40,8 @@ dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.27.7'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
compile files('../libs/RootTools.jar')
|
||||
}
|
||||
|
||||
buildscript {
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.simplemobiletools.filemanager.helpers
|
||||
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.stericson.RootShell.execution.Command
|
||||
import com.stericson.RootTools.RootTools
|
||||
|
||||
class RootHelpers {
|
||||
fun getFiles(path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||
val command = object : Command(0, "ls -la $path | awk '{print \$1,\$NF}'") {
|
||||
override fun commandOutput(id: Int, line: String) {
|
||||
super.commandOutput(id, line)
|
||||
val parts = line.split(" ")
|
||||
|
||||
val files = ArrayList<FileDirItem>()
|
||||
val filename = parts[1]
|
||||
val filePath = "${path.trimEnd('/')}/$filename"
|
||||
val isDirectory = parts[0].startsWith("d")
|
||||
val fileDirItem = FileDirItem(filePath, filename, isDirectory, 0, 0)
|
||||
files.add(fileDirItem)
|
||||
callback(files)
|
||||
}
|
||||
|
||||
override fun commandTerminated(id: Int, reason: String?) {
|
||||
super.commandTerminated(id, reason)
|
||||
}
|
||||
|
||||
override fun commandCompleted(id: Int, exitcode: Int) {
|
||||
super.commandCompleted(id, exitcode)
|
||||
}
|
||||
}
|
||||
RootTools.getShell(true).add(command)
|
||||
}
|
||||
}
|
BIN
libs/RootTools.jar
Normal file
BIN
libs/RootTools.jar
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user