Skip to content

Commit

Permalink
Release 1.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Str4tos committed Jan 27, 2021
1 parent 0cfbfd4 commit 58a9a8a
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 113 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Clever Ads Solutions Unity Plugin Change Log

## [1.9.6] - 2021-01-27
### Dependencies
- [Android] Wraps [1.9.6 SDK](https://github.com/cleveradssolutions/CAS-Android/releases)
- [iOS] Wraps [1.9.6 SDK](https://github.com/cleveradssolutions/CAS-iOS/releases)
### Features
- [CrossPromotion] Added support for new functionality to override ad destination link using a web page. In the future, we will detail these possibilities when we have everything ready.
- [CrossPromotion] Added a new meta flag `CAS.MediationExtras.crossPromoEndless` to disable endless display ad.
- [MyTarget] Added a new meta flags `CAS.MediationExtras.myTargetGDPRConsent` and `CAS.MediationExtras.myTargetCCPAOptedOut` to override GDPR and CCPA status.
- [Yandex Ads] Added a new meta flags `CAS.MediationExtras.yandexAdsGDPRConsent` to override GDPR status.
- [Editor] Implemented `CAS.MobileAds.GetActiveNetworks()` in Editor to get list of active network dependencies.
### Bug Fixes
- [Editor] Fix renderer progress bar of check for updates on open `Assets > CleverAdsSolutions > Settings` window.

## [1.9.5] - 2021-01-25
### Dependencies
- [Android] Wraps [1.9.5 SDK](https://github.com/cleveradssolutions/CAS-Android/releases)
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 102 additions & 35 deletions Editor/CASEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ public static class CASEditorUtils
public const string launcherGradlePath = "Assets/Plugins/Android/launcherTemplate.gradle";
public const string projectGradlePath = "Assets/Plugins/Android/baseProjectTemplate.gradle";
public const string packageManifestPath = "Packages/manifest.json";

public const string gitRootURL = "https://github.com/cleveradssolutions/";
public const string websiteURL = "https://cleveradssolutions.com";
#endregion

#region Internal Constants
internal const string gitRootURL = "https://github.com/cleveradssolutions/";
internal const string gitUnityRepo = "CAS-Unity";
internal const string gitUnityRepoURL = gitRootURL + gitUnityRepo;
internal const string supportURL = gitUnityRepoURL + "#support";
internal const string configuringPrivacyURL = gitUnityRepoURL + "#include-ios";
internal const string websiteURL = "https://cleveradssolutions.com";

internal const string generalDeprecateDependency = "General";
internal const string teenDeprecateDependency = "Teen";
Expand Down Expand Up @@ -172,6 +173,90 @@ public static bool TryResolveAndroidDependencies( bool force = true )
}
return success;
}

public static string GetNewVersionOrNull( string repo, string currVersion, bool force )
{
try
{
var newVerStr = GetLatestVersion( repo, force, currVersion );
if (newVerStr != null && newVerStr != currVersion)
{
var currVer = new System.Version( currVersion );
var newVer = new System.Version( newVerStr );
if (currVer < newVer)
return newVerStr;
}
}
catch (Exception e)
{
Debug.LogException( e );
}
return null;
}

public static bool IsPackageExist( string package )
{
return File.Exists( packageManifestPath ) &&
File.ReadAllText( packageManifestPath ).Contains( package );
}

public static void LinksToolbarGUI( string gitRepoName )
{
EditorGUILayout.BeginHorizontal( EditorStyles.toolbar );
if (GUILayout.Button( "Support", EditorStyles.toolbarButton, GUILayout.ExpandWidth( false ) ))
Application.OpenURL( gitRootURL + gitRepoName + "#support" );
if (GUILayout.Button( "GitHub", EditorStyles.toolbarButton, GUILayout.ExpandWidth( false ) ))
Application.OpenURL( gitRootURL + gitRepoName );
if (GUILayout.Button( "CleverAdsSolutions.com", EditorStyles.toolbarButton ))
Application.OpenURL( websiteURL );
EditorGUILayout.EndHorizontal();
}

public static void AboutRepoGUI( string gitRepoName, bool allowedPackageUpdate, string currVersion, ref string newCASVersion )
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label( gitRepoName + " version: " + currVersion );
if (GUILayout.Button( "Check for Updates", EditorStyles.miniButton, GUILayout.ExpandWidth( false ) ))
{
newCASVersion = GetNewVersionOrNull( gitRepoName, currVersion, true );
string message = string.IsNullOrEmpty( newCASVersion ) ? "You are using the latest version."
: "There is a new version " + newCASVersion + " of the " + gitRepoName + " available for update.";
EditorUtility.DisplayDialog( "Check for Updates", message, "OK" );
}
EditorGUILayout.EndHorizontal();
if (!string.IsNullOrEmpty( newCASVersion ))
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox( "There is a new version " + newCASVersion + " of the " + gitRepoName + " available for update.", MessageType.Warning );
var layoutParams = new[] { GUILayout.Height( 38 ), GUILayout.ExpandWidth( false ) };
#if UNITY_2018_4_OR_NEWER
if (allowedPackageUpdate && GUILayout.Button( "Update", layoutParams ))
{
var request = UnityEditor.PackageManager.Client.Add( gitRootURL + gitRepoName + ".git#" + newCASVersion );
try
{
while (!request.IsCompleted)
{
if (EditorUtility.DisplayCancelableProgressBar(
"Update Package Manager dependency", gitRepoName + " " + newCASVersion, 0.5f ))
break;
}
if (request.Status == UnityEditor.PackageManager.StatusCode.Success)
Debug.Log( "Package Manager: Update " + request.Result.displayName );
else if (request.Status >= UnityEditor.PackageManager.StatusCode.Failure)
Debug.LogError( request.Error.message );
}
finally
{
EditorUtility.ClearProgressBar();
}
}
#endif
if (GUILayout.Button( "Releases", layoutParams ))
Application.OpenURL( gitRootURL + gitRepoName + "/releases" );
EditorGUILayout.EndHorizontal();
}
}
#endregion

#region Internal API
Expand All @@ -183,12 +268,6 @@ internal static bool IsFirebaseServiceExist( string service )
return IsPackageExist( "com.google.firebase." + service );
}

internal static bool IsPackageExist( string package )
{
return File.Exists( packageManifestPath ) &&
File.ReadAllText( packageManifestPath ).Contains( package );
}

internal static void OpenSettingsWindow( BuildTarget target )
{
var asset = GetSettingsAsset( target );
Expand Down Expand Up @@ -447,26 +526,6 @@ private static void WriteSettingsForPlatform( string content, BuildTarget target
WriteToFile( content, iosResSettingsPath );
}

internal static string GetNewVersionOrNull( string repo, string currVersion, bool force )
{
try
{
var newVerStr = GetLatestVersion( repo, force );
if (newVerStr != null && newVerStr != currVersion)
{
var currVer = new System.Version( currVersion );
var newVer = new System.Version( newVerStr );
if (currVer < newVer)
return newVerStr;
}
}
catch (Exception e)
{
Debug.LogException( e );
}
return null;
}

internal static HashSet<string> GetCrossPromoAlias( BuildTarget platform )
{
var result = new HashSet<string>();
Expand Down Expand Up @@ -498,11 +557,11 @@ internal static HashSet<string> GetCrossPromoAlias( BuildTarget platform )
return result;
}

internal static string GetLatestVersion( string repo, bool force )
internal static string GetLatestVersion( string repo, bool force, string currVersion )
{
if (!force && !HasTimePassed( editorLatestVersionTimestampPrefs + repo, 1, false ))
{
var last = PlayerPrefs.GetString( editorLatestVersionPrefs + repo );
var last = EditorPrefs.GetString( editorLatestVersionPrefs + repo );
if (!string.IsNullOrEmpty( last ))
return last;
}
Expand All @@ -522,6 +581,7 @@ internal static string GetLatestVersion( string repo, bool force )
Mathf.Repeat( ( float )EditorApplication.timeSinceStartup, 1.0f ) ))
{
loader.Dispose();
SaveLatestRepoVersion( repo, currVersion );
return null;
}
}
Expand All @@ -536,21 +596,28 @@ internal static string GetLatestVersion( string repo, bool force )
var content = loader.downloadHandler.text;
var versionInfo = JsonUtility.FromJson<GitVersionInfo>( content );
if (!string.IsNullOrEmpty( versionInfo.tag_name ))
{
PlayerPrefs.SetString( editorLatestVersionPrefs + repo, versionInfo.tag_name );
EditorPrefs.SetString( editorLatestVersionTimestampPrefs + repo, DateTime.Now.ToBinary().ToString() );
}
SaveLatestRepoVersion( repo, versionInfo.tag_name );

return versionInfo.tag_name;
}
else
{
Debug.LogError( logTag + "Response " + loader.responseCode + ": " + loader.error );
Debug.LogError( logTag + "Check " + repo + " updates failed. Response " +
loader.responseCode + ": " + loader.error );
SaveLatestRepoVersion( repo, currVersion );
}

}

return null;
}

private static void SaveLatestRepoVersion( string repo, string version )
{
EditorPrefs.SetString( editorLatestVersionPrefs + repo, version );
EditorPrefs.SetString( editorLatestVersionTimestampPrefs + repo, DateTime.Now.ToBinary().ToString() );
}

internal static bool HasTimePassed( string prefKey, int days, bool projectOnly )
{
string pref;
Expand Down
69 changes: 6 additions & 63 deletions Editor/CASInitSettignsInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class CASInitSettignsInspector : Editor
private ReorderableList managerIdsList;
private BuildTarget platform;
private bool allowedPackageUpdate;
private string newCASVersion;
private string newCASVersion = null;
private bool deprecateDependenciesExist;
//private bool usingMultidexOnBuild;

Expand Down Expand Up @@ -70,10 +70,12 @@ private void OnEnable()
};

allowedPackageUpdate = Utils.IsPackageExist( Utils.packageName );
newCASVersion = Utils.GetNewVersionOrNull( Utils.gitUnityRepo, MobileAds.wrapperVersion, false );

//usingMultidexOnBuild = PlayerPrefs.GetInt( Utils.editorIgnoreMultidexPrefs, 0 ) == 0;

dependencyManager = DependencyManager.Create( platform, ( Audience )audienceTaggedProp.enumValueIndex, true );

EditorApplication.delayCall += () => newCASVersion = Utils.GetNewVersionOrNull( Utils.gitUnityRepo, MobileAds.wrapperVersion, false );
}

private void DrawListHeader( Rect rect )
Expand All @@ -94,7 +96,7 @@ public override void OnInspectorGUI()
var obj = serializedObject;
obj.UpdateIfRequiredOrScript();

LinksToolbarGUI();
Utils.LinksToolbarGUI( Utils.gitUnityRepo );

HelpStyles.BeginBoxScope();
EditorGUILayout.PropertyField( testAdModeProp );
Expand Down Expand Up @@ -137,7 +139,7 @@ public override void OnInspectorGUI()

DrawSeparator();
DeprecatedDependenciesGUI();
OnCASAboutGUI();
Utils.AboutRepoGUI( Utils.gitUnityRepo, allowedPackageUpdate, MobileAds.wrapperVersion, ref newCASVersion );

if (dependencyManager == null)
{
Expand Down Expand Up @@ -275,65 +277,6 @@ private void OnEditroRuntimeActiveAdGUI()
}
}

private void OnCASAboutGUI()
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label( "CAS Unity wrapper version: " + MobileAds.wrapperVersion );
if (GUILayout.Button( "Check for Updates", EditorStyles.miniButton, GUILayout.ExpandWidth( false ) ))
{
newCASVersion = Utils.GetNewVersionOrNull( Utils.gitUnityRepo, MobileAds.wrapperVersion, true );
string message = string.IsNullOrEmpty( newCASVersion ) ? "You are using the latest version."
: "There is a new version " + newCASVersion + " of the CAS Unity available for update.";
EditorUtility.DisplayDialog( "Check for Updates", message, "OK" );
}
EditorGUILayout.EndHorizontal();
if (!string.IsNullOrEmpty( newCASVersion ))
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox( "There is a new version " + newCASVersion + " of the CAS Unity available for update.", MessageType.Warning );
var layoutParams = new[] { GUILayout.Height( 38 ), GUILayout.ExpandWidth( false ) };
#if UNITY_2018_4_OR_NEWER
if (allowedPackageUpdate && GUILayout.Button( "Update", layoutParams ))
{
var request = UnityEditor.PackageManager.Client.Add( Utils.gitUnityRepoURL + ".git#" + newCASVersion );
try
{
while (!request.IsCompleted)
{
if (EditorUtility.DisplayCancelableProgressBar(
"Update Package Manager dependency", "Clever Ads Solutions " + newCASVersion, 0.5f ))
break;
}
if (request.Status == UnityEditor.PackageManager.StatusCode.Success)
Debug.Log( "Package Manager: Update " + request.Result.displayName );
else if (request.Status >= UnityEditor.PackageManager.StatusCode.Failure)
Debug.LogError( request.Error.message );
}
finally
{
EditorUtility.ClearProgressBar();
}
}
#endif
if (GUILayout.Button( "Releases", layoutParams ))
Application.OpenURL( Utils.gitUnityRepoURL + "/releases" );
EditorGUILayout.EndHorizontal();
}

}

private void LinksToolbarGUI()
{
EditorGUILayout.BeginHorizontal( EditorStyles.toolbar );
if (GUILayout.Button( "Support", EditorStyles.toolbarButton, GUILayout.ExpandWidth( false ) ))
Application.OpenURL( Utils.supportURL );
if (GUILayout.Button( "GitHub", EditorStyles.toolbarButton, GUILayout.ExpandWidth( false ) ))
Application.OpenURL( Utils.gitUnityRepoURL );
if (GUILayout.Button( "CleverAdsSolutions.com", EditorStyles.toolbarButton ))
Application.OpenURL( Utils.websiteURL );
EditorGUILayout.EndHorizontal();
}

private void DeprecatedDependenciesGUI()
{
if (deprecateDependenciesExist)
Expand Down
4 changes: 0 additions & 4 deletions Editor/CASInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public partial class DependencyManager

internal bool installedAny;

private bool firebaseDeepLinksExist;

private static bool solutionsFoldout = true;
private static bool advancedFoldout;
private static bool otherFoldout;
Expand Down Expand Up @@ -149,8 +147,6 @@ internal void Init( BuildTarget platform, bool deepInit = true )
}
}
}

firebaseDeepLinksExist = Utils.IsFirebaseServiceExist( "dynamic" );
}

private void OnHeaderGUI()
Expand Down
19 changes: 18 additions & 1 deletion Editor/DependencyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ public static DependencyManager Create( Dependency[] simple, Dependency[] advanc
};
}

// Reflection target
public static string GetActiveMediationPattern()
{
var target = Create( EditorUserBuildSettings.activeBuildTarget, Audience.Mixed, true );
if (target == null)
return "";

var networks = Enum.GetValues( typeof( AdNetwork ) );
var result = new char[networks.Length];
for (int i = 0; i < networks.Length; i++)
{
var dependency = target.Find( ( ( AdNetwork )networks.GetValue( i ) ).ToString() );
result[i] = ( dependency != null && dependency.isInstalled() ) ? '1' : '0';
}
return new string( result );
}

public Dependency Find( string name )
{
for (int i = 0; i < simple.Length; i++)
Expand All @@ -63,7 +80,7 @@ public Dependency FindCrossPromotion()
}
}



[Serializable]
public partial class Dependency
Expand Down
2 changes: 2 additions & 0 deletions LICENSE.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58a9a8a

Please sign in to comment.