mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-21 09:17:35 +01:00
Added automatic 9-patch workaround.
This commit is contained in:
parent
dc1a645396
commit
d35120da35
@ -199,10 +199,14 @@ public class Androlib {
|
|||||||
File apkFile = File.createTempFile("APKTOOL", null);
|
File apkFile = File.createTempFile("APKTOOL", null);
|
||||||
apkFile.delete();
|
apkFile.delete();
|
||||||
|
|
||||||
|
File ninePatch = new File(appDir, "9patch");
|
||||||
|
if (! ninePatch.exists()) {
|
||||||
|
ninePatch = null;
|
||||||
|
}
|
||||||
mAndRes.aaptPackage(
|
mAndRes.aaptPackage(
|
||||||
apkFile,
|
apkFile,
|
||||||
new File(appDir, "AndroidManifest.xml"),
|
new File(appDir, "AndroidManifest.xml"),
|
||||||
new File(appDir, "res")
|
new File(appDir, "res"), ninePatch, null, false
|
||||||
);
|
);
|
||||||
|
|
||||||
new ExtFile(apkFile).getDirectory()
|
new ExtFile(apkFile).getDirectory()
|
||||||
|
@ -66,13 +66,12 @@ final public class AndrolibResources {
|
|||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File out9PatchDir = new File(outDir, "9patch/res");
|
||||||
ExtMXSerializer xmlSerializer = getResXmlSerializer();
|
ExtMXSerializer xmlSerializer = getResXmlSerializer();
|
||||||
for (ResPackage pkg : resTable.listMainPackages()) {
|
for (ResPackage pkg : resTable.listMainPackages()) {
|
||||||
attrDecoder.setCurrentPackage(pkg);
|
attrDecoder.setCurrentPackage(pkg);
|
||||||
for (ResResource res : pkg.listFiles()) {
|
for (ResResource res : pkg.listFiles()) {
|
||||||
ResFileValue fileValue = (ResFileValue) res.getValue();
|
decodeFile(res, in, out, fileDecoder, out9PatchDir);
|
||||||
fileDecoder.decode(in, fileValue.getStrippedPath(),
|
|
||||||
out, res.getFilePath());
|
|
||||||
}
|
}
|
||||||
for (ResValuesFile valuesFile : pkg.listValuesFiles()) {
|
for (ResValuesFile valuesFile : pkg.listValuesFiles()) {
|
||||||
generateValuesFile(valuesFile, out, xmlSerializer);
|
generateValuesFile(valuesFile, out, xmlSerializer);
|
||||||
@ -156,6 +155,31 @@ final public class AndrolibResources {
|
|||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void decodeFile(ResResource res, Directory in, Directory out,
|
||||||
|
ResFileDecoder fileDecoder, File out9PatchDir)
|
||||||
|
throws AndrolibException {
|
||||||
|
ResFileValue fileValue = (ResFileValue) res.getValue();
|
||||||
|
String inName = fileValue.getStrippedPath();
|
||||||
|
String outName = res.getFilePath();
|
||||||
|
|
||||||
|
fileDecoder.decode(in, inName, out, outName);
|
||||||
|
|
||||||
|
if (inName.endsWith(".9.png")) {
|
||||||
|
File out9PatchFile = new File(
|
||||||
|
out9PatchDir, outName + ".png");
|
||||||
|
out9PatchFile.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
|
BrutIO.copyAndClose(in.getFileInput(inName),
|
||||||
|
new FileOutputStream(out9PatchFile));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new AndrolibException(ex);
|
||||||
|
} catch (DirectoryException ex) {
|
||||||
|
throw new AndrolibException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void generateValuesFile(ResValuesFile valuesFile, Directory out,
|
private void generateValuesFile(ResValuesFile valuesFile, Directory out,
|
||||||
XmlSerializer serial) throws AndrolibException {
|
XmlSerializer serial) throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user