-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Syncing changes from private repository
- Loading branch information
1 parent
9e37b01
commit d19177f
Showing
32 changed files
with
537 additions
and
161 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package> | ||
<metadata> | ||
<id>Chartboost.CSharp.Core.Unity.Consent.Usercentrics</id> | ||
<version>1.0.0</version> | ||
<title>Chartboost Core Consent Usercentrics</title> | ||
<description>Usercentrics CMP adapter for mediating through Chartboost Core.</description> | ||
<authors>Chartboost</authors> | ||
<owners>Chartboost</owners> | ||
<license type="file">LICENSE.md</license> | ||
<readme>README.md</readme> | ||
<projectUrl>https://www.chartboost.com</projectUrl> | ||
<copyright>Copyright 2024</copyright> | ||
<tags>Chartboost, Consent, Usercentrics, Core, Unity, cs</tags> | ||
<repository type="git" url="https://github.com/ChartBoost/chartboost-core-unity-consent-adapter-usercentrics"/> | ||
<dependencies> | ||
<dependency id="Chartboost.CSharp.Core.Unity" version="1.0.0" /> | ||
<dependency id="Chartboost.CSharp.Utilities.Unity" version="1.0.1" /> | ||
<dependency id="Chartboost.CSharp.Logging.Unity" version="1.0.0" /> | ||
</dependencies> | ||
</metadata> | ||
</package> |
7 changes: 7 additions & 0 deletions
7
Chartboost.CSharp.Core.Unity.Consent.Usercentrics.nuspec.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
...boost.consent.usercentrics.android.asmdef → ....Core.Consent.Usercentrics.Android.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,124 @@ | ||
using System.Collections.Generic; | ||
using Chartboost.Core.Android.Modules; | ||
using Chartboost.Core.Android.Utilities; | ||
using Chartboost.Logging; | ||
using UnityEngine; | ||
using UnityEngine.Scripting; | ||
|
||
namespace Chartboost.Core.Usercentrics.Android | ||
{ | ||
internal class UsercentricsAdapter : NativeModule | ||
internal sealed class UsercentricsAdapter : NativeModule | ||
{ | ||
private const string Tag = nameof(UsercentricsAdapter); | ||
private const string UsercentricsNamespace = "com.usercentrics.sdk"; | ||
// ReSharper disable InconsistentNaming | ||
private const string ClassUsercentricsAdapter = "com.chartboost.core.consent.usercentrics.UsercentricsAdapter"; | ||
private const string ClassUsercentricsOptions = "com.usercentrics.sdk.UsercentricsOptions"; | ||
|
||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | ||
private static readonly string ClassUsercentricsOptions = $"{UsercentricsNamespace}.UsercentricsOptions"; | ||
|
||
private const string FunctionSetRulesetId = "setRuleSetId"; | ||
private const string FunctionSetSettingsId = "setSettingsId"; | ||
private const string FunctionSetDefaultLanguage = "setDefaultLanguage"; | ||
private const string FunctionSetVersion = "setVersion"; | ||
private const string FunctionSetTimeoutMillis = "setTimeoutMillis"; | ||
private const string FunctionSetConsentMediation = "setConsentMediation"; | ||
|
||
private const string CommonNamespace = "models.common"; | ||
private static readonly string EnumUsercentricsLoggerLevel = $"{UsercentricsNamespace}.{CommonNamespace}.UsercentricsLoggerLevel"; | ||
private const string UsercentricsLoggerLevelNone = "NONE"; | ||
private const string UsercentricsLoggerLevelError = "ERROR"; | ||
private const string UsercentricsLoggerLevelWarning = "WARNING"; | ||
private const string UsercentricsLoggerLevelDebug = "DEBUG"; | ||
private const string FunctionSetLoggerLevel = "setLoggerLevel"; | ||
|
||
private static readonly string EnumUsercentricsNetworkMode = $"{UsercentricsNamespace}.{CommonNamespace}.NetworkMode"; | ||
private const string UsercentricsNetworkModeWorld = "WORLD"; | ||
private const string UsercentricsNetworkModeEU = "EU"; | ||
private const string FunctionSetNetworkMode = "setNetworkMode"; | ||
// ReSharper restore InconsistentNaming | ||
|
||
|
||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
private static void SetInstance() | ||
{ | ||
if (Application.isEditor) | ||
return; | ||
|
||
Usercentrics.UsercentricsAdapter.InstanceType = typeof(UsercentricsAdapter); | ||
} | ||
|
||
[Preserve] | ||
public UsercentricsAdapter(UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId) : base(CreateInstance(options, templateIdToPartnerId)) { } | ||
|
||
|
||
[Preserve] | ||
public UsercentricsAdapter(string dpsName, UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId) : base(CreateInstance(dpsName, options, templateIdToPartnerId)) { } | ||
|
||
private static AndroidJavaObject CreateInstance(UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId) | ||
{ | ||
var usercentricsOptions = new AndroidJavaObject(ClassUsercentricsOptions, options.SettingsId); | ||
return new AndroidJavaObject(ClassUsercentricsAdapter, usercentricsOptions, templateIdToPartnerId.DictionaryToMap()); | ||
} | ||
public UsercentricsAdapter(UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId = null) : base(CreateInstance(options, templateIdToPartnerId)) { } | ||
|
||
private static AndroidJavaObject CreateInstance(string dpsName, UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId) | ||
private static AndroidJavaObject CreateInstance(UsercentricsOptions options, IDictionary<string, string> templateIdToPartnerId = null) | ||
{ | ||
var usercentricsOptions = new AndroidJavaObject(ClassUsercentricsOptions, options.SettingsId); | ||
return new AndroidJavaObject(ClassUsercentricsAdapter, usercentricsOptions, templateIdToPartnerId.DictionaryToMap(), dpsName); | ||
var nativeOptions = new AndroidJavaObject(ClassUsercentricsOptions); | ||
|
||
if (!string.IsNullOrEmpty(options.RulesetId)) | ||
{ | ||
nativeOptions.Call(FunctionSetRulesetId, options.RulesetId);; | ||
LogController.Log($"{Tag} Setting RulesetID: {options.RulesetId}, SettingsId will be ignored", LogLevel.Verbose); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(options.SettingsId) && string.IsNullOrEmpty(options.RulesetId)) | ||
{ | ||
nativeOptions.Call(FunctionSetSettingsId, options.SettingsId); | ||
LogController.Log($"{Tag} Setting SettingsId: {options.SettingsId}", LogLevel.Verbose); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(options.DefaultLanguage)) | ||
{ | ||
nativeOptions.Call(FunctionSetDefaultLanguage, options.DefaultLanguage); | ||
LogController.Log($"{Tag} Setting DefaultLanguage: {options.DefaultLanguage}", LogLevel.Verbose); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(options.Version)) | ||
{ | ||
nativeOptions.Call(FunctionSetVersion, options.Version); | ||
LogController.Log($"{Tag} Setting Version: {options.Version}", LogLevel.Verbose); | ||
} | ||
|
||
if (options.TimeoutMilliseconds.HasValue) | ||
{ | ||
nativeOptions.Call(FunctionSetTimeoutMillis, options.TimeoutMilliseconds.Value); | ||
LogController.Log($"{Tag} Setting TimeoutMilliseconds: {options.TimeoutMilliseconds}", LogLevel.Verbose); | ||
} | ||
|
||
if (options.ConsentMediation.HasValue) | ||
{ | ||
nativeOptions.Call(FunctionSetConsentMediation, options.ConsentMediation.Value); | ||
LogController.Log($"{Tag} Setting ConsentMediation: {options.ConsentMediation}", LogLevel.Verbose); | ||
} | ||
|
||
if (options.LoggerLevel.HasValue) | ||
{ | ||
using var enumClass = new AndroidJavaClass(EnumUsercentricsLoggerLevel); | ||
using var value = options.LoggerLevel.Value switch | ||
{ | ||
UsercentricsLoggerLevel.None => enumClass.GetStatic<AndroidJavaObject>(UsercentricsLoggerLevelNone), | ||
UsercentricsLoggerLevel.Error => enumClass.GetStatic<AndroidJavaObject>(UsercentricsLoggerLevelError), | ||
UsercentricsLoggerLevel.Warning => enumClass.GetStatic<AndroidJavaObject>(UsercentricsLoggerLevelWarning), | ||
UsercentricsLoggerLevel.Debug => enumClass.GetStatic<AndroidJavaObject>(UsercentricsLoggerLevelDebug), | ||
_ => enumClass.GetStatic<AndroidJavaObject>(UsercentricsLoggerLevelNone), | ||
}; | ||
|
||
nativeOptions.Call(FunctionSetLoggerLevel, value); | ||
LogController.Log($"{Tag} Setting LoggerLevel: {options.LoggerLevel}", LogLevel.Verbose); | ||
} | ||
|
||
if (options.NetworkMode.HasValue) | ||
{ | ||
using var enumClass = new AndroidJavaClass(EnumUsercentricsNetworkMode); | ||
using var value = options.NetworkMode.Value switch | ||
{ | ||
NetworkMode.World => enumClass.GetStatic<AndroidJavaObject>(UsercentricsNetworkModeWorld), | ||
NetworkMode.EU => enumClass.GetStatic<AndroidJavaObject>(UsercentricsNetworkModeEU), | ||
_ => enumClass.GetStatic<AndroidJavaObject>(UsercentricsNetworkModeWorld), | ||
}; | ||
|
||
nativeOptions.Call(FunctionSetNetworkMode, value); | ||
LogController.Log($"{Tag} Setting LoggerLevel: {options.NetworkMode}", LogLevel.Verbose); | ||
} | ||
|
||
return new AndroidJavaObject(ClassUsercentricsAdapter, nativeOptions, templateIdToPartnerId.DictionaryToMap()); | ||
} | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...om.chartboost.consent.usercentrics.asmdef → ...artboost.Core.Consent.Usercentrics.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Chartboost.Core.Usercentrics | ||
{ | ||
public enum NetworkMode | ||
{ | ||
World = 0, | ||
EU = 1 | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.