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
12 changes: 6 additions & 6 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=true
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_media_audio=false
permissions/read_media_images=true
permissions/read_media_images=false
permissions/read_media_video=false
permissions/read_media_visual_user_selected=false
permissions/read_phone_state=false
Expand Down Expand Up @@ -216,7 +216,7 @@ permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=true
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
Expand Down Expand Up @@ -391,13 +391,13 @@ permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=true
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_media_audio=false
permissions/read_media_images=true
permissions/read_media_images=false
permissions/read_media_video=false
permissions/read_media_visual_user_selected=false
permissions/read_phone_state=false
Expand Down Expand Up @@ -446,7 +446,7 @@ permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=true
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
Expand Down
2 changes: 1 addition & 1 deletion src/config_classes/TabData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func _sync() -> void:

if is_saved():
# The extension is included in the presented name because it's always in the end and can't hide useless info.
presented_name = svg_file_path.get_file()
presented_name = Utils.get_file_name(svg_file_path, false)
empty_unsaved = false

if OS.has_feature("web"):
Expand Down
4 changes: 2 additions & 2 deletions src/ui_parts/editor_scene.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://bihwwoedqcyo8"]
[gd_scene format=3 uid="uid://bihwwoedqcyo8"]

[ext_resource type="Script" uid="uid://dunoppeuubgd1" path="res://src/ui_parts/editor_scene.gd" id="1_o7lif"]

[node name="EditorScene" type="PanelContainer"]
[node name="EditorScene" type="PanelContainer" unique_id=1706058386]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down
2 changes: 1 addition & 1 deletion src/ui_parts/good_file_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func get_save_name() -> String:
if selected_file_paths.is_empty() or selected_file_paths[0].get_extension().is_empty():
return default_saved_file
else:
return selected_file_paths[0].get_file()
return Utils.get_file_name(selected_file_paths[0], false)

# For optimization, only generate the visible files' images.
func _setup_file_images() -> void:
Expand Down
22 changes: 8 additions & 14 deletions src/utils/FileUtils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ static func open_xml_export_dialog(xml: String, file_name: String) -> void:
)

static func _finish_export(file_path: String, export_data: ImageExportData) -> void:
if not (file_path.contains("/Documents/") or file_path.contains("/Download/")):
OS.alert("Saving is only allowed in the Documents or Download directories.", "Save Failed")
return
if file_path.get_extension().is_empty():
file_path += "." + export_data.format

Expand Down Expand Up @@ -184,13 +181,6 @@ static func open_xml_import_dialog(completion_callback: Callable) -> void:

# On web, the completion callback can't use the full file path.
static func open_custom_import_dialog(extensions: PackedStringArray, completion_callback: Callable, multi_select := false) -> void:
var permission := "android.permission.READ_MEDIA_IMAGES"
if Configs.current_sdk < 33:
permission = "android.permission.READ_EXTERNAL_STORAGE"

if not OS.request_permission(permission):
return

var extensions_with_dots := PackedStringArray()
for extension in extensions:
extensions_with_dots.append("." + extension)
Expand Down Expand Up @@ -223,9 +213,13 @@ static func open_custom_import_dialog(extensions: PackedStringArray, completion_
# Preprocessing step where all files with wrong extensions are discarded.
static func _start_file_import_process(file_paths: PackedStringArray, completion_callback: Callable,
allowed_extensions: PackedStringArray, show_incorrect_extension_errors := true) -> void:
if not show_incorrect_extension_errors:
if not file_paths.is_empty() and file_paths[0].begins_with("content://"):
_file_import_proceed(file_paths, completion_callback)
return

if (not show_incorrect_extension_errors):
for i in range(file_paths.size() - 1, -1, -1):
if not Utils.get_lowercase_extension(file_paths[i]) in allowed_extensions:
if (not Utils.get_lowercase_extension(file_paths[i]) in allowed_extensions):
file_paths.remove_at(i)
if not file_paths.is_empty():
_file_import_proceed(file_paths, completion_callback)
Expand All @@ -251,7 +245,7 @@ allowed_extensions: PackedStringArray, show_incorrect_extension_errors := true)
passed_list = incorrect_extension_file_paths
else:
error_text += Translator.translate("{file_name} was discarded.").format(
{"file_name": incorrect_extension_file_paths[0].get_file()})
{"file_name": Utils.get_file_name(incorrect_extension_file_paths[0], false)})

var options_dialog := OptionsDialogScene.instantiate()
HandlerGUI.add_dialog(options_dialog)
Expand Down Expand Up @@ -284,7 +278,7 @@ static func _file_import_proceed(file_paths: PackedStringArray, completion_callb
var options_dialog := OptionsDialogScene.instantiate()
HandlerGUI.add_dialog(options_dialog)
var error := Translator.translate("{file_name} couldn't be opened.").format(
{"file_name": Utils.simplify_file_path(file_path).get_file()})
{"file_name": Utils.get_file_name(Utils.simplify_file_path(file_path), false)})
if not FileAccess.file_exists(file_path):
error += "\n" + Translator.translate("Check if the file still exists in the selected file path.")
if not file_paths.is_empty():
Expand Down
9 changes: 7 additions & 2 deletions src/utils/Utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ static func is_string_upper(string: String) -> bool:
static func is_string_lower(string: String) -> bool:
return string.to_lower() == string

static func get_file_name(string: String) -> String:
return string.get_file().trim_suffix("." + string.get_extension())
static func get_file_name(string: String, trim_extension := true) -> String:
if string.begins_with("content://"):
string = string.uri_file_decode()
if trim_extension:
return string.get_file().trim_suffix("." + string.get_extension())
else:
return string.get_file()

static func get_lowercase_extension(string: String) -> String:
return string.get_extension().to_lower()
Expand Down