private void SetAdapterInformationForImport(NetworkDependency latestDependency, PlatformSdk platformSdk)
        {
            switch (platformSdk)
            {
            case PlatformSdk.Android:
                if (latestDependency.android_info != null)
                {
                    SetAdapterImportInfo(latestDependency.name, AppodealDependencyUtils.EmptyCurrentVersion,
                                         latestDependency.android_info.version, latestDependency.android_info.unity_content);
                }

                break;

            case PlatformSdk.iOS:
                if (latestDependency.ios_info != null)
                {
                    SetAdapterImportInfo(latestDependency.name, AppodealDependencyUtils.EmptyCurrentVersion,
                                         latestDependency.ios_info.version, latestDependency.ios_info.unity_content);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(platformSdk), platformSdk, null);
            }
        }
Exemple #2
0
        public static NetworkDependency GetAppodealDependency(
            Dictionary <string, NetworkDependency> networkDependencies)
        {
            NetworkDependency networkDependency = null;

            foreach (var dependency
                     in networkDependencies.Where(dependency
                                                  => dependency.Key.Contains(Appodeal))
                     .Where(dependency => dependency.Value != null))
            {
                networkDependency = dependency.Value;
            }

            return(networkDependency);
        }
        private void GetInternalDependencies(string dependencyPath)
        {
            var networkDependency = new NetworkDependency
            {
                name = AppodealDependencyUtils.GetConfigName(dependencyPath)
            };

            #region iOSInternalDependencies

            var    sourcesiOS   = new List <string>();
            string podName      = null;
            string version      = null;
            string minTargetSdk = null;

            XmlUtilities.ParseXmlTextFileElements(dependencyPath,
                                                  (reader, elementName, isStart, parentElementName, elementNameStack) =>
            {
                if (elementName == "dependencies" &&
                    parentElementName == "" || elementName == "iosPods" &&
                    (parentElementName == "dependencies" || parentElementName == ""))
                {
                    return(true);
                }

                if (elementName == "iosPod" && parentElementName == "iosPods")
                {
                    if (isStart)
                    {
                        podName      = reader.GetAttribute("name");
                        version      = reader.GetAttribute("version");
                        minTargetSdk = reader.GetAttribute("minTargetSdk");

                        sourcesiOS = new List <string>();
                        if (podName == null)
                        {
                            Debug.Log(
                                $"Pod name not specified while reading {dependencyPath}:{reader.LineNumber}\n");
                            return(false);
                        }
                    }
                    else
                    {
                        if (podName != null && version != null && minTargetSdk != null)
                        {
                            if (!podName.Contains(AppodealDependencyUtils.APDAppodealAdExchangeAdapter))
                            {
                                networkDependency.ios_info = new NetworkDependency.iOSDependency(podName,
                                                                                                 version,
                                                                                                 AppodealDependencyUtils.GetiOSContent(dependencyPath));
                            }
                        }
                    }

                    return(true);
                }

                if (elementName == "sources" && parentElementName == "iosPod")
                {
                    return(true);
                }
                if (elementName == "sources" && parentElementName == "iosPods")
                {
                    if (isStart)
                    {
                        sourcesiOS = new List <string>();
                    }
                    else
                    {
                        using (var enumerator = sourcesiOS.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                var current = enumerator.Current;
                                Debug.Log(current);
                            }
                        }
                    }

                    return(true);
                }

                if (!(elementName == "source") || !(parentElementName == "sources"))
                {
                    return(false);
                }
                if (isStart && reader.Read() && reader.NodeType == XmlNodeType.Text)
                {
                    sourcesiOS.Add(reader.ReadContentAsString());
                }
                return(true);
            });

            #endregion

            #region AndroidInternalDependencies

            var    sources = new List <string>();
            string specName;

            XmlUtilities.ParseXmlTextFileElements(dependencyPath,
                                                  (reader, elementName, isStart, parentElementName, elementNameStack) =>
            {
                if (elementName == "dependencies" &&
                    parentElementName == "" || elementName == "androidPackages" &&
                    (parentElementName == "dependencies" || parentElementName == ""))
                {
                    return(true);
                }

                if (elementName == "androidPackage" && parentElementName == "androidPackages")
                {
                    if (isStart)
                    {
                        specName = reader.GetAttribute("spec");
                        sources  = new List <string>();
                        if (specName == null)
                        {
                            Debug.Log(
                                $"Pod name not specified while reading {dependencyPath}:{reader.LineNumber}\n");
                            return(false);
                        }

                        foreach (var s in new List <string> {
                            "vast", "nast", "mraid", "appodealx", "appodeal"
                        })
                        {
                            if (!specName.Contains(s))
                            {
                                if (specName.Contains(AppodealDependencyUtils.Replace_dependency_value))
                                {
                                    networkDependency.android_info = new NetworkDependency.AndroidDependency(
                                        AppodealDependencyUtils.GetAndroidDependencyName(specName),
                                        AppodealDependencyUtils.GetAndroidDependencyVersion(specName),
                                        AppodealDependencyUtils.GetAndroidContent(dependencyPath));
                                }
                                else if (specName.Contains(AppodealDependencyUtils.Replace_dependency_core))
                                {
                                    networkDependency.android_info = new NetworkDependency.AndroidDependency(
                                        "appodeal",
                                        AppodealDependencyUtils.GetAndroidDependencyCoreVersion(specName),
                                        AppodealDependencyUtils.GetAndroidContent(dependencyPath));
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }

                    return(true);
                }

                if (elementName == "sources" && parentElementName == "androidPackage")
                {
                    return(true);
                }
                if (elementName == "sources" && parentElementName == "androidPackages")
                {
                    if (isStart)
                    {
                        sources = new List <string>();
                    }
                    else
                    {
                        using (var enumerator = sources.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                var current = enumerator.Current;
                                Debug.Log(current);
                            }
                        }
                    }

                    return(true);
                }

                if (elementName != "source" || parentElementName != "sources")
                {
                    return(false);
                }
                if (isStart && reader.Read() && reader.NodeType == XmlNodeType.Text)
                {
                    sources.Add(reader.ReadContentAsString());
                }
                return(true);
            });

            #endregion

            if (!string.IsNullOrEmpty(networkDependency.name))
            {
                internalDependencies.Add(networkDependency.name, networkDependency);
            }
        }
        private void GuiCoreRow(NetworkDependency internalDependency, NetworkDependency latestDependency,
                                PlatformSdk platform)
        {
            if (internalDependency == null || latestDependency == null)
            {
                return;
            }
            using (new EditorGUILayout.HorizontalScope(GUILayout.Height(20)))
            {
                if (!string.IsNullOrEmpty(internalDependency.name))
                {
                    GUILayout.Space(2);
                    GUILayout.Button(internalDependency.name, packageInfoStyle, GUILayout.Width(150));
                    if (platform == PlatformSdk.iOS)
                    {
                        if (internalDependency.ios_info != null &&
                            !string.IsNullOrEmpty(internalDependency.ios_info.version))
                        {
                            GUILayout.Space(56);
                            GUILayout.Button(
                                AppodealDependencyUtils.ReplaceBetaVersion(internalDependency.ios_info.version),
                                packageInfoStyle, GUILayout.Width(110));
                            if (latestDependency.ios_info != null &&
                                !string.IsNullOrEmpty(latestDependency.ios_info.version))
                            {
                                GUILayout.Space(85);
                                GUILayout.Button(
                                    AppodealDependencyUtils.ReplaceBetaVersion(latestDependency.ios_info.version),
                                    packageInfoStyle);
                                GUILayout.Space(15);

                                if (AppodealDependencyUtils.CompareVersion(internalDependency.ios_info.version,
                                                                           latestDependency.ios_info.version) == 0)
                                {
                                    GUI.enabled = false;
                                    GUILayout.Button(
                                        new GUIContent {
                                        text = AppodealDependencyUtils.ActionUpdate
                                    },
                                        btnFieldWidth);
                                    GUI.enabled = true;
                                }
                                else if (AppodealDependencyUtils.CompareVersion(internalDependency.ios_info.version,
                                                                                latestDependency.ios_info.version) > 0)
                                {
                                    GUI.enabled = false;
                                    GUILayout.Button(
                                        new GUIContent {
                                        text = AppodealDependencyUtils.ActionUpdate
                                    },
                                        btnFieldWidth);
                                    GUI.enabled = true;
                                }
                                else
                                {
                                    UpdateCoreProccess(internalDependency.name,
                                                       internalDependency.ios_info.unity_content,
                                                       latestDependency.ios_info.unity_content, PlatformSdk.iOS);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (internalDependency.android_info != null &&
                            !string.IsNullOrEmpty(internalDependency.android_info.version))
                        {
                            GUILayout.Space(56);
                            GUILayout.Button(
                                AppodealDependencyUtils.ReplaceBetaVersion(internalDependency.android_info.version),
                                packageInfoStyle, GUILayout.Width(110));
                            if (latestDependency.android_info != null &&
                                !string.IsNullOrEmpty(latestDependency.android_info.version))
                            {
                                GUILayout.Space(85);
                                GUILayout.Button(
                                    AppodealDependencyUtils.ReplaceBetaVersion(
                                        latestDependency.android_info.version),
                                    packageInfoStyle);
                                GUILayout.Space(15);

                                if (AppodealDependencyUtils.CompareVersion(
                                        internalDependency.android_info.version,
                                        latestDependency.android_info.version) == 0)
                                {
                                    GUI.enabled = false;
                                    GUILayout.Button(
                                        new GUIContent {
                                        text = AppodealDependencyUtils.ActionUpdate
                                    },
                                        btnFieldWidth);
                                    GUI.enabled = true;
                                }
                                else if (AppodealDependencyUtils.CompareVersion(
                                             internalDependency.android_info.version,
                                             latestDependency.android_info.version) > 0)
                                {
                                    GUI.enabled = false;
                                    GUILayout.Button(
                                        new GUIContent {
                                        text = AppodealDependencyUtils.ActionUpdate
                                    },
                                        btnFieldWidth);
                                    GUI.enabled = true;
                                }
                                else
                                {
                                    UpdateCoreProccess(internalDependency.name,
                                                       internalDependency.android_info.unity_content,
                                                       latestDependency.android_info.unity_content,
                                                       PlatformSdk.Android);
                                }
                            }
                        }
                    }
                }

                GUILayout.Space(5);
                GUILayout.Space(5);
                GUILayout.Space(5);
            }
        }