Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ class BuildEnvironment(private val context: Context, private val rootfs: String,

projectTreeUri = waitForDirectoryAccess(DIR_ACCESS_WAIT_DURATION)
?: throw Exception("Directory access not granted in time. Build canceled.")
outputHandler(OUTPUT_INFO, "Access granted for $projectPath.\nStarting Gradle build...")

if (!FileUtils.isValidDirSelected(context, projectTreeUri)) {
throw Exception("The selected folder is not a valid project directory. Please try exporting again and select $projectPath." +
"\nIf the problem persists, please create a bug report at [color=#3182CE][url]https://github.com/godotengine/android-editor-buildenv-app/issues[/url][/color]")
}

outputHandler(OUTPUT_INFO, "Access granted for project directory. Starting Gradle build...")
FileUtils.saveProjectTreeUri(context, projectPath, projectTreeUri)

// Notify user if limit is reached so they can clear older projects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.DocumentsContract
import android.util.Log
import androidx.documentfile.provider.DocumentFile
import java.io.File
Expand Down Expand Up @@ -194,4 +195,12 @@ object FileUtils {
val uriString = prefs.getString(projectPath, null)
return uriString?.toUri()
}

fun isValidDirSelected(context: Context, projectTreeUri: Uri): Boolean {
val treeDocumentId = DocumentsContract.getTreeDocumentId(projectTreeUri) ?: return false
// Check if "project.godot" file exists.
val projectGodotUri = DocumentsContract.buildDocumentUriUsingTree(projectTreeUri, "$treeDocumentId/project.godot")
val godotFile = DocumentFile.fromSingleUri(context, projectGodotUri)
return godotFile?.exists() == true
}
}
Loading