mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-16 20:00:36 +01:00
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:
commit
f60145aa8b
@ -51,6 +51,21 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
|
|
||||||
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||||
when {
|
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) -> {
|
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
|
||||||
if (activity.isRestrictedSAFOnlyRoot(path)) {
|
if (activity.isRestrictedSAFOnlyRoot(path)) {
|
||||||
activity.handleAndroidSAFDialog(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 -> {
|
else -> {
|
||||||
RootHelpers(activity).createFileFolder(path, false) {
|
RootHelpers(activity).createFileFolder(path, false) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.pro.extensions
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
@ -5,7 +5,7 @@ kotlin = "1.9.0"
|
|||||||
androidx-swiperefreshlayout = "1.1.0"
|
androidx-swiperefreshlayout = "1.1.0"
|
||||||
androidx-documentfile = "1.0.1"
|
androidx-documentfile = "1.0.1"
|
||||||
#Simple tools
|
#Simple tools
|
||||||
simple-commons = "eceb48949e"
|
simple-commons = "0661d6d44a"
|
||||||
#Other
|
#Other
|
||||||
autofittextview = "0.2.1"
|
autofittextview = "0.2.1"
|
||||||
gestureviews = "2.5.2"
|
gestureviews = "2.5.2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user