示例#1
0
        public void ProcessFile(object fileObject, Func <bool> isCanceled)
        {
            if (fileObject == null)
            {
                throw new ArgumentNullException("fileObject");
            }
            var file = fileObject as ApkFile;

            if (file == null)
            {
                throw new Exception(string.Format("{0} can not handle object of type {1}", GetType().Name,
                                                  fileObject.GetType().Name));
            }

            if (FolderUtility.Empty(file.ResourceFolder))
            {
                return;
            }
            MessageEngine.AddInformation(this, string.Format("Updating {0} with optimized png files", file.Name));
            using (var zf = new AndroidArchive(file.FileSystemPath))
            {
                foreach (string pngFile in file.GetPngFilesToOptimize())
                {
                    zf.Add(pngFile, FolderUtility.GetRelativePath(file.ResourceFolder, pngFile), CompressionType.Store);
                }
            }
        }
示例#2
0
        protected void Recompile(string compositFilePath, string inputFolder, CrcsProject project)
        {
            var ep       = new ExecuteProgram();
            var apiLevel = project.Properties.ApiLevel;

            var arguments = new StringBuilder();

            arguments.Append("-jar \"").Append(_smaliFile).Append("\"");
            arguments.Append(" \"").Append(inputFolder).Append("\"");
            string classesDexFile = Path.Combine(FolderUtility.CreateTempFolder(), "classes.dex");

            arguments.Append(" -o \"").Append(classesDexFile).Append("\"");
            if (_useSmaliApiLevel)
            {
                arguments.Append(" -a ").Append(apiLevel);
            }
            if (ep.Execute(_javaFile, arguments.ToString(), Path.GetDirectoryName(classesDexFile)) != 0)
            {
                throw ep.CreateException(Path.GetFileName(_smaliFile));
            }

            // add to program file apk/jar...
            using (var zf = new AndroidArchive(compositFilePath))
            {
                zf.Add(classesDexFile, Path.GetFileName(classesDexFile));
            }
        }