Commit 6e50ddf5 authored by Sergey Toshin's avatar Sergey Toshin

Generates and saves public.xml in apktool style

parent dda49f15
......@@ -65,7 +65,7 @@ public class ResTableParser extends CommonBinaryParser {
ResXmlGen resGen = new ResXmlGen(resStorage, vp);
ResContainer res = ResContainer.multiFile("res");
res.setContent(makeDump());
res.setContent(makeXmlDump());
res.getSubFiles().addAll(resGen.makeResourcesXml());
return res;
}
......@@ -83,6 +83,23 @@ public class ResTableParser extends CommonBinaryParser {
return writer;
}
public CodeWriter makeXmlDump() {
CodeWriter writer = new CodeWriter();
writer.startLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
writer.startLine("<resources>");
writer.incIndent();
for (ResourceEntry ri : resStorage.getResources()) {
String format = String.format("<public type=\"%s\" name=\"%s\" id=\"%s\" />",
ri.getTypeName(), ri.getKeyName(), ri.getId());
writer.startLine(format);
}
writer.decIndent();
writer.startLine("</resources>");
writer.finish();
return writer;
}
public ResourceStorage getResStorage() {
return resStorage;
}
......
......@@ -46,6 +46,7 @@ public class ResourcesSaver implements Runnable {
if (subFiles.isEmpty()) {
save(rc, outDir);
} else {
saveToFile(rc, new File(outDir, "res/values/public.xml"));
for (ResContainer subFile : subFiles) {
saveResources(subFile);
}
......@@ -65,6 +66,10 @@ public class ResourcesSaver implements Runnable {
}
return;
}
saveToFile(rc, outFile);
}
private void saveToFile(ResContainer rc, File outFile) {
CodeWriter cw = rc.getContent();
if (cw != null) {
cw.save(outFile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment