fix: [XML] decode duplicate file as path string for multiple referencing entries

This commit is contained in:
REAndroid 2023-01-17 05:18:36 -05:00
parent 4439738534
commit db59ebc6ae
2 changed files with 5 additions and 9 deletions

View File

@ -25,7 +25,6 @@ import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock; import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
import com.reandroid.lib.arsc.container.SpecTypePair; import com.reandroid.lib.arsc.container.SpecTypePair;
import com.reandroid.lib.arsc.decoder.ValueDecoder; import com.reandroid.lib.arsc.decoder.ValueDecoder;
import com.reandroid.lib.arsc.item.TableString;
import com.reandroid.lib.arsc.value.*; import com.reandroid.lib.arsc.value.*;
import com.reandroid.lib.common.EntryStore; import com.reandroid.lib.common.EntryStore;
import com.reandroid.lib.common.Frameworks; import com.reandroid.lib.common.Frameworks;
@ -110,7 +109,7 @@ import java.util.*;
resFile.getInputSource().write(outputStream); resFile.getInputSource().write(outputStream);
outputStream.close(); outputStream.close();
addDecodedEntry(resFile.getEntryBlockList()); addDecodedEntry(resFile.pickOne());
} }
private void decodeResXml(EntryStore entryStore, File outDir, ResFile resFile) private void decodeResXml(EntryStore entryStore, File outDir, ResFile resFile)
throws IOException, XMLException{ throws IOException, XMLException{
@ -131,7 +130,7 @@ import java.util.*;
XMLDocument xmlDocument=resXmlBlock.decodeToXml(entryStore, packageBlock.getId()); XMLDocument xmlDocument=resXmlBlock.decodeToXml(entryStore, packageBlock.getId());
xmlDocument.save(file, true); xmlDocument.save(file, true);
addDecodedEntry(resFile.getEntryBlockList()); addDecodedEntry(resFile.pickOne());
} }
private void decodePublicXml(TableBlock tableBlock, File outDir) private void decodePublicXml(TableBlock tableBlock, File outDir)
throws IOException{ throws IOException{
@ -167,11 +166,6 @@ import java.util.*;
xmlDocument.save(file, true); xmlDocument.save(file, true);
addDecodedPath(AndroidManifestBlock.FILE_NAME); addDecodedPath(AndroidManifestBlock.FILE_NAME);
} }
private void addDecodedEntry(Collection<EntryBlock> entryBlockList){
for(EntryBlock entryBlock:entryBlockList){
addDecodedEntry(entryBlock);
}
}
private void addDecodedEntry(EntryBlock entryBlock){ private void addDecodedEntry(EntryBlock entryBlock){
if(entryBlock.isNull()){ if(entryBlock.isNull()){
return; return;

View File

@ -28,7 +28,9 @@ class XMLValuesEncoderColor extends XMLValuesEncoder{
if(encodeResult!=null){ if(encodeResult!=null){
entryBlock.setValueAsRaw(encodeResult.valueType, encodeResult.value); entryBlock.setValueAsRaw(encodeResult.valueType, encodeResult.value);
}else { }else {
throw new EncodeException("Unknown color value: "+value); // If reaches here the value might be
// file path e.g. res/color/something.xml
entryBlock.setValueAsString(value);
} }
} }
} }