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
2 changes: 1 addition & 1 deletion src/autoload/Configs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func check_orientation():
if new_orientation != current_orientation:
current_orientation = new_orientation
orientation_changed.emit()

HandlerGUI.toogle_status_bar(new_orientation == orientation.PORTRAIT)

const savedata_path = "user://savedata.tres"
var savedata: SaveData:
Expand Down
29 changes: 26 additions & 3 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var tabs_panel: PanelContainer
var android_runtime: JNISingleton
var is_light_system_bars: bool = false

var status_bar_visible: bool = true

func set_system_bar_color(color: Color, override_appearance := false) -> void:
if not android_runtime:
return
Expand All @@ -42,6 +44,24 @@ func set_system_bar_color(color: Color, override_appearance := false) -> void:

activity.runOnUiThread(android_runtime.createRunnableFromGodotCallable(callable))

func toogle_status_bar(visible: bool, override := false) -> void:
if (status_bar_visible == visible and not override) or not android_runtime:
return

var activity = android_runtime.getActivity()
var callable = func ():
var window = activity.getWindow()
var WindowInsetsControllerCompat = JavaClassWrapper.wrap("androidx.core.view.WindowInsetsControllerCompat")
var controller = WindowInsetsControllerCompat.call("<init>", window, window.getDecorView())
var type = JavaClassWrapper.wrap("androidx.core.view.WindowInsetsCompat$Type")
if visible:
controller.show(type.statusBars())
else:
controller.hide(type.statusBars())
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE)
status_bar_visible = visible

activity.runOnUiThread(android_runtime.createRunnableFromGodotCallable(callable))

func _enter_tree() -> void:
var window := get_window()
Expand All @@ -60,6 +80,9 @@ func _ready() -> void:

android_runtime = Engine.get_singleton("AndroidRuntime")
set_system_bar_color(ThemeUtils.base_color, true)
toogle_status_bar(Configs.current_orientation == Configs.orientation.PORTRAIT)
var version = JavaClassWrapper.wrap("android.os.Build$VERSION")
if version: Configs.current_sdk = version.SDK_INT

shortcut_panel = ShortcutPanelScene.instantiate()
get_tree().root.add_child(shortcut_panel)
Expand All @@ -73,9 +96,9 @@ func _ready() -> void:
overlay_ref.add_child(tabs_panel)

func _notification(what: int) -> void:
if what == NOTIFICATION_WM_ABOUT:
# TODO Keep track of #101410.
open_about.call_deferred()
if what == NOTIFICATION_APPLICATION_RESUMED:
if not status_bar_visible:
toogle_status_bar(false, true)

# Drag-and-drop of files.
func _on_files_dropped(files: PackedStringArray) -> void:
Expand Down
2 changes: 0 additions & 2 deletions src/ui_parts/editor_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ func _ready() -> void:
Configs.layout_changed.connect(update_layout)
Configs.orientation_changed.connect(update_orientation)
update_layout()
var version = JavaClassWrapper.wrap("android.os.Build$VERSION")
if version: Configs.current_sdk = version.SDK_INT

func update_orientation():
if Configs.current_orientation == Configs.orientation.PORTRAIT:
Expand Down