@@ -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) {
0 commit comments