Skip to content

Commit

Permalink
[XML] Fix encode all "id" resource values REAndroid/APKEditor#95
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Apr 5, 2024
1 parent 7cd2a7d commit ee1654d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ private void scanResourceFiles(File resourcesDirectory) throws IOException, XmlP
}
loadPublicXmlFiles(pubXmlFileList);

excludeIds(pubXmlFileList);
initializeFrameworkFromManifest(pubXmlFileList);

encodeAttrs(pubXmlFileList);
Expand Down Expand Up @@ -205,11 +204,6 @@ private void encodeAttrs(List<File> pubXmlFileList) throws IOException, XmlPullP
private void excludeIds(List<File> pubXmlFileList){
for(File pubXmlFile : pubXmlFileList){
addParsedFiles(pubXmlFile);
File valuesDir = pubXmlFile.getParentFile();
File file = new File(valuesDir, "ids.xml");
if(file.isFile()){
addParsedFiles(file);
}
}
}
private void initializeFrameworkFromManifest(File manifestFile) throws IOException {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/reandroid/arsc/coder/xml/XmlCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void encodeEntry(XMLElement entryElement, TypeBlock typeBlock) throws IOE
public void encodeScalar(XMLElement element, Entry entry) throws IOException{
entry.ensureComplex(false);
if(isTypeId(element)){
encodeScalarId(entry);
encodeScalarId(element, entry);
}else {
encodeScalarAny(element, entry);
}
Expand Down Expand Up @@ -285,9 +285,15 @@ private boolean isBag(XMLElement element){
|| element.hasAttribute(ATTR_formats)
|| TypeString.isTypeArray(tag);
}
private void encodeScalarId(Entry entry){
entry.setValueAsBoolean(false);
entry.getHeader().setWeak(true);
private void encodeScalarId(XMLElement element, Entry entry) throws IOException {
if(!element.hasTextNode()){
entry.setValueAsBoolean(false);
}else {
encodeScalarAny(element, entry);
}
ValueHeader header = entry.getHeader();
header.setPublic(true);
header.setWeak(true);
}
private void encodeScalarAny(XMLElement element, Entry entry) throws IOException{
ResValue resValue = entry.getResValue();
Expand Down

0 comments on commit ee1654d

Please sign in to comment.