Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83e75f77 authored by tibbi's avatar tibbi
Browse files

get the parent folder documentFile if we are creating a new file

parent bb49b860
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.13.3'
        propVersionName = '3.13.4'
        kotlin_version = '1.2.21'
        support_libs = '27.0.2'
    }
+5 −1
Original line number Diff line number Diff line
@@ -564,10 +564,14 @@ fun Activity.hideKeyboard(view: View) {
    inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}

fun BaseSimpleActivity.getFileOutputStream(fileDirItem: FileDirItem, callback: (outputStream: OutputStream?) -> Unit) {
fun BaseSimpleActivity.getFileOutputStream(fileDirItem: FileDirItem, allowCreatingNewFile: Boolean = false, callback: (outputStream: OutputStream?) -> Unit) {
    if (needsStupidWritePermissions(fileDirItem.path)) {
        handleSAFDialog(fileDirItem.path) {
            var document = getDocumentFile(fileDirItem.path)
            if (document == null && allowCreatingNewFile) {
                document = getDocumentFile(fileDirItem.getParentPath())
            }

            if (document == null) {
                val error = String.format(getString(R.string.could_not_create_file), fileDirItem.path)
                showErrorToast(error)