Skip to content

Commit f60145a

Browse files
authored
Merge pull request #751 from esensar/fix/602-delete-otg
Handle file/folder creation, deletion and copy/move for OTG
2 parents 265c49d + f03a29f commit f60145a

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/CreateNewItemDialog.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
5151

5252
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
5353
when {
54+
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
55+
if (!it) {
56+
return@handleSAFDialog
57+
}
58+
59+
val documentFile = activity.getDocumentFile(path.getParentPath())
60+
if (documentFile == null) {
61+
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
62+
activity.showErrorToast(error)
63+
callback(false)
64+
return@handleSAFDialog
65+
}
66+
documentFile.createDirectory(path.getFilenameFromPath())
67+
success(alertDialog)
68+
}
5469
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
5570
if (activity.isRestrictedSAFOnlyRoot(path)) {
5671
activity.handleAndroidSAFDialog(path) {
@@ -72,21 +87,6 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
7287
}
7388
}
7489
}
75-
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(path) {
76-
if (!it) {
77-
return@handleSAFDialog
78-
}
79-
80-
val documentFile = activity.getDocumentFile(path.getParentPath())
81-
if (documentFile == null) {
82-
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
83-
activity.showErrorToast(error)
84-
callback(false)
85-
return@handleSAFDialog
86-
}
87-
documentFile.createDirectory(path.getFilenameFromPath())
88-
success(alertDialog)
89-
}
9090
else -> {
9191
RootHelpers(activity).createFileFolder(path, false) {
9292
if (it) {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Activity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.pro.extensions
22

33
import android.app.Activity
44
import android.content.Intent
5-
import android.content.res.Configuration
65
import android.net.Uri
76
import android.view.View
87
import androidx.appcompat.app.AppCompatActivity

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kotlin = "1.9.0"
55
androidx-swiperefreshlayout = "1.1.0"
66
androidx-documentfile = "1.0.1"
77
#Simple tools
8-
simple-commons = "eceb48949e"
8+
simple-commons = "0661d6d44a"
99
#Other
1010
autofittextview = "0.2.1"
1111
gestureviews = "2.5.2"

0 commit comments

Comments
 (0)