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
Binary file not shown.
Binary file not shown.
40 changes: 40 additions & 0 deletions addons/VTAndroidCore/export_plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@tool
extends EditorPlugin

# A class member to hold the editor export plugin during its lifecycle.
var export_plugin : BillingPluginExportPlugin

func _enter_tree():
# Initialization of the plugin goes here.
export_plugin = BillingPluginExportPlugin.new()
add_export_plugin(export_plugin)


func _exit_tree():
# Clean-up of the plugin goes here.
remove_export_plugin(export_plugin)
export_plugin = null


class BillingPluginExportPlugin extends EditorExportPlugin:
var _plugin_name = "VTAndroidCore"

func _supports_platform(platform):
if platform is EditorExportPlatformAndroid:
return true
return false

func _get_android_libraries(platform, debug):
if debug:
return PackedStringArray([_plugin_name + "/bin/debug/" + _plugin_name + "-debug.aar"])
else:
return PackedStringArray([_plugin_name + "/bin/release/" + _plugin_name + "-release.aar"])

func _get_android_dependencies(platform, debug):
if debug:
return PackedStringArray()
else:
return PackedStringArray()

func _get_name():
return _plugin_name
1 change: 1 addition & 0 deletions addons/VTAndroidCore/export_plugin.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ddhyjofvs0log
7 changes: 7 additions & 0 deletions addons/VTAndroidCore/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="VTAndroidCore"
description="Mandatory plugin for VectorTouch, providing essential Android-specific methods and utilities."
author="Anish Mishra"
version="1.0"
script="export_plugin.gd"
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ text_editor/completion/add_type_hints=true
text_editor/completion/add_node_path_literals=true
text_editor/completion/add_string_name_literals=false
text_editor/appearance/guidelines/line_length_guideline_hard_column=160
enabled=PackedStringArray("res://addons/VTAndroidCore/plugin.cfg")

[filesystem]

Expand Down
46 changes: 10 additions & 36 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,23 @@ var popup_stack: Array[Control]
var shortcut_panel: PanelContainer
var tabs_panel: PanelContainer

var android_runtime: JNISingleton
var is_light_system_bars: bool = false
var VTAndroidCore: JNISingleton
var system_bar_color: Color = Color.BLACK
var status_bar_visible: bool = true

var minimum_content_width : float

func set_system_bar_color(color: Color, override_appearance := false) -> void:
if not android_runtime:
func set_system_bar_color(color: Color, override := false) -> void:
if (system_bar_color == color and not override) or not VTAndroidCore:
return

var activity = android_runtime.getActivity()
var callable = func ():
var window = activity.getWindow()
var decorView: JavaObject = window.getDecorView()
decorView.setBackgroundColor(color.to_argb32())

if (is_light_system_bars != (color.get_luminance() > 0.45)) or override_appearance:
is_light_system_bars = color.get_luminance() > 0.45
var WindowInsetsControllerCompat = JavaClassWrapper.wrap("androidx.core.view.WindowInsetsControllerCompat")
var controller = WindowInsetsControllerCompat.call("<init>", window, window.getDecorView())
controller.setAppearanceLightNavigationBars(is_light_system_bars)
controller.setAppearanceLightStatusBars(is_light_system_bars)

activity.runOnUiThread(android_runtime.createRunnableFromGodotCallable(callable))
VTAndroidCore.setWindowColor(color)
system_bar_color = color

func toogle_status_bar(visible: bool, override := false) -> void:
if (status_bar_visible == visible and not override) or not android_runtime:
if (status_bar_visible == visible and not override) or not VTAndroidCore:
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))
VTAndroidCore.toogleStatusBar(visible)
status_bar_visible = visible

var shortcut_registrations: Dictionary[Node, ShortcutsRegistration] = {}

Expand Down Expand Up @@ -94,7 +68,7 @@ func _ready() -> void:
await get_tree().process_frame # Helps make things more consistent.
update_ui_scale()

android_runtime = Engine.get_singleton("AndroidRuntime")
VTAndroidCore = Engine.get_singleton("VTAndroidCore")
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")
Expand Down