Merge pull request #751 from esensar/fix/602-delete-otg

Handle file/folder creation, deletion and copy/move for OTG
This commit is contained in:
Tibor Kaputa 2023-09-21 09:37:52 +02:00 committed by GitHub
commit f60145aa8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 17 deletions

View file

@ -51,6 +51,21 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
when {
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
if (!it) {
return@handleSAFDialog
}
val documentFile = activity.getDocumentFile(path.getParentPath())
if (documentFile == null) {
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
activity.showErrorToast(error)
callback(false)
return@handleSAFDialog
}
documentFile.createDirectory(path.getFilenameFromPath())
success(alertDialog)
}
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
if (activity.isRestrictedSAFOnlyRoot(path)) {
activity.handleAndroidSAFDialog(path) {
@ -72,21 +87,6 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
}
}
}
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
if (!it) {
return@handleSAFDialog
}
val documentFile = activity.getDocumentFile(path.getParentPath())
if (documentFile == null) {
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
activity.showErrorToast(error)
callback(false)
return@handleSAFDialog
}
documentFile.createDirectory(path.getFilenameFromPath())
success(alertDialog)
}
else -> {
RootHelpers(activity).createFileFolder(path, false) {
if (it) {

View file

@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.pro.extensions
import android.app.Activity
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.view.View
import androidx.appcompat.app.AppCompatActivity

View file

@ -5,7 +5,7 @@ kotlin = "1.9.0"
androidx-swiperefreshlayout = "1.1.0"
androidx-documentfile = "1.0.1"
#Simple tools
simple-commons = "eceb48949e"
simple-commons = "0661d6d44a"
#Other
autofittextview = "0.2.1"
gestureviews = "2.5.2"