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 { ...@@ -65,7 +65,7 @@ public class ResTableParser extends CommonBinaryParser {
ResXmlGen resGen = new ResXmlGen(resStorage, vp); ResXmlGen resGen = new ResXmlGen(resStorage, vp);
ResContainer res = ResContainer.multiFile("res"); ResContainer res = ResContainer.multiFile("res");
res.setContent(makeDump()); res.setContent(makeXmlDump());
res.getSubFiles().addAll(resGen.makeResourcesXml()); res.getSubFiles().addAll(resGen.makeResourcesXml());
return res; return res;
} }
...@@ -83,6 +83,23 @@ public class ResTableParser extends CommonBinaryParser { ...@@ -83,6 +83,23 @@ public class ResTableParser extends CommonBinaryParser {
return writer; 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() { public ResourceStorage getResStorage() {
return resStorage; return resStorage;
} }
......
...@@ -46,6 +46,7 @@ public class ResourcesSaver implements Runnable { ...@@ -46,6 +46,7 @@ public class ResourcesSaver implements Runnable {
if (subFiles.isEmpty()) { if (subFiles.isEmpty()) {
save(rc, outDir); save(rc, outDir);
} else { } else {
saveToFile(rc, new File(outDir, "res/values/public.xml"));
for (ResContainer subFile : subFiles) { for (ResContainer subFile : subFiles) {
saveResources(subFile); saveResources(subFile);
} }
...@@ -65,6 +66,10 @@ public class ResourcesSaver implements Runnable { ...@@ -65,6 +66,10 @@ public class ResourcesSaver implements Runnable {
} }
return; return;
} }
saveToFile(rc, outFile);
}
private void saveToFile(ResContainer rc, File outFile) {
CodeWriter cw = rc.getContent(); CodeWriter cw = rc.getContent();
if (cw != null) { if (cw != null) {
cw.save(outFile); 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