Skip to content

Commit 7449adc

Browse files
Request READ_EXTERNAL_STORAGE permission on older devices
1 parent 685d8f5 commit 7449adc

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/autoload/Configs.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ signal tab_selected(index: int)
3636
@warning_ignore("unused_signal")
3737
signal layout_changed
3838

39+
var current_sdk: int = -1
40+
3941
const savedata_path = "user://savedata.tres"
4042
var savedata: SaveData:
4143
set(new_value):

src/ui_parts/editor_scene.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ func _ready() -> void:
1212
Configs.layout_changed.connect(update_layout)
1313
update_layout()
1414
update_theme()
15+
var version = JavaClassWrapper.wrap("android.os.Build$VERSION")
16+
if version: Configs.current_sdk = version.SDK_INT
1517

1618
func update_theme() -> void:
1719
var stylebox := StyleBoxFlat.new()

src/utils/FileUtils.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ static func open_xml_import_dialog(completion_callback: Callable) -> void:
182182
# On web, the completion callback can't use the full file path.
183183
static func _open_import_dialog(extensions: PackedStringArray,
184184
completion_callback: Callable, multi_select := false) -> void:
185-
if not OS.request_permission("android.permission.READ_MEDIA_IMAGES"):
185+
var permission := "android.permission.READ_MEDIA_IMAGES"
186+
if Configs.current_sdk < 33:
187+
permission = "android.permission.READ_EXTERNAL_STORAGE"
188+
189+
if not OS.request_permission(permission):
186190
return
187191

188192
var extensions_with_dots := PackedStringArray()

0 commit comments

Comments
 (0)