Skip to content

Commit 5cd666d

Browse files
committed
Handle file creation for OTG
This fixes #602
1 parent 79e5c09 commit 5cd666d

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
6666
callback(false)
6767
}
6868
}
69+
} else if (activity.isPathOnOTG(path)) {
70+
val parent = activity.getDocumentFile(path.getParentPath())
71+
val created = parent?.createDirectory(path.getFilenameFromPath())
72+
if (created != null) {
73+
success(alertDialog)
74+
}
6975
} else {
7076
if (File(path).mkdirs()) {
7177
success(alertDialog)
@@ -137,8 +143,17 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
137143
}
138144

139145
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
140-
if (File(path).createNewFile()) {
141-
success(alertDialog)
146+
147+
if (activity.isPathOnOTG(path)) {
148+
val parent = activity.getDocumentFile(path.getParentPath())
149+
val created = parent?.createFile(path.getMimeType(), path.getFilenameFromPath())
150+
if (created != null) {
151+
success(alertDialog)
152+
}
153+
} else {
154+
if (File(path).createNewFile()) {
155+
success(alertDialog)
156+
}
142157
}
143158
}
144159
else -> {

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

0 commit comments

Comments
 (0)