exclude SD and OTG from SAF restricted directories

This commit is contained in:
darthpaul
2021-11-12 06:54:59 +00:00
parent 2de754e4cf
commit b7ef3993f2
8 changed files with 30 additions and 30 deletions

View File

@@ -9,13 +9,13 @@ if (keystorePropertiesFile.exists()) {
}
android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.simplemobiletools.filemanager.pro"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 108
versionName "6.9.4"
multiDexEnabled true
@@ -58,7 +58,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:649211e294'
implementation project(":commons")
implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6'
implementation 'com.alexvasilkov:gesture-views:2.5.2'

View File

@@ -50,12 +50,8 @@ import kotlinx.android.synthetic.main.item_file_dir_list.view.item_name
import kotlinx.android.synthetic.main.item_section.view.*
import java.io.Closeable
import java.io.File
import java.io.FileInputStream
import java.net.URI
import java.net.URLEncoder
import java.util.*
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
@@ -469,9 +465,9 @@ class ItemsAdapter(
CompressAsDialog(activity, firstPath) {
val destination = it
activity.handlePrimarySAFDialog(firstPath) { granted ->
activity.handlePrimaryAndroidSAFDialog(firstPath) { granted ->
if (!granted) {
return@handlePrimarySAFDialog
return@handlePrimaryAndroidSAFDialog
}
activity.handleSAFDialog(firstPath) {
if (!it) {

View File

@@ -68,10 +68,10 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
}
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
if (activity.isRestrictedAndroidDir(path)) {
activity.handlePrimarySAFDialog(path) {
activity.handlePrimaryAndroidSAFDialog(path) {
if (!it) {
callback(false)
return@handlePrimarySAFDialog
return@handlePrimaryAndroidSAFDialog
}
if (activity.createSAFOnlyDirectory(path)) {
success(alertDialog)
@@ -103,10 +103,10 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
try {
when {
activity.isRestrictedAndroidDir(path) -> {
activity.handlePrimarySAFDialog(path) {
activity.handlePrimaryAndroidSAFDialog(path) {
if (!it) {
callback(false)
return@handlePrimarySAFDialog
return@handlePrimaryAndroidSAFDialog
}
if (activity.createSAFOnlyFile(path)) {
success(alertDialog)

View File

@@ -188,7 +188,12 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
if (context.isRestrictedAndroidDir(path)) {
activity?.handlePrimarySAFDialog(path) {
activity?.handlePrimaryAndroidSAFDialog(path) {
if (!it) {
activity?.toast(R.string.no_storage_permissions)
return@handlePrimaryAndroidSAFDialog
}
context.getStorageItemsWithTreeUri(path, context.config.shouldShowHidden, getProperChildCount) {
callback(path, getListItemsFromFileDirItems(it))
}

View File

@@ -122,19 +122,18 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
FileColumns.SIZE
)
val cursor = if (isOreoPlus()) {
val queryArgs = bundleOf(
ContentResolver.QUERY_ARG_LIMIT to RECENTS_LIMIT,
ContentResolver.QUERY_ARG_SORT_COLUMNS to arrayOf(FileColumns.DATE_MODIFIED),
ContentResolver.QUERY_ARG_SORT_DIRECTION to ContentResolver.QUERY_SORT_DIRECTION_DESCENDING
)
context?.contentResolver?.query(uri, projection, queryArgs, null)
} else {
val sortOrder = "${FileColumns.DATE_MODIFIED} DESC LIMIT $RECENTS_LIMIT"
context?.contentResolver?.query(uri, projection, null, null, sortOrder)
}
try {
val cursor = if (isOreoPlus()) {
val queryArgs = bundleOf(
ContentResolver.QUERY_ARG_LIMIT to RECENTS_LIMIT,
ContentResolver.QUERY_ARG_SORT_COLUMNS to arrayOf(FileColumns.DATE_MODIFIED),
ContentResolver.QUERY_ARG_SORT_DIRECTION to ContentResolver.QUERY_SORT_DIRECTION_DESCENDING
)
context?.contentResolver?.query(uri, projection, queryArgs, null)
} else {
val sortOrder = "${FileColumns.DATE_MODIFIED} DESC LIMIT $RECENTS_LIMIT"
context?.contentResolver?.query(uri, projection, null, null, sortOrder)
}
cursor?.use {
if (cursor.moveToFirst()) {
do {