Skip to content

Commit 40805d3

Browse files
authored
6 add share completed share failed share cancelled signals (#7)
* Added completed, canceled, & failed signals * Added signal info to README doc
1 parent 070b29b commit 40805d3

37 files changed

+1064
-637
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ body:
7575
options:
7676
- "5.0"
7777
- "5.1"
78-
- "5.2"
7978
- Other
80-
default: 2
79+
default: 1
8180
validations:
8281
required: true
8382
- type: dropdown

.github/ISSUE_TEMPLATE/feature_request.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ body:
7272
options:
7373
- "5.0"
7474
- "5.1"
75-
- "5.2"
7675
- Other
77-
default: 2
76+
default: 1
7877
validations:
7978
required: true
8079
- type: dropdown

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ demo/addons
66
demo/android
77
demo/ios
88
build/
9+
release/
910
export.cfg
1011

1112
# General
@@ -15,6 +16,7 @@ export.cfg
1516
# Android
1617
.gradle/
1718
*.jar
19+
!android/gradle/wrapper/gradle-wrapper.jar
1820
*.aar
1921
local.properties
2022

@@ -25,6 +27,7 @@ local.properties
2527
*.d
2628
*.o
2729
*.dblite
30+
xcuserdata/
2831
Pods/
2932
ios/godot/
3033

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Share Plugin allows sharing of text and images on Android and iOS platforms.
2222
## <img src="addon/icon.png" width="20"> Table of Contents
2323
- [Installation](#installation)
2424
- [Usage](#usage)
25+
- [Signals](#signals)
2526
- [Platform-Specific Notes](#platform-specific-notes)
2627
- [Links](#links)
2728
- [All Plugins](#all-plugins)
@@ -65,6 +66,18 @@ Add a `Share` node to your scene and follow the following steps:
6566

6667
---
6768

69+
<a name="signals"></a>
70+
71+
## <img src="addon/icon.png" width="20"> Signals
72+
73+
- `share_completed`: Emitted when shared item is sent on iOS. On Android, emitted when a share target is selected on the chooser screen.
74+
- `share_canceled`: Emitted when user does not send shared item on iOS. On Android, emitted when user returns to app without making a selection on chooser screen within threshold milliseconds (default threshold is 5000ms).
75+
- `share_failed`: Emitted when a failure that prevents sharing occurs.
76+
77+
*Note: On Android, `share_completed` signal does not mean that the user actually sent the shared item.*
78+
79+
---
80+
6881
<a name="platform-specific-notes"></a>
6982

7083
## <img src="addon/icon.png" width="20"> Platform-Specific Notes

addon/Share.gd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ class_name Share extends Node
77

88
const PLUGIN_SINGLETON_NAME: String = "@pluginName@"
99

10+
signal share_completed(activity_type: String)
11+
signal share_failed(error_message: String)
12+
signal share_canceled()
13+
1014
const MIME_TYPE_TEXT: String = "text/plain"
1115
const MIME_TYPE_IMAGE: String = "image/*"
1216

17+
const SIGNAL_NAME_SHARE_COMPLETED: String = "share_completed";
18+
const SIGNAL_NAME_SHARE_FAILED: String = "share_failed";
19+
const SIGNAL_NAME_SHARE_CANCELED: String = "share_canceled";
20+
1321
@onready var _temp_image_path: String = OS.get_user_data_dir() + "/tmp_share_img_path.png"
1422

1523
var _plugin_singleton: Object
@@ -28,10 +36,17 @@ func _update_plugin() -> void:
2836
if _plugin_singleton == null:
2937
if Engine.has_singleton(PLUGIN_SINGLETON_NAME):
3038
_plugin_singleton = Engine.get_singleton(PLUGIN_SINGLETON_NAME)
39+
_connect_signals()
3140
elif not OS.has_feature("editor_hint"):
3241
log_error("%s singleton not found!" % PLUGIN_SINGLETON_NAME)
3342

3443

44+
func _connect_signals() -> void:
45+
_plugin_singleton.connect(SIGNAL_NAME_SHARE_COMPLETED, _on_share_completed)
46+
_plugin_singleton.connect(SIGNAL_NAME_SHARE_FAILED, _on_share_failed)
47+
_plugin_singleton.connect(SIGNAL_NAME_SHARE_CANCELED, _on_share_canceled)
48+
49+
3550
func share_text(a_title: String, a_subject: String, a_content: String) -> void:
3651
if _plugin_singleton != null:
3752
_plugin_singleton.share(
@@ -79,6 +94,18 @@ func share_file(a_path: String, a_mime_type: String, a_title: String, a_subject:
7994
log_error("%s plugin not initialized" % PLUGIN_SINGLETON_NAME)
8095

8196

97+
func _on_share_completed(a_activity_type: String) -> void:
98+
emit_signal(SIGNAL_NAME_SHARE_COMPLETED, a_activity_type)
99+
100+
101+
func _on_share_failed(a_error_message: String) -> void:
102+
emit_signal(SIGNAL_NAME_SHARE_FAILED, a_error_message)
103+
104+
105+
func _on_share_canceled() -> void:
106+
emit_signal(SIGNAL_NAME_SHARE_CANCELED)
107+
108+
82109
static func log_error(a_description: String) -> void:
83110
push_error(a_description)
84111

addon/model/SharedData.gd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# © 2024-present https://github.com/cengiz-pz
33
#
44

5-
class_name SharedData
6-
extends RefCounted
5+
class_name SharedData extends RefCounted
76

87
const DATA_KEY_TITLE = "title"
98
const DATA_KEY_SUBJECT = "subject"
109
const DATA_KEY_CONTENT = "content"
1110
const DATA_KEY_FILE_PATH = "file_path"
1211
const DATA_KEY_MIME_TYPE = "mime_type"
12+
const DATA_KEY_CUSTOM_THRESHOLD_MS = "custom_threshold"
1313

1414
var _data: Dictionary
1515

@@ -43,5 +43,10 @@ func set_mime_type(a_mime_type: String) -> SharedData:
4343
return self
4444

4545

46+
func set_custom_threshold(a_threshold_ms: int) -> SharedData:
47+
_data[DATA_KEY_CUSTOM_THRESHOLD_MS] = a_threshold_ms
48+
return self
49+
50+
4651
func get_raw_data() -> Dictionary:
4752
return _data

android/config.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extra.apply {
3434
set("templateDirectory", "../../addon")
3535

3636
// iOS
37+
set("iosPlatformVersion", iosProperties.getProperty("platform_version"))
3738
set("iosFrameworks", iosProperties.getProperty("frameworks"))
3839
set("iosEmbeddedFrameworks", iosProperties.getProperty("embedded_frameworks"))
3940
set("iosLinkerFlags", iosProperties.getProperty("flags"))
59.3 KB
Binary file not shown.

android/gradlew

100644100755
File mode changed.

android/share/build.gradle.kts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// © 2024-present https://github.com/cengiz-pz
33
//
44

5-
import org.apache.tools.ant.filters.ReplaceTokens
65
import com.android.build.gradle.internal.api.LibraryVariantOutputImpl
76

7+
import org.apache.tools.ant.filters.ReplaceTokens
8+
9+
810
plugins {
911
alias(libs.plugins.android.library)
1012
alias(libs.plugins.kotlin.android)
@@ -42,7 +44,7 @@ android {
4244

4345
buildToolsVersion = libs.versions.buildTools.get()
4446

45-
// Force AAR filenames to match original case and format
47+
// Force AAR filenames to match original case and format
4648
libraryVariants.all {
4749
outputs.all {
4850
val outputImpl = this as LibraryVariantOutputImpl
@@ -102,6 +104,7 @@ tasks {
102104
"pluginVersion" to (project.extra["pluginVersion"] as String),
103105
"pluginPackage" to (project.extra["pluginPackageName"] as String),
104106
"androidDependencies" to androidDependencies.joinToString(", ") { "\"$it\"" },
107+
"iosPlatformVersion" to (project.extra["iosPlatformVersion"] as String),
105108
"iosFrameworks" to (project.extra["iosFrameworks"] as String)
106109
.split(",")
107110
.map { it.trim() }
@@ -121,9 +124,27 @@ tasks {
121124
}
122125

123126
register<de.undercouch.gradle.tasks.download.Download>("downloadGodotAar") {
127+
val destFile = file("${project.rootDir}/libs/${project.extra["godotAarFile"]}")
128+
124129
src(project.extra["godotAarUrl"] as String)
125-
dest(file("${project.rootDir}/libs/${project.extra["godotAarFile"]}"))
130+
dest(destFile)
126131
overwrite(false)
132+
133+
onlyIf {
134+
val exists = destFile.exists() && destFile.length() > 0
135+
if (exists) {
136+
println("[DEBUG] File already exists and is non-empty: ${destFile.absolutePath} (${destFile.length()} bytes)")
137+
println("[DEBUG] Skipping download.")
138+
} else {
139+
if (destFile.exists()) {
140+
println("[DEBUG] File exists but is empty: ${destFile.absolutePath}")
141+
} else {
142+
println("[DEBUG] File not found: ${destFile.absolutePath}")
143+
}
144+
println("[DEBUG] Proceeding with download...")
145+
}
146+
!exists // run task only if file does NOT exist or is empty
147+
}
127148
}
128149

129150
named("preBuild") {

0 commit comments

Comments
 (0)