com.taptap.sdk.leaderboard 4.10.2 → 4.10.3-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,12 @@
4
4
  <repositories>
5
5
  <repository>https://repo.maven.apache.org/maven2</repository>
6
6
  </repositories>
7
- <androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.10.2" />
7
+ <androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.10.3-beta.3" />
8
8
  </androidPackages>
9
9
  <iosPods>
10
10
  <sources>
11
11
  <source>https://github.com/CocoaPods/Specs.git</source>
12
12
  </sources>
13
- <iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapSDK/Leaderboard" version="4.10.2" />
13
+ <iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapSDK/Leaderboard" version="4.10.3-beta.3" />
14
14
  </iosPods>
15
15
  </dependencies>
@@ -0,0 +1,225 @@
1
+ using System.IO;
2
+ using System.Xml;
3
+ using UnityEditor.Android;
4
+ using UnityEngine;
5
+
6
+ namespace TapSDK.Leaderboard.Mobile.Editor
7
+ {
8
+ /// <summary>
9
+ /// 为 Leaderboard 分享能力自动补充 Android FileProvider 配置。
10
+ /// </summary>
11
+ public class TapLeaderboardAndroidPostGenerateGradleProject : IPostGenerateGradleAndroidProject
12
+ {
13
+ private const string AndroidNamespaceUri = "http://schemas.android.com/apk/res/android";
14
+ private const string FileProviderClassName = "com.taptap.sdk.leaderboard.androidx.provider.TapLeaderboardFileProvider";
15
+ private const string FileProviderAuthorities = "${applicationId}.tapsdk.leaderboard.fileprovider";
16
+ private const string FileProviderPathsMetaName = "android.support.FILE_PROVIDER_PATHS";
17
+ private const string FileProviderPathsResource = "@xml/tap_leaderboard_file_paths";
18
+ private const string FilePathsFileName = "tap_leaderboard_file_paths.xml";
19
+ private const string DefaultSharedImagesPathName = "shared_images";
20
+ private const string SharedImagesRelativePath = "shared_images/";
21
+
22
+ public int callbackOrder => 0;
23
+
24
+ public void OnPostGenerateGradleAndroidProject(string path)
25
+ {
26
+ string manifestPath = GetLauncherManifestPath(path);
27
+ if (string.IsNullOrEmpty(manifestPath) || !File.Exists(manifestPath))
28
+ {
29
+ Debug.LogWarning($"[TapSDK][Leaderboard] AndroidManifest.xml not found under: {path}");
30
+ return;
31
+ }
32
+
33
+ string resXmlDirectory = Path.Combine(Path.GetDirectoryName(manifestPath) ?? string.Empty, "res", "xml");
34
+ EnsureFileProvider(manifestPath);
35
+ EnsureFilePathsXml(resXmlDirectory);
36
+ }
37
+
38
+ private static string GetLauncherManifestPath(string exportPath)
39
+ {
40
+ string[] candidates =
41
+ {
42
+ Path.Combine(exportPath, "launcher", "src", "main", "AndroidManifest.xml"),
43
+ Path.Combine(exportPath, "src", "main", "AndroidManifest.xml")
44
+ };
45
+
46
+ foreach (string candidate in candidates)
47
+ {
48
+ if (File.Exists(candidate))
49
+ {
50
+ return candidate;
51
+ }
52
+ }
53
+
54
+ return null;
55
+ }
56
+
57
+ private static void EnsureFilePathsXml(string resXmlDirectory)
58
+ {
59
+ Directory.CreateDirectory(resXmlDirectory);
60
+ string filePathsPath = Path.Combine(resXmlDirectory, FilePathsFileName);
61
+
62
+ if (!File.Exists(filePathsPath))
63
+ {
64
+ File.WriteAllText(filePathsPath, CreateFilePathsContent());
65
+ return;
66
+ }
67
+
68
+ var document = new XmlDocument();
69
+ document.Load(filePathsPath);
70
+
71
+ XmlElement pathsElement = document.DocumentElement;
72
+ if (pathsElement == null || pathsElement.Name != "paths")
73
+ {
74
+ File.WriteAllText(filePathsPath, CreateFilePathsContent());
75
+ return;
76
+ }
77
+
78
+ if (HasSharedImagesPath(pathsElement))
79
+ {
80
+ return;
81
+ }
82
+
83
+ XmlElement filesPathElement = document.CreateElement("files-path");
84
+ filesPathElement.SetAttribute("name", DefaultSharedImagesPathName);
85
+ filesPathElement.SetAttribute("path", SharedImagesRelativePath);
86
+ pathsElement.AppendChild(filesPathElement);
87
+ SaveXml(document, filePathsPath);
88
+ }
89
+
90
+ private static string CreateFilePathsContent()
91
+ {
92
+ return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
93
+ "<paths>\n" +
94
+ " <!-- Allow leaderboard share images stored in files/shared_images/. -->\n" +
95
+ " <files-path name=\"" + DefaultSharedImagesPathName + "\" path=\"" + SharedImagesRelativePath + "\" />\n" +
96
+ "</paths>\n";
97
+ }
98
+
99
+ private static bool HasSharedImagesPath(XmlElement pathsElement)
100
+ {
101
+ foreach (XmlNode child in pathsElement.ChildNodes)
102
+ {
103
+ XmlElement element = child as XmlElement;
104
+ if (element == null || element.Name != "files-path")
105
+ {
106
+ continue;
107
+ }
108
+
109
+ if (element.GetAttribute("path") == SharedImagesRelativePath)
110
+ {
111
+ return true;
112
+ }
113
+ }
114
+
115
+ return false;
116
+ }
117
+
118
+ private static void EnsureFileProvider(string manifestPath)
119
+ {
120
+ var document = new XmlDocument();
121
+ document.Load(manifestPath);
122
+
123
+ XmlElement manifestElement = document.DocumentElement;
124
+ XmlNode applicationNode = manifestElement != null ? manifestElement.SelectSingleNode("application") : null;
125
+ XmlElement applicationElement = applicationNode as XmlElement;
126
+ if (applicationElement == null)
127
+ {
128
+ Debug.LogWarning($"[TapSDK][Leaderboard] <application> node not found in manifest: {manifestPath}");
129
+ return;
130
+ }
131
+
132
+ XmlElement providerElement = FindFileProvider(applicationElement);
133
+ bool manifestChanged = false;
134
+ if (providerElement == null)
135
+ {
136
+ providerElement = document.CreateElement("provider");
137
+ providerElement.SetAttribute("name", AndroidNamespaceUri, FileProviderClassName);
138
+ providerElement.SetAttribute("authorities", AndroidNamespaceUri, FileProviderAuthorities);
139
+ providerElement.SetAttribute("exported", AndroidNamespaceUri, "false");
140
+ providerElement.SetAttribute("grantUriPermissions", AndroidNamespaceUri, "true");
141
+ applicationElement.AppendChild(providerElement);
142
+ manifestChanged = true;
143
+ }
144
+
145
+ if (EnsureFileProviderMetaData(document, providerElement))
146
+ {
147
+ manifestChanged = true;
148
+ }
149
+
150
+ if (manifestChanged)
151
+ {
152
+ SaveXml(document, manifestPath);
153
+ }
154
+ }
155
+
156
+ private static XmlElement FindFileProvider(XmlElement applicationElement)
157
+ {
158
+ foreach (XmlNode child in applicationElement.ChildNodes)
159
+ {
160
+ XmlElement element = child as XmlElement;
161
+ if (element == null || element.Name != "provider")
162
+ {
163
+ continue;
164
+ }
165
+
166
+ string authorities = element.GetAttribute("authorities", AndroidNamespaceUri);
167
+ if (authorities == FileProviderAuthorities)
168
+ {
169
+ return element;
170
+ }
171
+ }
172
+
173
+ return null;
174
+ }
175
+
176
+ private static bool EnsureFileProviderMetaData(XmlDocument document, XmlElement providerElement)
177
+ {
178
+ foreach (XmlNode child in providerElement.ChildNodes)
179
+ {
180
+ XmlElement element = child as XmlElement;
181
+ if (element == null || element.Name != "meta-data")
182
+ {
183
+ continue;
184
+ }
185
+
186
+ string metaName = element.GetAttribute("name", AndroidNamespaceUri);
187
+ if (metaName != FileProviderPathsMetaName)
188
+ {
189
+ continue;
190
+ }
191
+
192
+ string filePathsResource = element.GetAttribute("resource", AndroidNamespaceUri);
193
+ if (filePathsResource != FileProviderPathsResource)
194
+ {
195
+ element.SetAttribute("resource", AndroidNamespaceUri, FileProviderPathsResource);
196
+ return true;
197
+ }
198
+
199
+ return false;
200
+ }
201
+
202
+ XmlElement metaDataElement = document.CreateElement("meta-data");
203
+ metaDataElement.SetAttribute("name", AndroidNamespaceUri, FileProviderPathsMetaName);
204
+ metaDataElement.SetAttribute("resource", AndroidNamespaceUri, FileProviderPathsResource);
205
+ providerElement.AppendChild(metaDataElement);
206
+ return true;
207
+ }
208
+
209
+ private static void SaveXml(XmlDocument document, string path)
210
+ {
211
+ var settings = new XmlWriterSettings
212
+ {
213
+ Indent = true,
214
+ IndentChars = " ",
215
+ NewLineChars = "\n",
216
+ NewLineHandling = NewLineHandling.Replace
217
+ };
218
+
219
+ using (XmlWriter writer = XmlWriter.Create(path, settings))
220
+ {
221
+ document.Save(writer);
222
+ }
223
+ }
224
+ }
225
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 96aaf13ea6b94d4790d9d2f99e4b6b2c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -13,7 +13,7 @@ namespace TapSDK.Leaderboard
13
13
  /// <summary>
14
14
  /// SDK版本号
15
15
  /// </summary>
16
- public static readonly string Version = "4.10.2";
16
+ public static readonly string Version = "4.10.3-beta.3";
17
17
 
18
18
  /// <summary>
19
19
  /// 打开排行榜页面
package/package.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "com.taptap.sdk.leaderboard",
3
3
  "displayName": "TapTapSDK Leaderboard",
4
4
  "description": "TapTapSDK Leaderboard",
5
- "version": "4.10.2",
6
- "unity": "2019.4",
5
+ "version": "4.10.3-beta.3",
6
+ "unity": "2020.3.0f1",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.taptap.sdk.core": "4.10.2",
10
- "com.taptap.sdk.login": "4.10.2"
9
+ "com.taptap.sdk.core": "4.10.3-beta.3",
10
+ "com.taptap.sdk.login": "4.10.3-beta.3"
11
11
  }
12
12
  }