Handle file creation for OTG

This fixes #602
This commit is contained in:
Ensar Sarajčić 2023-09-20 13:11:02 +02:00
parent 79e5c0928b
commit 5cd666d949
2 changed files with 17 additions and 3 deletions

View File

@ -66,6 +66,12 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
callback(false)
}
}
} else if (activity.isPathOnOTG(path)) {
val parent = activity.getDocumentFile(path.getParentPath())
val created = parent?.createDirectory(path.getFilenameFromPath())
if (created != null) {
success(alertDialog)
}
} else {
if (File(path).mkdirs()) {
success(alertDialog)
@ -137,8 +143,17 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
}
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
if (File(path).createNewFile()) {
success(alertDialog)
if (activity.isPathOnOTG(path)) {
val parent = activity.getDocumentFile(path.getParentPath())
val created = parent?.createFile(path.getMimeType(), path.getFilenameFromPath())
if (created != null) {
success(alertDialog)
}
} else {
if (File(path).createNewFile()) {
success(alertDialog)
}
}
}
else -> {

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