mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-04-29 22:04:25 +02:00
write public.xml directly
This commit is contained in:
parent
25aee4c6ef
commit
74c0f533de
@ -25,6 +25,7 @@ import com.reandroid.json.JSONObject;
|
|||||||
import com.reandroid.xml.*;
|
import com.reandroid.xml.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ResourceIds {
|
public class ResourceIds {
|
||||||
@ -210,11 +211,32 @@ import java.util.*;
|
|||||||
writeXml(outputStream);
|
writeXml(outputStream);
|
||||||
}
|
}
|
||||||
public void writeXml(OutputStream outputStream) throws IOException {
|
public void writeXml(OutputStream outputStream) throws IOException {
|
||||||
XMLDocument xmlDocument=toXMLDocument();
|
String indent = " ";
|
||||||
xmlDocument.setIndent(1);
|
writeXml(indent, outputStream);
|
||||||
xmlDocument.save(outputStream, false);
|
}
|
||||||
|
public void writeXml(String indent, OutputStream outputStream) throws IOException {
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
|
||||||
|
writeXml(indent, writer);
|
||||||
|
writer.close();
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
public void writeXml(String indent, Writer writer) throws IOException{
|
||||||
|
writeBegin(writer);
|
||||||
|
for(Package pkg:listPackages()){
|
||||||
|
pkg.writeXml(indent, writer);
|
||||||
|
}
|
||||||
|
writeEnd(writer);
|
||||||
|
writer.flush();
|
||||||
|
}
|
||||||
|
private void writeBegin(Writer writer) throws IOException{
|
||||||
|
writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
|
writer.write('\n');
|
||||||
|
writer.write("<resources>");
|
||||||
|
}
|
||||||
|
private void writeEnd(Writer writer) throws IOException{
|
||||||
|
writer.write('\n');
|
||||||
|
writer.write("</resources>");
|
||||||
|
}
|
||||||
public void fromXml(File file) throws IOException {
|
public void fromXml(File file) throws IOException {
|
||||||
FileInputStream inputStream=new FileInputStream(file);
|
FileInputStream inputStream=new FileInputStream(file);
|
||||||
fromXml(inputStream);
|
fromXml(inputStream);
|
||||||
@ -434,6 +456,23 @@ import java.util.*;
|
|||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
public void writeXml(String indent, Writer writer) throws IOException{
|
||||||
|
writeComment(indent, writer);
|
||||||
|
for(Type type:listTypes()){
|
||||||
|
type.writeXml(indent, writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void writeComment(String indent, Writer writer) throws IOException{
|
||||||
|
String name = this.name;
|
||||||
|
if(name == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writer.write('\n');
|
||||||
|
writer.write(indent);
|
||||||
|
writer.write("<!--packageName=\"");
|
||||||
|
writer.write(name);
|
||||||
|
writer.write("\"-->");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
@ -588,6 +627,11 @@ import java.util.*;
|
|||||||
int countEntries(){
|
int countEntries(){
|
||||||
return entryMap.size();
|
return entryMap.size();
|
||||||
}
|
}
|
||||||
|
public void writeXml(String indent, Writer writer) throws IOException{
|
||||||
|
for(Entry entry:listEntries()){
|
||||||
|
entry.writeXml(indent, writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Type type) {
|
public int compareTo(Type type) {
|
||||||
return Integer.compare(getIdInt(), type.getIdInt());
|
return Integer.compare(getIdInt(), type.getIdInt());
|
||||||
@ -691,6 +735,18 @@ import java.util.*;
|
|||||||
public String getHexId(){
|
public String getHexId(){
|
||||||
return String.format("0x%08x", getResourceId());
|
return String.format("0x%08x", getResourceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeXml(String indent, Writer writer) throws IOException{
|
||||||
|
writer.write('\n');
|
||||||
|
writer.write(indent);
|
||||||
|
writer.write("<public id=\"");
|
||||||
|
writer.write(getHexId());
|
||||||
|
writer.write("\" type=\"");
|
||||||
|
writer.write(getTypeName());
|
||||||
|
writer.write("\" name=\"");
|
||||||
|
writer.write(getName());
|
||||||
|
writer.write("\"/>");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Entry entry) {
|
public int compareTo(Entry entry) {
|
||||||
return Integer.compare(getEntryIdInt(), entry.getEntryIdInt());
|
return Integer.compare(getEntryIdInt(), entry.getEntryIdInt());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user