list the root files that should be visible
This commit is contained in:
parent
57aa9054f2
commit
2532c43f7e
2 changed files with 16 additions and 8 deletions
|
@ -23,6 +23,7 @@ import com.simplemobiletools.filemanager.activities.SimpleActivity
|
|||
import com.simplemobiletools.filemanager.adapters.ItemsAdapter
|
||||
import com.simplemobiletools.filemanager.dialogs.CreateNewItemDialog
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
import com.simplemobiletools.filemanager.helpers.RootHelpers
|
||||
import kotlinx.android.synthetic.main.items_fragment.*
|
||||
import kotlinx.android.synthetic.main.items_fragment.view.*
|
||||
import java.io.File
|
||||
|
@ -188,7 +189,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
|
|||
}
|
||||
|
||||
private fun getRootItemsOf(path: String, callback: (items: ArrayList<FileDirItem>) -> Unit) {
|
||||
|
||||
RootHelpers().getFiles(context, path, callback)
|
||||
}
|
||||
|
||||
private fun getChildren(file: File): Int {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.simplemobiletools.filemanager.helpers
|
||||
|
||||
import android.content.Context
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
import com.stericson.RootShell.execution.Command
|
||||
import com.stericson.RootTools.RootTools
|
||||
|
||||
|
@ -33,18 +35,22 @@ class RootHelpers {
|
|||
}
|
||||
}
|
||||
|
||||
fun getFiles(path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||
fun getFiles(context: Context, path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||
val files = ArrayList<FileDirItem>()
|
||||
val showHidden = context.config.shouldShowHidden
|
||||
|
||||
val command = object : Command(0, "ls -la $path | awk '{print \$1,\$NF}'") {
|
||||
override fun commandOutput(id: Int, line: String) {
|
||||
val parts = line.split(" ")
|
||||
|
||||
val files = ArrayList<FileDirItem>()
|
||||
val filename = parts[1]
|
||||
if (showHidden || !filename.startsWith(".")) {
|
||||
val filePath = "${path.trimEnd('/')}/$filename"
|
||||
val isDirectory = parts[0].startsWith("d")
|
||||
val fileDirItem = FileDirItem(filePath, filename, isDirectory, 0, 0)
|
||||
files.add(fileDirItem)
|
||||
callback(files)
|
||||
}
|
||||
|
||||
super.commandOutput(id, line)
|
||||
}
|
||||
|
||||
|
@ -54,6 +60,7 @@ class RootHelpers {
|
|||
|
||||
override fun commandCompleted(id: Int, exitcode: Int) {
|
||||
super.commandCompleted(id, exitcode)
|
||||
callback(files)
|
||||
}
|
||||
}
|
||||
RootTools.getShell(true).add(command)
|
||||
|
|
Loading…
Reference in a new issue