@@ -204,6 +204,22 @@ func _show_file_dialog(remote_path: String, is_uploading: bool, is_dir: bool = f
204204
205205 add_child (file_dialog )
206206 file_dialog .popup_file_dialog ()
207+ file_dialog .visibility_changed .connect (_dialog_visibility_changed .bind (file_dialog ))
208+
209+
210+ func _show_delete_dialog (remote_path : String , is_dir : bool ) -> void :
211+ var confirm_dialog = ConfirmationDialog .new ()
212+ confirm_dialog .title = "Delete"
213+ confirm_dialog .dialog_text = "Are you sure you want to delete %s '%s '?" % ["folder" if is_dir else "file" , remote_path .get_file ()]
214+ confirm_dialog .confirmed .connect (_delete .bind (remote_path ))
215+ add_child (confirm_dialog )
216+ confirm_dialog .popup_centered ()
217+ confirm_dialog .visibility_changed .connect (_dialog_visibility_changed .bind (confirm_dialog ))
218+
219+
220+ func _dialog_visibility_changed (dialog : AcceptDialog ) -> void :
221+ if not dialog .visible :
222+ dialog .queue_free ()
207223
208224# ADB Handling--------------------------------------------------------------------------------------
209225
@@ -310,6 +326,15 @@ func _push(local_path: String, remote_path: String) -> void:
310326 _run_adb (["shell" , "run-as" , PACKAGE_NAME , cp_cmd ])
311327 _run_adb (["shell" , "rm" , "-rf" , temp_path ])
312328
329+
330+ func _delete (remote_path : String ) -> void :
331+ var delete_cmd = "rm -r '%s '" % remote_path
332+ if remote_path .begins_with (DATA_ROOT ):
333+ var a = _run_adb (["shell" , "run-as" , PACKAGE_NAME , delete_cmd ])
334+ print (a )
335+ else :
336+ _run_adb (["shell" , delete_cmd ])
337+
313338# ---------------------------------------------------------------------------------------------------
314339
315340func _get_icon_for_ext (path : String ) -> String :
@@ -363,4 +388,7 @@ func _on_context_menu_item_pressed(id: int) -> void:
363388 ContextMenu .UPLOAD :
364389 var meta = item .get_metadata (0 )
365390 _show_file_dialog (meta .path , true )
391+ ContextMenu .DELETE :
392+ var meta = item .get_metadata (0 )
393+ _show_delete_dialog (meta .path , meta .is_dir )
366394
0 commit comments