mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-07 23:48:46 +01:00
read files from Andoid/data and Android/obb
This commit is contained in:
parent
3a52528a54
commit
471d77e19f
@ -3,7 +3,6 @@ package com.simplemobiletools.filemanager.pro.fragments
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Log
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
|
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
|
||||||
@ -120,8 +119,10 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
breadcrumbs.updateFontSize(context!!.getTextSize())
|
breadcrumbs.updateFontSize(context!!.getTextSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemsAdapter(activity as SimpleActivity, storedItems, this, items_list, isPickMultipleIntent, items_fastscroller,
|
ItemsAdapter(
|
||||||
items_swipe_refresh) {
|
activity as SimpleActivity, storedItems, this, items_list, isPickMultipleIntent, items_fastscroller,
|
||||||
|
items_swipe_refresh
|
||||||
|
) {
|
||||||
if ((it as? ListItem)?.isSectionTitle == true) {
|
if ((it as? ListItem)?.isSectionTitle == true) {
|
||||||
openDirectory(it.mPath)
|
openDirectory(it.mPath)
|
||||||
searchClosed()
|
searchClosed()
|
||||||
@ -158,34 +159,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
||||||
skipItemUpdating = false
|
skipItemUpdating = false
|
||||||
Log.d(TAG, "getItems: $path")
|
|
||||||
|
|
||||||
if (isRPlus() && context.isAndroidDataRoot(path)) {
|
|
||||||
activity?.handleSAFDialog(path) { granted ->
|
|
||||||
Log.d(TAG, "getItems: $granted")
|
|
||||||
if (!granted) {
|
|
||||||
return@handleSAFDialog
|
|
||||||
}
|
|
||||||
ensureBackgroundThread {
|
|
||||||
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
|
||||||
val config = context!!.config
|
|
||||||
if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
|
|
||||||
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
|
||||||
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) {
|
|
||||||
callback(path, getListItemsFromFileDirItems(it))
|
|
||||||
}
|
|
||||||
}else if (!config.enableRootAccess || !context!!.isPathOnRoot(path)) {
|
|
||||||
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
|
||||||
context!!.getStorageItems(path, config.shouldShowHidden, getProperFileSize){
|
|
||||||
callback(path, getListItemsFromFileDirItems(it))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
RootHelpers(activity!!).getFiles(path, callback)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
||||||
val config = context!!.config
|
val config = context!!.config
|
||||||
@ -202,18 +175,30 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getRegularItemsOf(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
private fun getRegularItemsOf(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
||||||
val items = ArrayList<ListItem>()
|
val items = ArrayList<ListItem>()
|
||||||
val files = File(path).listFiles()?.filterNotNull()
|
|
||||||
if (context == null || files == null) {
|
if (context == null) {
|
||||||
callback(path, items)
|
callback(path, items)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
||||||
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
||||||
|
|
||||||
|
if (isRPlus() && context.isSAFOnlyRoot(path)) {
|
||||||
|
activity?.handlePrimarySAFDialog(path) {
|
||||||
|
context.getStorageItemsWithTreeUri(path, context.config.shouldShowHidden, getProperChildCount) {
|
||||||
|
callback(path, getListItemsFromFileDirItems(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val files = File(path).listFiles()?.filterNotNull()
|
||||||
|
if (files == null) {
|
||||||
|
callback(path, items)
|
||||||
|
return
|
||||||
|
}
|
||||||
val lastModifieds = context!!.getFolderLastModifieds(path)
|
val lastModifieds = context!!.getFolderLastModifieds(path)
|
||||||
|
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
@ -239,6 +224,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getFileDirItemFromFile(file: File, isSortingBySize: Boolean, lastModifieds: HashMap<String, Long>, getProperChildCount: Boolean): ListItem? {
|
private fun getFileDirItemFromFile(file: File, isSortingBySize: Boolean, lastModifieds: HashMap<String, Long>, getProperChildCount: Boolean): ListItem? {
|
||||||
val curPath = file.absolutePath
|
val curPath = file.absolutePath
|
||||||
@ -557,8 +543,4 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
override fun selectedPaths(paths: ArrayList<String>) {
|
override fun selectedPaths(paths: ArrayList<String>) {
|
||||||
(activity as MainActivity).pickedPaths(paths)
|
(activity as MainActivity).pickedPaths(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "ItemsFragment"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user