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); } } }
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 (!file.IsDeCoded) return; MessageEngine.AddInformation(this, string.Format("Encoding resources for {0}", file.Name)); DecodeHandler.InstallFrameworkIfMissing(file); FileUtility.DeleteFile(file.UnsignedFile); var ep = new ExecuteProgram((message) => MessageEngine.AddInformation(this, message)); var arguments = new StringBuilder(); arguments.Append("-jar \"").Append(_apkToolFile).Append("\""); if (_verbose) arguments.Append(" -v"); arguments.Append(" b -f \"").Append(file.ResourceFolder).Append("\""); arguments.Append(" \"").Append(file.UnsignedFile).Append("\""); if (ep.Execute(_javaFile, arguments.ToString(), Path.GetDirectoryName(_apkToolFile)) != 0) { throw new Exception(string.Format("Program {0} failed", Path.GetFileName(_apkToolFile))); } //ZipFile.ExtractAll(file.UnsignedFile, file.UnsignedFolder, true); using (var zf = new AndroidArchive(file.FileSystemPath, CrcsSettings.Current.OnlyStoreFileTypes)) { zf.MergeZipFile(file.UnsignedFile, true); //foreach (string resFile in Directory.GetFiles(file.UnsignedFolder, "*.*", SearchOption.AllDirectories)) //{ // if (resFile.IndexOf(@"\META-INF\", StringComparison.Ordinal) >= 0) continue; // if (resFile.EndsWith("AndroidManifest.xml", StringComparison.OrdinalIgnoreCase)) continue; // zf.Add(resFile, FolderUtility.GetRelativePath(file.UnsignedFolder, resFile)); //} } }
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)); } }