void AddActivity(string filePath, ActivityInfo info, SDKInfo sdkInfo, ChannelInfo channelInfo)
        {
            string xmlPath = filePath + "\\AndroidManifest.xml";

            //移除旧MainActivity
            if (info.MainActivity)
            {
                RemoveOldMainActivity(filePath);
            }

            //替换关键字
            string newContent = compileTool.ReplaceKeyWord(info.content, channelInfo);

            newContent = compileTool.ReplaceKeyWordbySDKInfo(newContent, sdkInfo);

            string xml   = FileTool.ReadStringByFile(xmlPath);
            int    index = xml.IndexOf("</application>");

            xml = xml.Insert(index, newContent);

            //直接保存
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);
            xmlDoc.Save(xmlPath);

            //添加新MainActivity
            if (info.MainActivity)
            {
                AddMainActivity(filePath, info);
            }
        }
        void CopyFile(string filePath, SDKInfo info, ChannelInfo channelInfo)
        {
            string SDKPath = EditorData.SdkLibPath + "\\" + info.sdkName;

            DirectoryInfo directoryInfo = new DirectoryInfo(SDKPath);

            DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories();
            foreach (DirectoryInfo dir in directoryInfoArray)
            {
                string dirName = FileTool.GetDirectoryName(dir.FullName);

                //只拷贝这三个目录
                if (dirName.Contains("assets") ||
                    dirName.Contains("lib")
                    )
                {
                    FileTool.CopyDirectory(dir.FullName, filePath + "\\" + dirName);
                }

                //合并res文件
                if (dirName.Contains("res"))
                {
                    FileTool.CopyDirectory(dir.FullName, filePath + "\\" + dirName, RepeatHandle);

                    //递归替换关键字
                    FileTool.RecursionFileExecute(filePath + "\\" + dirName, "xml", (file) =>
                    {
                        String content = FileTool.ReadStringByFile(file);
                        content        = compileTool.ReplaceKeyWord(content, channelInfo);

                        FileTool.WriteStringByFile(file, content);
                    });
                }
            }
        }
        void PutSDK(string filePath, SDKInfo info)
        {
            SDKConfig config = EditorData.TotalSDKInfo.GetSDKConfig(info.sdkName);

            //添加Jar
            OutPut("添加Jar " + info.sdkName);
            PutJar(filePath, info);

            //拷贝资源文件
            OutPut("拷贝资源文件 " + info.sdkName);
            CopyFile(filePath, info);

            //添加Activity
            for (int i = 0; i < config.ActivityInfoList.Count; i++)
            {
                OutPut("添加Activity " + info.sdkName + " " + config.ActivityInfoList[i].name);
                AddActivity(filePath, config.ActivityInfoList[i]);
            }

            //添加Service
            for (int i = 0; i < config.serviceInfoList.Count; i++)
            {
                OutPut("添加Service " + info.sdkName + " " + config.serviceInfoList[i].name);
                AddService(filePath, config.serviceInfoList[i]);
            }

            if (!string.IsNullOrEmpty(config.ApplicationName))
            {
                ChangeApplicationName(filePath, config.ApplicationName);
            }

            //添加配置文件
            OutPut("添加配置文件 " + info.sdkName);
            SaveSDKConfigFile(filePath, info);
        }
Example #4
0
        //获取SDK信息
        static IEnumerator UF_IGetSDKInfo()
        {
            Debugger.UF_Log("==== Waiting For SDK info ====");
            IsAppCheck = false;

            //等待返回,无限期等待
            while (SDKInfo == null)
            {
                if (SDKInfo != null)
                {
                    break;
                }
                yield return(null);
            }
            if (SDKInfo != null)
            {
                Debugger.UF_Log(string.Format("SDK Info:\n{0}", SDKInfo.UF_Serialize()));
                //是否接入了SDK
                IsSdkOn = SDKInfo.UF_GetValue("SDK_ON", "0") == "1";
                //当前的APPID
                AppID = SDKInfo.UF_GetValue("APP_ID", "0");
                //查询获取审核状态
                IsAppCheck = SDKInfo.UF_GetValue("APP_CHECK", "0") == "1";
            }
            yield break;
        }
        void CopyFile(string filePath, SDKInfo info)
        {
            string SDKPath = EditorData.SdkLibPath + "\\" + info.sdkName;

            DirectoryInfo directoryInfo = new DirectoryInfo(SDKPath);

            DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories();
            foreach (DirectoryInfo dir in directoryInfoArray)
            {
                string dirName = FileTool.GetDirectoryName(dir.FullName);

                //只拷贝这三个目录
                if (dirName.Contains("assets") ||
                    dirName.Contains("lib")
                    )
                {
                    FileTool.CopyDirectory(dir.FullName, filePath + "\\" + dirName);
                }

                //合并res文件
                if (dirName.Contains("res"))
                {
                    FileTool.CopyDirectory(dir.FullName, filePath + "\\" + dirName, RepeatHandle);
                }
            }
        }
 public override ApkInfo getAPK()
 {
     return(new ApkInfo()
     {
         MinSDK = SDKInfo.GetInfo(getMinSDKVersion()),
         TargetSDK = SDKInfo.GetInfo(getTargetSDKVersion())
     });
 }
Example #7
0
    public string ReplaceKeyWordbySDKInfo(string oldContent, SDKInfo SDKinfo)
    {
        string result = oldContent;

        for (int i = 0; i < SDKinfo.sdkConfig.Count; i++)
        {
            result = result.Replace("{" + SDKinfo.sdkConfig[i].key + "}", SDKinfo.sdkConfig[i].value);
        }
        return(result);
    }
Example #8
0
 public static string UF_GetSDKValue(string key)
 {
     if (SDKInfo != null)
     {
         return(SDKInfo.UF_GetValue(key));
     }
     else
     {
         return(string.Empty);
     }
 }
        void PutJar(string filePath, SDKInfo info)
        {
            string libPath = EditorData.SdkLibPath + "\\" + info.sdkName;

            List <string> jarList = FileTool.GetAllFileNamesByPath(libPath, new string[] { "jar" }, false);

            for (int i = 0; i < jarList.Count; i++)
            {
                compileTool.Jar2Smali(jarList[i], filePath);
            }
        }
        void SaveSDKManifest(string filePath, ChannelInfo info)
        {
            string path    = filePath + "\\assets\\SdkManifest.properties";
            string content = "";

            foreach (SDKType item in Enum.GetValues(typeof(SDKType)))
            {
                string key   = item.ToString();
                string value = "";

                for (int i = 0; i < info.sdkList.Count; i++)
                {
                    SDKInfo   si     = info.sdkList[i];
                    SDKConfig config = EditorData.TotalSDKInfo.GetSDKConfig(si.sdkName);
                    if ((config.sdkType & item) != 0)
                    {
                        if (config.className == null)
                        {
                            config.className = config.SdkName + "<NullClassName>";
                        }

                        if (value == "")
                        {
                            value += config.className;
                        }
                        else
                        {
                            value += "|" + config.className;
                        }
                    }
                }
                content += key + "=" + value + "\n";
            }

            //content += "\n";

            for (int i = 0; i < info.sdkList.Count; i++)
            {
                SDKConfig config = EditorData.TotalSDKInfo.GetSDKConfig(info.sdkList[i].sdkName);
                content += config.className + "=" + config.sdkName + "\n";
            }

            if (info.isLog)
            {
                content += "IsLog=true\n";
            }

            FileTool.WriteStringByFile(path, content);
        }
        void SaveSDKConfigFile(string filePath, SDKInfo info)
        {
            //TODO 加密此处以免破解
            string path = filePath + "\\assets\\" + info.SdkName + ".properties";

            string content = "";

            for (int i = 0; i < info.sdkConfig.Count; i++)
            {
                KeyValue kv = info.sdkConfig[i];

                content += kv.key + "=" + kv.value + "\n";
            }

            FileTool.WriteStringByFile(path, content);
        }
        void AddMainActivityProperty(string filePath, KeyValue kv, SDKInfo sdkInfo, ChannelInfo channelInfo)
        {
            string xmlPath = filePath + "\\AndroidManifest.xml";

            string      xml    = FileTool.ReadStringByFile(xmlPath);
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);

            //替换关键字
            string newValue = compileTool.ReplaceKeyWord(kv.value, channelInfo);

            newValue = compileTool.ReplaceKeyWordbySDKInfo(newValue, sdkInfo);

            XmlNode manifest = xmlDoc.SelectSingleNode("manifest");
            XmlNode app      = GetNode(manifest, "application");

            //获取主Activity
            for (int i = 0; i < app.ChildNodes.Count; i++)
            {
                XmlNode    node = app.ChildNodes[i];
                XmlElement ele  = (XmlElement)node;
                for (int j = 0; j < ele.ChildNodes.Count; j++)
                {
                    XmlNode node2 = ele.ChildNodes[j];

                    if (node2.Name == "intent-filter")
                    {
                        XmlNode    action = GetNode(node2, "category");
                        XmlElement ele2   = (XmlElement)action;

                        if (ele2.GetAttribute("name", "http://schemas.android.com/apk/res/android") == "android.intent.category.LAUNCHER")
                        {
                            //增加属性
                            ele.SetAttribute(kv.key, "http://schemas.android.com/apk/res/android", newValue);

                            break;
                        }
                    }
                }
            }

            //保存
            xmlDoc.Save(xmlPath);
        }
        void AddService(string filePath, ServiceInfo info, ChannelInfo channelInfo, SDKInfo SDKinfo)
        {
            string xmlPath = filePath + "\\AndroidManifest.xml";
            string xml     = FileTool.ReadStringByFile(xmlPath);

            string content = compileTool.ReplaceKeyWord(info.content, channelInfo);

            content = compileTool.ReplaceKeyWordbySDKInfo(content, SDKinfo);

            int index = xml.IndexOf("</application>");

            xml = xml.Insert(index, content);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);
            xmlDoc.Save(xmlPath);
        }
        void AddUses(string filePath, KeyValue kv, ChannelInfo channelInfo, SDKInfo info)
        {
            string xmlPath = filePath + "\\AndroidManifest.xml";
            string xml     = FileTool.ReadStringByFile(xmlPath);

            int index = xml.IndexOf("</manifest>");

            //替换关键字和配置
            string content = compileTool.ReplaceKeyWord(kv.value, channelInfo);

            content = compileTool.ReplaceKeyWordbySDKInfo(content, info);

            xml = xml.Insert(index, content);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);
            xmlDoc.Save(xmlPath);
        }
        void AddXMLHead(string filePath, KeyValue info, SDKInfo sdkInfo, ChannelInfo channelInfo)
        {
            string xmlPath = filePath + "\\AndroidManifest.xml";

            //替换关键字
            string newContent = compileTool.ReplaceKeyWord(info.value, channelInfo);

            newContent = compileTool.ReplaceKeyWordbySDKInfo(newContent, sdkInfo);

            string xml   = FileTool.ReadStringByFile(xmlPath);
            int    index = xml.IndexOf("<manifest") + 10;

            xml = xml.Insert(index, newContent + " "); //最后加一个空格

            //直接保存
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);
            xmlDoc.Save(xmlPath);
        }
        protected override void OnAttach()
        {
            base.OnAttach();

            Control window = ControlDeclarationManager.Instance.CreateControl("Gui\\AboutWindow.gui");

            Controls.Add(window);

            window.Controls["Version"].Text = EngineVersionInformation.Version;

            ((Button)window.Controls["Quit"]).Click += delegate(Button sender)
            {
                SetShouldDetach();
            };

            SDKInfo.SDKs sdk   = SDKInfo.GetSDK();
            float        alpha = .08f;

            if (sdk > SDKInfo.SDKs.Free)
            {
                window.Controls["FreeSDK"].ColorMultiplier           = new ColorValue(1, 1, 1, alpha);
                window.Controls["FreeSDKBackground"].ColorMultiplier = new ColorValue(1, 1, 1, alpha);
            }
            if (sdk > SDKInfo.SDKs.Professional)
            {
                window.Controls["ProfessionalSDK"].ColorMultiplier           = new ColorValue(1, 1, 1, alpha);
                window.Controls["ProfessionalSDKBackground"].ColorMultiplier = new ColorValue(1, 1, 1, alpha);
            }
            if (sdk > SDKInfo.SDKs.Unlimited)
            {
                window.Controls["UnlimitedSDK"].ColorMultiplier           = new ColorValue(1, 1, 1, alpha);
                window.Controls["UnlimitedSDKBackground"].ColorMultiplier = new ColorValue(1, 1, 1, alpha);
            }

            BackColor  = new ColorValue(0, 0, 0, .5f);
            MouseCover = true;
        }
        void PutSDK(string filePath, SDKInfo info, ChannelInfo channelInfo)
        {
            SDKConfig config = EditorData.TotalSDKInfo.GetSDKConfig(info.sdkName);

            //添加Jar
            OutPut("添加Jar " + info.sdkName);
            PutJar(filePath, info);

            //手动移除无法编译通过的字段
            RemoveErrordManifest(filePath);

            //自动编译类
            if (config.useCustomJavaClass)
            {
                OutPut("自动编译 ");
                compileTool.Compile(config, channelInfo, filePath);
            }

            //拷贝资源文件
            OutPut("拷贝资源文件 " + info.sdkName);
            CopyFile(filePath, info, channelInfo);

            //添加标签头
            for (int i = 0; i < config.XmlHeadList.Count; i++)
            {
                OutPut("添加AddXMLHead " + info.sdkName + " " + config.ActivityInfoList[i].name);
                AddXMLHead(filePath, config.XmlHeadList[i], info, channelInfo);
            }

            //添加Activity
            for (int i = 0; i < config.ActivityInfoList.Count; i++)
            {
                OutPut("添加Activity " + info.sdkName + " " + config.ActivityInfoList[i].name);
                AddActivity(filePath, config.ActivityInfoList[i], info, channelInfo);
            }

            //添加MainActivityProperty
            for (int i = 0; i < config.mainActivityPropertyList.Count; i++)
            {
                OutPut("添加mainActivityProperty " + info.sdkName + " " + config.mainActivityPropertyList[i].key);
                AddMainActivityProperty(filePath, config.mainActivityPropertyList[i], info, channelInfo);
            }

            //添加Service
            for (int i = 0; i < config.serviceInfoList.Count; i++)
            {
                OutPut("添加Service " + info.sdkName + " " + config.serviceInfoList[i].name);
                AddService(filePath, config.serviceInfoList[i], channelInfo, info);
            }

            //添加Provider
            for (int i = 0; i < config.providerInfoList.Count; i++)
            {
                OutPut("添加Provider " + info.sdkName + " " + config.providerInfoList[i].name);
                AddProvider(filePath, config.providerInfoList[i], channelInfo, info);
            }

            //添加Meta字段
            for (int i = 0; i < config.metaInfoList.Count; i++)
            {
                OutPut("添加Meta " + info.sdkName + " " + config.metaInfoList[i].key);
                AddMeta(filePath, config.metaInfoList[i], channelInfo, info);
            }

            //添加Uses字段
            for (int i = 0; i < config.usesList.Count; i++)
            {
                OutPut("添加Uses " + info.sdkName + " " + config.usesList[i].key);
                AddUses(filePath, config.usesList[i], channelInfo, info);
            }

            //修改ApplicationName
            if (!string.IsNullOrEmpty(config.ApplicationName))
            {
                OutPut("修改ApplicationName " + config.ApplicationName);
                ChangeApplicationName(filePath, config.ApplicationName);
            }

            //添加配置文件
            OutPut("添加配置文件 " + info.sdkName);
            SaveSDKConfigFile(filePath, info);
        }