@@ -18,49 +18,23 @@ var popup_stack: Array[Control]
1818var shortcut_panel : PanelContainer
1919var tabs_panel : PanelContainer
2020
21- var android_runtime : JNISingleton
22- var is_light_system_bars : bool = false
21+ var VTAndroidCore : JNISingleton
22+ var system_bar_color : Color = Color . BLACK
2323var status_bar_visible : bool = true
2424
2525var minimum_content_width : float
2626
27- func set_system_bar_color (color : Color , override_appearance := false ) -> void :
28- if not android_runtime :
27+ func set_system_bar_color (color : Color , override := false ) -> void :
28+ if ( system_bar_color == color and not override ) or not VTAndroidCore :
2929 return
30-
31- var activity = android_runtime .getActivity ()
32- var callable = func ():
33- var window = activity .getWindow ()
34- var decorView : JavaObject = window .getDecorView ()
35- decorView .setBackgroundColor (color .to_argb32 ())
36-
37- if (is_light_system_bars != (color .get_luminance () > 0.45 )) or override_appearance :
38- is_light_system_bars = color .get_luminance () > 0.45
39- var WindowInsetsControllerCompat = JavaClassWrapper .wrap ("androidx.core.view.WindowInsetsControllerCompat" )
40- var controller = WindowInsetsControllerCompat .call ("<init>" , window , window .getDecorView ())
41- controller .setAppearanceLightNavigationBars (is_light_system_bars )
42- controller .setAppearanceLightStatusBars (is_light_system_bars )
43-
44- activity .runOnUiThread (android_runtime .createRunnableFromGodotCallable (callable ))
30+ VTAndroidCore .setWindowColor (color )
31+ system_bar_color = color
4532
4633func toogle_status_bar (visible : bool , override := false ) -> void :
47- if (status_bar_visible == visible and not override ) or not android_runtime :
34+ if (status_bar_visible == visible and not override ) or not VTAndroidCore :
4835 return
49-
50- var activity = android_runtime .getActivity ()
51- var callable = func ():
52- var window = activity .getWindow ()
53- var WindowInsetsControllerCompat = JavaClassWrapper .wrap ("androidx.core.view.WindowInsetsControllerCompat" )
54- var controller = WindowInsetsControllerCompat .call ("<init>" , window , window .getDecorView ())
55- var type = JavaClassWrapper .wrap ("androidx.core.view.WindowInsetsCompat$Type" )
56- if visible :
57- controller .show (type .statusBars ())
58- else :
59- controller .hide (type .statusBars ())
60- controller .setSystemBarsBehavior (WindowInsetsControllerCompat .BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE )
61- status_bar_visible = visible
62-
63- activity .runOnUiThread (android_runtime .createRunnableFromGodotCallable (callable ))
36+ VTAndroidCore .toogleStatusBar (visible )
37+ status_bar_visible = visible
6438
6539var shortcut_registrations : Dictionary [Node , ShortcutsRegistration ] = {}
6640
@@ -94,7 +68,7 @@ func _ready() -> void:
9468 await get_tree ().process_frame # Helps make things more consistent.
9569 update_ui_scale ()
9670
97- android_runtime = Engine .get_singleton ("AndroidRuntime " )
71+ VTAndroidCore = Engine .get_singleton ("VTAndroidCore " )
9872 set_system_bar_color (ThemeUtils .base_color , true )
9973 toogle_status_bar (Configs .current_orientation == Configs .orientation .PORTRAIT )
10074 var version = JavaClassWrapper .wrap ("android.os.Build$VERSION" )
0 commit comments