Search in sources :

Example 1 with ExtMXSerializer

use of brut.androlib.res.util.ExtMXSerializer in project Apktool by iBotPeaches.

the class AndrolibResources method decode.

public void decode(ResTable resTable, ExtFile apkFile, File outDir) throws AndrolibException {
    Duo<ResFileDecoder, AXmlResourceParser> duo = getResFileDecoder();
    ResFileDecoder fileDecoder = duo.m1;
    ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
    attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next());
    Directory inApk, in = null, out;
    try {
        out = new FileDirectory(outDir);
        inApk = apkFile.getDirectory();
        out = out.createDir("res");
        if (inApk.containsDir("res")) {
            in = inApk.getDir("res");
        }
        if (in == null && inApk.containsDir("r")) {
            in = inApk.getDir("r");
        }
        if (in == null && inApk.containsDir("R")) {
            in = inApk.getDir("R");
        }
    } catch (DirectoryException ex) {
        throw new AndrolibException(ex);
    }
    ExtMXSerializer xmlSerializer = getResXmlSerializer();
    for (ResPackage pkg : resTable.listMainPackages()) {
        attrDecoder.setCurrentPackage(pkg);
        LOGGER.info("Decoding file-resources...");
        for (ResResource res : pkg.listFiles()) {
            fileDecoder.decode(res, in, out);
        }
        LOGGER.info("Decoding values */* XMLs...");
        for (ResValuesFile valuesFile : pkg.listValuesFiles()) {
            generateValuesFile(valuesFile, out, xmlSerializer);
        }
        generatePublicXml(pkg, out, xmlSerializer);
    }
    AndrolibException decodeError = duo.m2.getFirstError();
    if (decodeError != null) {
        throw decodeError;
    }
}
Also used : FileDirectory(brut.directory.FileDirectory) AndrolibException(brut.androlib.AndrolibException) ExtMXSerializer(brut.androlib.res.util.ExtMXSerializer) DirectoryException(brut.directory.DirectoryException) FileDirectory(brut.directory.FileDirectory) Directory(brut.directory.Directory)

Example 2 with ExtMXSerializer

use of brut.androlib.res.util.ExtMXSerializer in project Apktool by iBotPeaches.

the class AndrolibResources method getResXmlSerializer.

public ExtMXSerializer getResXmlSerializer() {
    ExtMXSerializer serial = new ExtMXSerializer();
    serial.setProperty(ExtXmlSerializer.PROPERTY_SERIALIZER_INDENTATION, "    ");
    serial.setProperty(ExtXmlSerializer.PROPERTY_SERIALIZER_LINE_SEPARATOR, System.getProperty("line.separator"));
    serial.setProperty(ExtXmlSerializer.PROPERTY_DEFAULT_ENCODING, "utf-8");
    serial.setDisabledAttrEscape(true);
    return serial;
}
Also used : ExtMXSerializer(brut.androlib.res.util.ExtMXSerializer)

Aggregations

ExtMXSerializer (brut.androlib.res.util.ExtMXSerializer)2 AndrolibException (brut.androlib.AndrolibException)1 Directory (brut.directory.Directory)1 DirectoryException (brut.directory.DirectoryException)1 FileDirectory (brut.directory.FileDirectory)1