summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFredia Huya-Kouadio <fhuya@meta.com>2023-07-14 13:46:24 -0700
committerFredia Huya-Kouadio <fhuya@meta.com>2023-07-14 13:46:24 -0700
commitb4844e98619766232645d70f80a29c2a53bc2709 (patch)
tree500a6deee2dfbd36f4356d69a2d5cb762314b03f /plugins
parent1d19d5912d1ac5bfa3cf6cc30f086aee8f0464f2 (diff)
downloadgodot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.tar.gz
godot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.tar.bz2
godot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.zip
Update the directory structure to make room for additional Godot Android samples besides plugins
Diffstat (limited to 'plugins')
-rw-r--r--plugins/README.md8
-rw-r--r--plugins/hello_signals/.gitignore1
-rw-r--r--plugins/hello_signals/README.md4
-rw-r--r--plugins/hello_signals/build.gradle43
-rw-r--r--plugins/hello_signals/demo/.gitignore2
-rw-r--r--plugins/hello_signals/demo/Main.gd27
-rw-r--r--plugins/hello_signals/demo/Main.tscn26
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/export/.gdignore1
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.debug.aarbin0 -> 6826 bytes
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.release.aarbin0 -> 6644 bytes
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_export_plugin.gd16
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_plugin.gd17
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/interface/hello_signals_plugin.gd27
-rw-r--r--plugins/hello_signals/demo/addons/hello_signals_plugin/plugin.cfg7
-rw-r--r--plugins/hello_signals/demo/default_env.tres7
-rw-r--r--plugins/hello_signals/demo/export_presets.cfg201
-rw-r--r--plugins/hello_signals/demo/icon.pngbin0 -> 3305 bytes
-rw-r--r--plugins/hello_signals/demo/project.godot33
-rw-r--r--plugins/hello_signals/src/main/AndroidManifest.xml20
-rw-r--r--plugins/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt59
-rw-r--r--plugins/hello_world/.gitignore1
-rw-r--r--plugins/hello_world/README.md3
-rw-r--r--plugins/hello_world/build.gradle43
-rw-r--r--plugins/hello_world/demo/.gitignore2
-rw-r--r--plugins/hello_world/demo/Main.gd11
-rw-r--r--plugins/hello_world/demo/Main.tscn19
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore0
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aarbin0 -> 6114 bytes
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aarbin0 -> 5978 bytes
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd16
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd17
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd18
-rw-r--r--plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg7
-rw-r--r--plugins/hello_world/demo/default_env.tres7
-rw-r--r--plugins/hello_world/demo/export_presets.cfg201
-rw-r--r--plugins/hello_world/demo/icon.pngbin0 -> 7370 bytes
-rw-r--r--plugins/hello_world/demo/project.godot33
-rw-r--r--plugins/hello_world/src/main/AndroidManifest.xml20
-rw-r--r--plugins/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java49
-rw-r--r--plugins/hello_world/src/main/res/layout/hello_world_view.xml16
-rw-r--r--plugins/hello_world/src/main/res/values/strings.xml4
41 files changed, 966 insertions, 0 deletions
diff --git a/plugins/README.md b/plugins/README.md
new file mode 100644
index 0000000..9437f4f
--- /dev/null
+++ b/plugins/README.md
@@ -0,0 +1,8 @@
+# Godot-Android-Plugins
+
+**Requires Godot 4.2 or above**
+
+Collection of samples showcasing how Godot Android plugins are built and packaged.
+
+- [Hello World plugin](hello_world/README.md)
+- [Hello Signals plugin](hello_signals/README.md)
diff --git a/plugins/hello_signals/.gitignore b/plugins/hello_signals/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/plugins/hello_signals/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/plugins/hello_signals/README.md b/plugins/hello_signals/README.md
new file mode 100644
index 0000000..7845f21
--- /dev/null
+++ b/plugins/hello_signals/README.md
@@ -0,0 +1,4 @@
+## Hello Signals plugin
+
+Showcases how to build a Godot Android plugin which is invoked from gdscript and emit signals
+from the java logic.
diff --git a/plugins/hello_signals/build.gradle b/plugins/hello_signals/build.gradle
new file mode 100644
index 0000000..6549636
--- /dev/null
+++ b/plugins/hello_signals/build.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ compileSdk versions.compileSdk
+
+ defaultConfig {
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
+ versionCode 1
+ versionName "1.0"
+ }
+
+ // Used to customize the name of generated AAR file.
+ libraryVariants.all { variant ->
+ variant.outputs.all { output ->
+ output.outputFileName = "HelloSignals.${variant.name}.aar"
+ }
+ }
+
+}
+
+dependencies {
+ compileOnly "org.godotengine:godot:$versions.godotLibVersion"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion"
+}
+
+task copyDebugAARToAddons(type: Copy) {
+ from 'build/outputs/aar'
+ include 'HelloSignals.debug.aar'
+ into 'demo/addons/hello_signals_plugin/export'
+}
+
+task copyReleaseAARToAddons(type: Copy) {
+ from 'build/outputs/aar'
+ include 'HelloSignals.release.aar'
+ into 'demo/addons/hello_signals_plugin/export'
+}
+
+assemble.finalizedBy(copyDebugAARToAddons)
+assemble.finalizedBy(copyReleaseAARToAddons)
diff --git a/plugins/hello_signals/demo/.gitignore b/plugins/hello_signals/demo/.gitignore
new file mode 100644
index 0000000..b405634
--- /dev/null
+++ b/plugins/hello_signals/demo/.gitignore
@@ -0,0 +1,2 @@
+*.import
+/android/
diff --git a/plugins/hello_signals/demo/Main.gd b/plugins/hello_signals/demo/Main.gd
new file mode 100644
index 0000000..2dca0db
--- /dev/null
+++ b/plugins/hello_signals/demo/Main.gd
@@ -0,0 +1,27 @@
+extends Node2D
+
+var timerCount = 0
+var timerRunning = false
+var helloSignalsPlugin : HelloSignalsPlugin
+
+func _ready():
+ helloSignalsPlugin = preload("res://addons/hello_signals_plugin/interface/hello_signals_plugin.gd").new()
+ helloSignalsPlugin.registerForTikTok(Callable(self, "_on_tiktok"))
+
+ $Button.connect("pressed", Callable(self, "_on_Button_pressed"))
+
+
+func _on_tiktok():
+ print("TikTok signal received")
+ timerCount = timerCount + 1
+ $Label.text = str(timerCount)
+
+
+func _on_Button_pressed():
+ print("on button pressed from GDScript")
+ helloSignalsPlugin.toggleTikTok()
+ timerRunning = !timerRunning
+ if (timerRunning):
+ $Button.text = "Stop Timer"
+ else:
+ $Button.text = "Start Timer"
diff --git a/plugins/hello_signals/demo/Main.tscn b/plugins/hello_signals/demo/Main.tscn
new file mode 100644
index 0000000..2f51657
--- /dev/null
+++ b/plugins/hello_signals/demo/Main.tscn
@@ -0,0 +1,26 @@
+[gd_scene load_steps=3 format=3 uid="uid://bdybkbximkyj2"]
+
+[ext_resource type="Script" path="res://Main.gd" id="1"]
+
+[sub_resource type="StyleBoxEmpty" id="1"]
+
+[node name="Main" type="Node2D"]
+script = ExtResource("1")
+
+[node name="Button" type="Button" parent="."]
+offset_left = 90.0
+offset_top = 178.0
+offset_right = 281.0
+offset_bottom = 261.0
+scale = Vector2(2, 2)
+text = "Start Timer"
+
+[node name="Label" type="Label" parent="."]
+offset_left = 515.0
+offset_top = 217.0
+offset_right = 591.0
+offset_bottom = 265.0
+scale = Vector2(2, 2)
+theme_override_styles/normal = SubResource("1")
+text = "00"
+uppercase = true
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/export/.gdignore b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/.gdignore
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/.gdignore
@@ -0,0 +1 @@
+
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.debug.aar b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.debug.aar
new file mode 100644
index 0000000..d241ab1
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.debug.aar
Binary files differ
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.release.aar b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.release.aar
new file mode 100644
index 0000000..6dae345
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/HelloSignals.release.aar
Binary files differ
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_export_plugin.gd b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_export_plugin.gd
new file mode 100644
index 0000000..f0f3288
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_export_plugin.gd
@@ -0,0 +1,16 @@
+@tool
+extends EditorExportPlugin
+
+func _supports_platform(platform):
+ if platform is EditorExportPlatformAndroid:
+ return true
+ return false
+
+func _get_android_libraries(platform, debug):
+ if debug:
+ return PackedStringArray(["hello_signals_plugin/export/HelloSignals.debug.aar"])
+ else:
+ return PackedStringArray(["hello_signals_plugin/export/HelloSignals.release.aar"])
+
+func _get_name():
+ return "Hello Signals plugin"
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_plugin.gd b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_plugin.gd
new file mode 100644
index 0000000..5c71083
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/export/hello_signals_editor_plugin.gd
@@ -0,0 +1,17 @@
+@tool
+extends EditorPlugin
+
+# A class member to hold the export plugin during its lifecycle
+var export_plugin : EditorExportPlugin
+
+func _enter_tree():
+ # Initialization of the plugin goes here.
+ export_plugin = preload("hello_signals_editor_export_plugin.gd").new()
+ add_export_plugin(export_plugin)
+ pass
+
+
+func _exit_tree():
+ # Clean-up of the plugin goes here.
+ remove_export_plugin(export_plugin)
+ export_plugin = null
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/interface/hello_signals_plugin.gd b/plugins/hello_signals/demo/addons/hello_signals_plugin/interface/hello_signals_plugin.gd
new file mode 100644
index 0000000..0cc9c1d
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/interface/hello_signals_plugin.gd
@@ -0,0 +1,27 @@
+class_name HelloSignalsPlugin extends Object
+
+## Interface used to access the functionality provided by the HelloSignals plugin
+
+var _hello_signals_singleton
+
+func _init():
+ if Engine.has_singleton("HelloSignals"):
+ _hello_signals_singleton = Engine.get_singleton("HelloSignals")
+ else:
+ printerr("Couldn't find HelloSignals singleton")
+
+
+## Register for the tiktok signals emitted
+func registerForTikTok(callback: Callable) -> void:
+ if _hello_signals_singleton:
+ _hello_signals_singleton.connect("TikTok", callback)
+ else:
+ printerr("Unable to register for tiktok")
+
+
+## Start tiktok if not started, otherwise stop it
+func toggleTikTok():
+ if _hello_signals_singleton:
+ _hello_signals_singleton.onButtonPressed()
+ else:
+ printerr("Unable to toggle tiktok")
diff --git a/plugins/hello_signals/demo/addons/hello_signals_plugin/plugin.cfg b/plugins/hello_signals/demo/addons/hello_signals_plugin/plugin.cfg
new file mode 100644
index 0000000..b32555f
--- /dev/null
+++ b/plugins/hello_signals/demo/addons/hello_signals_plugin/plugin.cfg
@@ -0,0 +1,7 @@
+[plugin]
+
+name="Hello Signals plugin"
+description="Showcases how to package a sample Android plugin"
+author="Fredia Huya-Kouadio"
+version=""
+script="export/hello_signals_editor_plugin.gd"
diff --git a/plugins/hello_signals/demo/default_env.tres b/plugins/hello_signals/demo/default_env.tres
new file mode 100644
index 0000000..529d705
--- /dev/null
+++ b/plugins/hello_signals/demo/default_env.tres
@@ -0,0 +1,7 @@
+[gd_resource type="Environment" load_steps=2 format=3 uid="uid://gucbhj6rar4r"]
+
+[sub_resource type="Sky" id="1"]
+
+[resource]
+background_mode = 2
+sky = SubResource("1")
diff --git a/plugins/hello_signals/demo/export_presets.cfg b/plugins/hello_signals/demo/export_presets.cfg
new file mode 100644
index 0000000..1d4cb1f
--- /dev/null
+++ b/plugins/hello_signals/demo/export_presets.cfg
@@ -0,0 +1,201 @@
+[preset.0]
+
+name="Android"
+platform="Android"
+runnable=true
+dedicated_server=false
+custom_features=""
+export_filter="all_resources"
+include_filter=""
+exclude_filter=""
+export_path="android/Hello Signals Plugin Demo.apk"
+encryption_include_filters=""
+encryption_exclude_filters=""
+encrypt_pck=false
+encrypt_directory=false
+
+[preset.0.options]
+
+custom_template/debug=""
+custom_template/release=""
+gradle_build/use_gradle_build=true
+gradle_build/export_format=0
+gradle_build/min_sdk=""
+gradle_build/target_sdk=""
+architectures/armeabi-v7a=true
+architectures/arm64-v8a=true
+architectures/x86=false
+architectures/x86_64=false
+version/code=1
+version/name="1.0"
+package/unique_name="fhuyakou.godot.plugin.android.hellosignals.demo"
+package/name=""
+package/signed=true
+package/app_category=2
+package/retain_data_on_uninstall=false
+package/exclude_from_recents=false
+launcher_icons/main_192x192=""
+launcher_icons/adaptive_foreground_432x432=""
+launcher_icons/adaptive_background_432x432=""
+graphics/opengl_debug=false
+xr_features/xr_mode=0
+screen/immersive_mode=true
+screen/support_small=true
+screen/support_normal=true
+screen/support_large=true
+screen/support_xlarge=true
+user_data_backup/allow=false
+command_line/extra_args=""
+apk_expansion/enable=false
+apk_expansion/SALT=""
+apk_expansion/public_key=""
+permissions/custom_permissions=PackedStringArray()
+permissions/access_checkin_properties=false
+permissions/access_coarse_location=false
+permissions/access_fine_location=false
+permissions/access_location_extra_commands=false
+permissions/access_mock_location=false
+permissions/access_network_state=false
+permissions/access_surface_flinger=false
+permissions/access_wifi_state=false
+permissions/account_manager=false
+permissions/add_voicemail=false
+permissions/authenticate_accounts=false
+permissions/battery_stats=false
+permissions/bind_accessibility_service=false
+permissions/bind_appwidget=false
+permissions/bind_device_admin=false
+permissions/bind_input_method=false
+permissions/bind_nfc_service=false
+permissions/bind_notification_listener_service=false
+permissions/bind_print_service=false
+permissions/bind_remoteviews=false
+permissions/bind_text_service=false
+permissions/bind_vpn_service=false
+permissions/bind_wallpaper=false
+permissions/bluetooth=false
+permissions/bluetooth_admin=false
+permissions/bluetooth_privileged=false
+permissions/brick=false
+permissions/broadcast_package_removed=false
+permissions/broadcast_sms=false
+permissions/broadcast_sticky=false
+permissions/broadcast_wap_push=false
+permissions/call_phone=false
+permissions/call_privileged=false
+permissions/camera=false
+permissions/capture_audio_output=false
+permissions/capture_secure_video_output=false
+permissions/capture_video_output=false
+permissions/change_component_enabled_state=false
+permissions/change_configuration=false
+permissions/change_network_state=false
+permissions/change_wifi_multicast_state=false
+permissions/change_wifi_state=false
+permissions/clear_app_cache=false
+permissions/clear_app_user_data=false
+permissions/control_location_updates=false
+permissions/delete_cache_files=false
+permissions/delete_packages=false
+permissions/device_power=false
+permissions/diagnostic=false
+permissions/disable_keyguard=false
+permissions/dump=false
+permissions/expand_status_bar=false
+permissions/factory_test=false
+permissions/flashlight=false
+permissions/force_back=false
+permissions/get_accounts=false
+permissions/get_package_size=false
+permissions/get_tasks=false
+permissions/get_top_activity_info=false
+permissions/global_search=false
+permissions/hardware_test=false
+permissions/inject_events=false
+permissions/install_location_provider=false
+permissions/install_packages=false
+permissions/install_shortcut=false
+permissions/internal_system_window=false
+permissions/internet=false
+permissions/kill_background_processes=false
+permissions/location_hardware=false
+permissions/manage_accounts=false
+permissions/manage_app_tokens=false
+permissions/manage_documents=false
+permissions/manage_external_storage=false
+permissions/master_clear=false
+permissions/media_content_control=false
+permissions/modify_audio_settings=false
+permissions/modify_phone_state=false
+permissions/mount_format_filesystems=false
+permissions/mount_unmount_filesystems=false
+permissions/nfc=false
+permissions/persistent_activity=false
+permissions/process_outgoing_calls=false
+permissions/read_calendar=false
+permissions/read_call_log=false
+permissions/read_contacts=false
+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_phone_state=false
+permissions/read_profile=false
+permissions/read_sms=false
+permissions/read_social_stream=false
+permissions/read_sync_settings=false
+permissions/read_sync_stats=false
+permissions/read_user_dictionary=false
+permissions/reboot=false
+permissions/receive_boot_completed=false
+permissions/receive_mms=false
+permissions/receive_sms=false
+permissions/receive_wap_push=false
+permissions/record_audio=false
+permissions/reorder_tasks=false
+permissions/restart_packages=false
+permissions/send_respond_via_message=false
+permissions/send_sms=false
+permissions/set_activity_watcher=false
+permissions/set_alarm=false
+permissions/set_always_finish=false
+permissions/set_animation_scale=false
+permissions/set_debug_app=false
+permissions/set_orientation=false
+permissions/set_pointer_speed=false
+permissions/set_preferred_applications=false
+permissions/set_process_limit=false
+permissions/set_time=false
+permissions/set_time_zone=false
+permissions/set_wallpaper=false
+permissions/set_wallpaper_hints=false
+permissions/signal_persistent_processes=false
+permissions/status_bar=false
+permissions/subscribed_feeds_read=false
+permissions/subscribed_feeds_write=false
+permissions/system_alert_window=false
+permissions/transmit_ir=false
+permissions/uninstall_shortcut=false
+permissions/update_device_stats=false
+permissions/use_credentials=false
+permissions/use_sip=false
+permissions/vibrate=false
+permissions/wake_lock=false
+permissions/write_apn_settings=false
+permissions/write_calendar=false
+permissions/write_call_log=false
+permissions/write_contacts=false
+permissions/write_external_storage=false
+permissions/write_gservices=false
+permissions/write_history_bookmarks=false
+permissions/write_profile=false
+permissions/write_secure_settings=false
+permissions/write_settings=false
+permissions/write_sms=false
+permissions/write_social_stream=false
+permissions/write_sync_settings=false
+permissions/write_user_dictionary=false
+xr_features/hand_tracking=0
+xr_features/hand_tracking_frequency=0
+xr_features/passthrough=0
diff --git a/plugins/hello_signals/demo/icon.png b/plugins/hello_signals/demo/icon.png
new file mode 100644
index 0000000..c98fbb6
--- /dev/null
+++ b/plugins/hello_signals/demo/icon.png
Binary files differ
diff --git a/plugins/hello_signals/demo/project.godot b/plugins/hello_signals/demo/project.godot
new file mode 100644
index 0000000..655eefc
--- /dev/null
+++ b/plugins/hello_signals/demo/project.godot
@@ -0,0 +1,33 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+; [section] ; section goes between []
+; param=value ; assign values to parameters
+
+config_version=5
+
+[application]
+
+config/name="Hello Signals Plugin Demo"
+run/main_scene="res://Main.tscn"
+config/features=PackedStringArray("4.1")
+config/icon="res://icon.png"
+
+[debug]
+
+settings/stdout/verbose_stdout=true
+
+[editor_plugins]
+
+enabled=PackedStringArray("res://addons/hello_signals_plugin/plugin.cfg")
+
+[rendering]
+
+renderer/rendering_method="gl_compatibility"
+renderer/rendering_method.mobile="gl_compatibility"
+textures/vram_compression/import_etc2_astc=true
+environment/defaults/default_environment="res://default_env.tres"
+quality/driver/driver_name="GLES2"
+vram_compression/import_etc=true
diff --git a/plugins/hello_signals/src/main/AndroidManifest.xml b/plugins/hello_signals/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8f791bd
--- /dev/null
+++ b/plugins/hello_signals/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="fhuyakou.godot.plugin.android.hellosignals">
+
+ <application>
+ <!--
+ Plugin metadata:
+
+ - In the `android:name` attribute, the `org.godotengine.plugin.v1` prefix
+ is required so Godot can recognize the project as a valid Godot
+ Android plugin. The plugin name following the prefix should match the value
+ of the plugin name returned by the plugin initializer.
+
+ - The `android:value` attribute should be the classpath to the plugin
+ initializer.
+ -->
+ <meta-data
+ android:name="org.godotengine.plugin.v1.HelloSignals"
+ android:value="fhuyakou.godot.plugin.android.hellosignals.HelloSignalsPlugin" />
+ </application>
+</manifest>
diff --git a/plugins/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt b/plugins/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt
new file mode 100644
index 0000000..d6df7ef
--- /dev/null
+++ b/plugins/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt
@@ -0,0 +1,59 @@
+package fhuyakou.godot.plugin.android.hellosignals
+
+import android.util.Log
+import org.godotengine.godot.Godot
+import org.godotengine.godot.plugin.GodotPlugin
+import org.godotengine.godot.plugin.SignalInfo
+import org.godotengine.godot.plugin.UsedByGodot
+import java.util.concurrent.Executors
+import java.util.concurrent.ScheduledFuture
+import java.util.concurrent.TimeUnit
+
+/**
+ * Exposes a [onButtonPressed] method to the game logic. Invoking the method starts a timer which
+ * fires a `TikTok` signal every second. Invoking the method a second time stops the timer.
+ */
+class HelloSignalsPlugin(godot: Godot) : GodotPlugin(godot) {
+
+ companion object {
+ val TAG = HelloSignalsPlugin::class.java.simpleName
+ }
+
+ private val tikTokSignalInfo = SignalInfo("TikTok")
+ private var tikTokTask : ScheduledFuture<*>? = null
+
+ override fun getPluginName() = "HelloSignals"
+
+ override fun getPluginSignals(): Set<SignalInfo> {
+ Log.i(TAG, "Registering $tikTokSignalInfo")
+ return setOf(tikTokSignalInfo)
+ }
+
+ private fun startTikTok(): Boolean {
+ if (tikTokTask == null || tikTokTask!!.isDone) {
+ Log.i(TAG, "Starting tiktok...")
+ tikTokTask = Executors.newSingleThreadScheduledExecutor()
+ .scheduleAtFixedRate({ emitSignal(tikTokSignalInfo.name) }, 0, 1, TimeUnit.SECONDS)
+ return true
+ }
+ return false
+ }
+
+ private fun stopTikTok() {
+ if (tikTokTask != null) {
+ if (!tikTokTask!!.isDone) {
+ Log.i(TAG, "Stopping tiktok...")
+ tikTokTask!!.cancel(true)
+ }
+ tikTokTask = null
+ }
+ }
+
+ @UsedByGodot
+ private fun onButtonPressed() {
+ Log.i(TAG, "OnButtonPressed from Kotlin")
+ if (!startTikTok()) {
+ stopTikTok()
+ }
+ }
+}
diff --git a/plugins/hello_world/.gitignore b/plugins/hello_world/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/plugins/hello_world/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/plugins/hello_world/README.md b/plugins/hello_world/README.md
new file mode 100644
index 0000000..5cfb640
--- /dev/null
+++ b/plugins/hello_world/README.md
@@ -0,0 +1,3 @@
+## Hello World plugin
+
+Showcase how to build a simple Godot Android plugin which is invoked from gdscript
diff --git a/plugins/hello_world/build.gradle b/plugins/hello_world/build.gradle
new file mode 100644
index 0000000..4c12e93
--- /dev/null
+++ b/plugins/hello_world/build.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ compileSdk versions.compileSdk
+
+ defaultConfig {
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
+ versionCode 1
+ versionName "1.0"
+ }
+
+ // Used to customize the name of generated AAR file.
+ libraryVariants.all { variant ->
+ variant.outputs.all { output ->
+ output.outputFileName = "HelloWorld.${variant.name}.aar"
+ }
+ }
+
+}
+
+dependencies {
+ compileOnly "org.godotengine:godot:$versions.godotLibVersion"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion"
+}
+
+task copyDebugAARToAddons(type: Copy) {
+ from 'build/outputs/aar'
+ include 'HelloWorld.debug.aar'
+ into 'demo/addons/hello_world_plugin/export'
+}
+
+task copyReleaseAARToAddons(type: Copy) {
+ from 'build/outputs/aar'
+ include 'HelloWorld.release.aar'
+ into 'demo/addons/hello_world_plugin/export'
+}
+
+assemble.finalizedBy(copyDebugAARToAddons)
+assemble.finalizedBy(copyReleaseAARToAddons)
diff --git a/plugins/hello_world/demo/.gitignore b/plugins/hello_world/demo/.gitignore
new file mode 100644
index 0000000..b405634
--- /dev/null
+++ b/plugins/hello_world/demo/.gitignore
@@ -0,0 +1,2 @@
+*.import
+/android/
diff --git a/plugins/hello_world/demo/Main.gd b/plugins/hello_world/demo/Main.gd
new file mode 100644
index 0000000..c5174eb
--- /dev/null
+++ b/plugins/hello_world/demo/Main.gd
@@ -0,0 +1,11 @@
+extends Node2D
+
+var hello_world_plugin : HelloWorldPlugin
+
+func _ready():
+ hello_world_plugin = preload("res://addons/hello_world_plugin/interface/hello_world_plugin.gd").new()
+
+
+func _on_Button_pressed():
+ if hello_world_plugin:
+ hello_world_plugin.helloWorld()
diff --git a/plugins/hello_world/demo/Main.tscn b/plugins/hello_world/demo/Main.tscn
new file mode 100644
index 0000000..57d3eb0
--- /dev/null
+++ b/plugins/hello_world/demo/Main.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=2 format=3 uid="uid://bgtr75kiyu5fh"]
+
+[ext_resource type="Script" path="res://Main.gd" id="1"]
+
+[node name="Main" type="Node2D"]
+script = ExtResource("1")
+
+[node name="Button" type="Button" parent="."]
+anchors_preset = 14
+anchor_top = 0.5
+anchor_right = 1.0
+anchor_bottom = 0.5
+offset_left = 40.0
+offset_top = 250.0
+offset_right = 320.0
+offset_bottom = 312.0
+text = "Hello World"
+
+[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore b/plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar
new file mode 100644
index 0000000..4d59e06
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar
Binary files differ
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar
new file mode 100644
index 0000000..6b112c5
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar
Binary files differ
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd b/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd
new file mode 100644
index 0000000..46a8a3b
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd
@@ -0,0 +1,16 @@
+@tool
+extends EditorExportPlugin
+
+func _supports_platform(platform):
+ if platform is EditorExportPlatformAndroid:
+ return true
+ return false
+
+func _get_android_libraries(platform, debug):
+ if debug:
+ return PackedStringArray(["hello_world_plugin/export/HelloWorld.debug.aar"])
+ else:
+ return PackedStringArray(["hello_world_plugin/export/HelloWorld.release.aar"])
+
+func _get_name():
+ return "HelloWorldPlugin"
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd b/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd
new file mode 100644
index 0000000..3865634
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd
@@ -0,0 +1,17 @@
+@tool
+extends EditorPlugin
+
+# A class member to hold the export plugin during its lifecycle.
+var export_plugin : EditorExportPlugin
+
+func _enter_tree():
+ # Initialization of the plugin goes here.
+ export_plugin = preload("hello_world_editor_export_plugin.gd").new()
+ add_export_plugin(export_plugin)
+ pass
+
+
+func _exit_tree():
+ # Clean-up of the plugin goes here.
+ remove_export_plugin(export_plugin)
+ export_plugin = null
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd b/plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd
new file mode 100644
index 0000000..ed84ef3
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd
@@ -0,0 +1,18 @@
+class_name HelloWorldPlugin extends Object
+
+## Interface used to access the functionality provided by this plugin
+
+var _hello_world_singleton
+
+func _init():
+ if Engine.has_singleton("HelloWorld"):
+ _hello_world_singleton = Engine.get_singleton("HelloWorld")
+ else:
+ printerr("Initialization error: unable to access the java logic")
+
+## Toggle between showing and hiding the hello world text
+func helloWorld():
+ if _hello_world_singleton:
+ _hello_world_singleton.helloWorld()
+ else:
+ printerr("Initialization error")
diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg b/plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg
new file mode 100644
index 0000000..bc8575e
--- /dev/null
+++ b/plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg
@@ -0,0 +1,7 @@
+[plugin]
+
+name="HelloWorldPlugin"
+description="Sample to showcase how to package a Godot Android plugin "
+author="Fredia Huya-Kouadio (m4gr3d)"
+version=""
+script="export/hello_world_editor_plugin.gd"
diff --git a/plugins/hello_world/demo/default_env.tres b/plugins/hello_world/demo/default_env.tres
new file mode 100644
index 0000000..3868def
--- /dev/null
+++ b/plugins/hello_world/demo/default_env.tres
@@ -0,0 +1,7 @@
+[gd_resource type="Environment" load_steps=2 format=3 uid="uid://bi2meuxrf37pv"]
+
+[sub_resource type="Sky" id="1"]
+
+[resource]
+background_mode = 2
+sky = SubResource("1")
diff --git a/plugins/hello_world/demo/export_presets.cfg b/plugins/hello_world/demo/export_presets.cfg
new file mode 100644
index 0000000..6356705
--- /dev/null
+++ b/plugins/hello_world/demo/export_presets.cfg
@@ -0,0 +1,201 @@
+[preset.0]
+
+name="Android"
+platform="Android"
+runnable=true
+dedicated_server=false
+custom_features=""
+export_filter="all_resources"
+include_filter=""
+exclude_filter=""
+export_path="android/Hello World Plugin Demo.apk"
+encryption_include_filters=""
+encryption_exclude_filters=""
+encrypt_pck=false
+encrypt_directory=false
+
+[preset.0.options]
+
+custom_template/debug=""
+custom_template/release=""
+gradle_build/use_gradle_build=true
+gradle_build/export_format=0
+gradle_build/min_sdk=""
+gradle_build/target_sdk=""
+architectures/armeabi-v7a=true
+architectures/arm64-v8a=true
+architectures/x86=false
+architectures/x86_64=false
+version/code=1
+version/name="1.0"
+package/unique_name="fhuyakou.godot.plugin.android.helloworld.demo"
+package/name=""
+package/signed=true
+package/app_category=2
+package/retain_data_on_uninstall=false
+package/exclude_from_recents=false
+launcher_icons/main_192x192=""
+launcher_icons/adaptive_foreground_432x432=""
+launcher_icons/adaptive_background_432x432=""
+graphics/opengl_debug=false
+xr_features/xr_mode=0
+screen/immersive_mode=true
+screen/support_small=true
+screen/support_normal=true
+screen/support_large=true
+screen/support_xlarge=true
+user_data_backup/allow=false
+command_line/extra_args=""
+apk_expansion/enable=false
+apk_expansion/SALT=""
+apk_expansion/public_key=""
+permissions/custom_permissions=PackedStringArray()
+permissions/access_checkin_properties=false
+permissions/access_coarse_location=false
+permissions/access_fine_location=false
+permissions/access_location_extra_commands=false
+permissions/access_mock_location=false
+permissions/access_network_state=false
+permissions/access_surface_flinger=false
+permissions/access_wifi_state=false
+permissions/account_manager=false
+permissions/add_voicemail=false
+permissions/authenticate_accounts=false
+permissions/battery_stats=false
+permissions/bind_accessibility_service=false
+permissions/bind_appwidget=false
+permissions/bind_device_admin=false
+permissions/bind_input_method=false
+permissions/bind_nfc_service=false
+permissions/bind_notification_listener_service=false
+permissions/bind_print_service=false
+permissions/bind_remoteviews=false
+permissions/bind_text_service=false
+permissions/bind_vpn_service=false
+permissions/bind_wallpaper=false
+permissions/bluetooth=false
+permissions/bluetooth_admin=false
+permissions/bluetooth_privileged=false
+permissions/brick=false
+permissions/broadcast_package_removed=false
+permissions/broadcast_sms=false
+permissions/broadcast_sticky=false
+permissions/broadcast_wap_push=false
+permissions/call_phone=false
+permissions/call_privileged=false
+permissions/camera=false
+permissions/capture_audio_output=false
+permissions/capture_secure_video_output=false
+permissions/capture_video_output=false
+permissions/change_component_enabled_state=false
+permissions/change_configuration=false
+permissions/change_network_state=false
+permissions/change_wifi_multicast_state=false
+permissions/change_wifi_state=false
+permissions/clear_app_cache=false
+permissions/clear_app_user_data=false
+permissions/control_location_updates=false
+permissions/delete_cache_files=false
+permissions/delete_packages=false
+permissions/device_power=false
+permissions/diagnostic=false
+permissions/disable_keyguard=false
+permissions/dump=false
+permissions/expand_status_bar=false
+permissions/factory_test=false
+permissions/flashlight=false
+permissions/force_back=false
+permissions/get_accounts=false
+permissions/get_package_size=false
+permissions/get_tasks=false
+permissions/get_top_activity_info=false
+permissions/global_search=false
+permissions/hardware_test=false
+permissions/inject_events=false
+permissions/install_location_provider=false
+permissions/install_packages=false
+permissions/install_shortcut=false
+permissions/internal_system_window=false
+permissions/internet=false
+permissions/kill_background_processes=false
+permissions/location_hardware=false
+permissions/manage_accounts=false
+permissions/manage_app_tokens=false
+permissions/manage_documents=false
+permissions/manage_external_storage=false
+permissions/master_clear=false
+permissions/media_content_control=false
+permissions/modify_audio_settings=false
+permissions/modify_phone_state=false
+permissions/mount_format_filesystems=false
+permissions/mount_unmount_filesystems=false
+permissions/nfc=false
+permissions/persistent_activity=false
+permissions/process_outgoing_calls=false
+permissions/read_calendar=false
+permissions/read_call_log=false
+permissions/read_contacts=false
+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_phone_state=false
+permissions/read_profile=false
+permissions/read_sms=false
+permissions/read_social_stream=false
+permissions/read_sync_settings=false
+permissions/read_sync_stats=false
+permissions/read_user_dictionary=false
+permissions/reboot=false
+permissions/receive_boot_completed=false
+permissions/receive_mms=false
+permissions/receive_sms=false
+permissions/receive_wap_push=false
+permissions/record_audio=false
+permissions/reorder_tasks=false
+permissions/restart_packages=false
+permissions/send_respond_via_message=false
+permissions/send_sms=false
+permissions/set_activity_watcher=false
+permissions/set_alarm=false
+permissions/set_always_finish=false
+permissions/set_animation_scale=false
+permissions/set_debug_app=false
+permissions/set_orientation=false
+permissions/set_pointer_speed=false
+permissions/set_preferred_applications=false
+permissions/set_process_limit=false
+permissions/set_time=false
+permissions/set_time_zone=false
+permissions/set_wallpaper=false
+permissions/set_wallpaper_hints=false
+permissions/signal_persistent_processes=false
+permissions/status_bar=false
+permissions/subscribed_feeds_read=false
+permissions/subscribed_feeds_write=false
+permissions/system_alert_window=false
+permissions/transmit_ir=false
+permissions/uninstall_shortcut=false
+permissions/update_device_stats=false
+permissions/use_credentials=false
+permissions/use_sip=false
+permissions/vibrate=false
+permissions/wake_lock=false
+permissions/write_apn_settings=false
+permissions/write_calendar=false
+permissions/write_call_log=false
+permissions/write_contacts=false
+permissions/write_external_storage=false
+permissions/write_gservices=false
+permissions/write_history_bookmarks=false
+permissions/write_profile=false
+permissions/write_secure_settings=false
+permissions/write_settings=false
+permissions/write_sms=false
+permissions/write_social_stream=false
+permissions/write_sync_settings=false
+permissions/write_user_dictionary=false
+xr_features/hand_tracking=0
+xr_features/hand_tracking_frequency=0
+xr_features/passthrough=0
diff --git a/plugins/hello_world/demo/icon.png b/plugins/hello_world/demo/icon.png
new file mode 100644
index 0000000..5f7f827
--- /dev/null
+++ b/plugins/hello_world/demo/icon.png
Binary files differ
diff --git a/plugins/hello_world/demo/project.godot b/plugins/hello_world/demo/project.godot
new file mode 100644
index 0000000..3fcf242
--- /dev/null
+++ b/plugins/hello_world/demo/project.godot
@@ -0,0 +1,33 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+; [section] ; section goes between []
+; param=value ; assign values to parameters
+
+config_version=5
+
+[application]
+
+config/name="Hello World Plugin Demo"
+run/main_scene="res://Main.tscn"
+config/features=PackedStringArray("4.1")
+config/icon="res://icon.png"
+
+[debug]
+
+settings/stdout/verbose_stdout=true
+
+[editor_plugins]
+
+enabled=PackedStringArray("res://addons/hello_world_plugin/plugin.cfg")
+
+[rendering]
+
+renderer/rendering_method="gl_compatibility"
+renderer/rendering_method.mobile="gl_compatibility"
+textures/vram_compression/import_etc2_astc=true
+environment/defaults/default_environment="res://default_env.tres"
+quality/driver/driver_name="GLES2"
+vram_compression/import_etc=true
diff --git a/plugins/hello_world/src/main/AndroidManifest.xml b/plugins/hello_world/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8bb5fa4
--- /dev/null
+++ b/plugins/hello_world/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="fhuyakou.godot.plugin.android.helloworld">
+
+ <application>
+ <!--
+ Plugin metadata:
+
+ - In the `android:name` attribute, the `org.godotengine.plugin.v1` prefix
+ is required so Godot can recognize the project as a valid Godot
+ Android plugin. The plugin name following the prefix should match the value
+ of the plugin name returned by the plugin initializer.
+
+ - The `android:value` attribute should be the classpath to the plugin
+ initializer.
+ -->
+ <meta-data
+ android:name="org.godotengine.plugin.v1.HelloWorld"
+ android:value="fhuyakou.godot.plugin.android.helloworld.HelloWorldPlugin" />
+ </application>
+</manifest>
diff --git a/plugins/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java b/plugins/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java
new file mode 100644
index 0000000..1dfa1b2
--- /dev/null
+++ b/plugins/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java
@@ -0,0 +1,49 @@
+package fhuyakou.godot.plugin.android.helloworld;
+
+import android.app.Activity;
+import android.view.View;
+import org.godotengine.godot.Godot;
+import org.godotengine.godot.plugin.GodotPlugin;
+import org.godotengine.godot.plugin.UsedByGodot;
+
+public class HelloWorldPlugin extends GodotPlugin {
+
+ private static final String HELLO_WORLD = "Hello World";
+
+ private View helloWorldContainer;
+
+ public HelloWorldPlugin(Godot godot) {
+ super(godot);
+ }
+
+ @Override
+ public String getPluginName() {
+ return "HelloWorld";
+ }
+
+ @Override
+ public View onMainCreate(Activity activity) {
+ View view = activity.getLayoutInflater().inflate(R.layout.hello_world_view, null);
+ helloWorldContainer = view.findViewById(R.id.hello_world_container);
+ return view;
+ }
+
+ /**
+ * Show/hide, print and return "Hello World".
+ */
+ @UsedByGodot
+ public String helloWorld() {
+ if (helloWorldContainer != null) {
+ helloWorldContainer.post(() -> {
+ if (helloWorldContainer.getVisibility() == View.VISIBLE) {
+ helloWorldContainer.setVisibility(View.GONE);
+ } else {
+ helloWorldContainer.setVisibility(View.VISIBLE);
+ }
+ });
+ }
+
+ System.out.println(HELLO_WORLD);
+ return HELLO_WORLD;
+ }
+}
diff --git a/plugins/hello_world/src/main/res/layout/hello_world_view.xml b/plugins/hello_world/src/main/res/layout/hello_world_view.xml
new file mode 100644
index 0000000..e831d87
--- /dev/null
+++ b/plugins/hello_world/src/main/res/layout/hello_world_view.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/hello_world_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:padding="10dp"
+ android:text="@string/hello_world"
+ android:textSize="20sp" />
+
+</FrameLayout> \ No newline at end of file
diff --git a/plugins/hello_world/src/main/res/values/strings.xml b/plugins/hello_world/src/main/res/values/strings.xml
new file mode 100644
index 0000000..d2cf3ac
--- /dev/null
+++ b/plugins/hello_world/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello_world">Hello World</string>
+</resources> \ No newline at end of file