66 lines
2.0 KiB
GDScript
66 lines
2.0 KiB
GDScript
#
|
|
# © 2024-present https://github.com/cengiz-pz
|
|
#
|
|
|
|
@tool
|
|
extends EditorPlugin
|
|
|
|
const PLUGIN_NODE_TYPE_NAME = "Share"
|
|
const PLUGIN_PARENT_NODE_TYPE = "Node"
|
|
const PLUGIN_NAME: String = "SharePlugin"
|
|
const PLUGIN_VERSION: String = "3.0"
|
|
const PLUGIN_PACKAGE: String = "org.godotengine.plugin.android.share"
|
|
const PLUGIN_DEPENDENCIES: Array = [ "androidx.appcompat:appcompat:1.7.0" ]
|
|
|
|
const PROVIDER_TAG = """
|
|
<provider android:name="%s.ShareFileProvider"
|
|
android:exported="false"
|
|
android:authorities="%s.sharefileprovider"
|
|
android:grantUriPermissions="true">
|
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_provider_paths"/>
|
|
</provider>
|
|
"""
|
|
|
|
var export_plugin: AndroidExportPlugin
|
|
|
|
|
|
func _enter_tree() -> void:
|
|
add_custom_type(PLUGIN_NODE_TYPE_NAME, PLUGIN_PARENT_NODE_TYPE, preload("Share.gd"), preload("icon.png"))
|
|
export_plugin = AndroidExportPlugin.new()
|
|
add_export_plugin(export_plugin)
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
remove_custom_type(PLUGIN_NODE_TYPE_NAME)
|
|
remove_export_plugin(export_plugin)
|
|
export_plugin = null
|
|
|
|
|
|
class AndroidExportPlugin extends EditorExportPlugin:
|
|
var _plugin_name = PLUGIN_NAME
|
|
|
|
|
|
func _supports_platform(platform: EditorExportPlatform) -> bool:
|
|
if platform is EditorExportPlatformAndroid:
|
|
return true
|
|
return false
|
|
|
|
|
|
func _get_android_libraries(platform: EditorExportPlatform, debug: bool) -> PackedStringArray:
|
|
if debug:
|
|
return PackedStringArray(["%s/bin/debug/%s-%s-debug.aar" % [_plugin_name, _plugin_name, PLUGIN_VERSION]])
|
|
else:
|
|
return PackedStringArray(["%s/bin/release/%s-%s-release.aar" % [_plugin_name, _plugin_name, PLUGIN_VERSION]])
|
|
|
|
|
|
func _get_name() -> String:
|
|
return _plugin_name
|
|
|
|
|
|
func _get_android_dependencies(platform: EditorExportPlatform, debug: bool) -> PackedStringArray:
|
|
return PackedStringArray(PLUGIN_DEPENDENCIES)
|
|
|
|
|
|
func _get_android_manifest_application_element_contents(platform: EditorExportPlatform, debug: bool) -> String:
|
|
return PROVIDER_TAG % [PLUGIN_PACKAGE, get_option("package/unique_name")]
|