first attempt

This commit is contained in:
Paul Akhamiogu 2021-08-25 00:37:18 +01:00
parent 6ab6f50b9b
commit 6a94feaf0e
4 changed files with 54 additions and 15 deletions

View File

@ -58,7 +58,8 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:16ae1d2c03' // implementation 'com.github.SimpleMobileTools:Simple-Commons:e56c724d04'
implementation project(":commons")
implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6' implementation 'com.github.Stericson:RootShell:1.6'
implementation 'com.alexvasilkov:gesture-views:2.5.2' implementation 'com.alexvasilkov:gesture-views:2.5.2'

View File

@ -3,8 +3,9 @@ package com.simplemobiletools.filemanager.pro.extensions
import android.content.Context import android.content.Context
import com.simplemobiletools.commons.extensions.isPathOnOTG import com.simplemobiletools.commons.extensions.isPathOnOTG
import com.simplemobiletools.commons.extensions.isPathOnSD import com.simplemobiletools.commons.extensions.isPathOnSD
import com.simplemobiletools.commons.extensions.otgPath
import com.simplemobiletools.commons.extensions.sdCardPath
import com.simplemobiletools.filemanager.pro.helpers.Config import com.simplemobiletools.filemanager.pro.helpers.Config
val Context.config: Config get() = Config.newInstance(applicationContext) val Context.config: Config get() = Config.newInstance(applicationContext)
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (isPathOnSD(path))) fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (isPathOnSD(path)))

View File

@ -3,6 +3,7 @@ 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
@ -23,12 +24,13 @@ import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
import com.simplemobiletools.filemanager.pro.models.ListItem import com.simplemobiletools.filemanager.pro.models.ListItem
import kotlinx.android.synthetic.main.items_fragment.view.*
import java.io.File import java.io.File
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlinx.android.synthetic.main.items_fragment.view.*
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener, Breadcrumbs.BreadcrumbsListener { class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener,
Breadcrumbs.BreadcrumbsListener {
private var showHidden = false private var showHidden = false
private var skipItemUpdating = false private var skipItemUpdating = false
private var isSearchOpen = false private var isSearchOpen = false
@ -156,18 +158,47 @@ 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
ensureBackgroundThread { Log.d(TAG, "getItems: $path")
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
val config = context!!.config if (isRPlus() && context.isAndroidDataRoot(path)) {
if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) { activity?.handleSAFDialog(path) { granted ->
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0 Log.d(TAG, "getItems: $granted")
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) { if (!granted) {
callback(path, getListItemsFromFileDirItems(it)) 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 {
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)) {
getRegularItemsOf(path, callback)
} else {
RootHelpers(activity!!).getFiles(path, callback)
} }
} else if (!config.enableRootAccess || !context!!.isPathOnRoot(path)) {
getRegularItemsOf(path, callback)
} else {
RootHelpers(activity!!).getFiles(path, callback)
} }
} }
} }
@ -526,4 +557,8 @@ 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"
}
} }

View File

@ -1 +1,3 @@
include ':app' include ':app'
include ':commons'
project(":commons").projectDir = new File("/Users/cyberman/StudioProjects/Simple-Commons/commons")