diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index 14223405..855fd42f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -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) -> Unit) { - + RootHelpers().getFiles(context, path, callback) } private fun getChildren(file: File): Int { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt index cdcb0a62..0509df68 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt @@ -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) -> Unit) { + fun getFiles(context: Context, path: String, callback: (fileDirItems: ArrayList) -> Unit) { + val files = ArrayList() + 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() 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) + 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) + } + 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)