@@ -51,6 +51,7 @@ import org.godotengine.godot.io.file.MediaStoreData
5151internal class FilePicker {
5252 companion object {
5353 private const val FILE_PICKER_REQUEST = 1000
54+ private const val FILE_SAVE_REQUEST = 1001
5455 private val TAG = FilePicker ::class .java.simpleName
5556
5657 // Constants for fileMode values
@@ -70,7 +71,7 @@ internal class FilePicker {
7071 */
7172 @RequiresApi(Build .VERSION_CODES .Q )
7273 fun handleActivityResult (context : Context , requestCode : Int , resultCode : Int , data : Intent ? ) {
73- if (requestCode == FILE_PICKER_REQUEST ) {
74+ if (requestCode == FILE_PICKER_REQUEST || requestCode == FILE_SAVE_REQUEST ) {
7475 if (resultCode == Activity .RESULT_CANCELED ) {
7576 Log .d(TAG , " File picker canceled" )
7677 GodotLib .filePickerCallback(false , emptyArray())
@@ -101,6 +102,10 @@ internal class FilePicker {
101102 } else {
102103 Log .d(TAG , " null filepath URI: $it " )
103104 }
105+
106+ if (requestCode == FILE_SAVE_REQUEST ) {
107+ DocumentsContract .deleteDocument(context.contentResolver, it)
108+ }
104109 }
105110 }
106111
@@ -152,7 +157,11 @@ internal class FilePicker {
152157 intent.addCategory(Intent .CATEGORY_OPENABLE )
153158 }
154159 intent.putExtra(Intent .EXTRA_LOCAL_ONLY , true )
155- activity?.startActivityForResult(intent, FILE_PICKER_REQUEST )
160+ if (fileMode == FILE_MODE_SAVE_FILE ) {
161+ activity?.startActivityForResult(intent, FILE_SAVE_REQUEST )
162+ } else {
163+ activity?.startActivityForResult(intent, FILE_PICKER_REQUEST )
164+ }
156165 }
157166
158167 /* *
0 commit comments