mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-01 06:37:34 +01:00
Fixed an issue when *.9.png doesn't have 9patch chunk in it.
This commit is contained in:
parent
604b15c1cc
commit
036d766602
40
src/brut/androlib/err/CantFind9PatchChunk.java
Normal file
40
src/brut/androlib/err/CantFind9PatchChunk.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Ryszard Wiśniewski <brut.alll@gmail.com>.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package brut.androlib.err;
|
||||||
|
|
||||||
|
import brut.androlib.AndrolibException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
|
*/
|
||||||
|
public class CantFind9PatchChunk extends AndrolibException {
|
||||||
|
|
||||||
|
public CantFind9PatchChunk(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CantFind9PatchChunk(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CantFind9PatchChunk(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CantFind9PatchChunk() {
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
package brut.androlib.res.decoder;
|
package brut.androlib.res.decoder;
|
||||||
|
|
||||||
import brut.androlib.AndrolibException;
|
import brut.androlib.AndrolibException;
|
||||||
|
import brut.androlib.err.CantFind9PatchChunk;
|
||||||
import brut.util.ExtDataInput;
|
import brut.util.ExtDataInput;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -79,7 +80,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
|||||||
try {
|
try {
|
||||||
size = di.readInt();
|
size = di.readInt();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AndrolibException("Cant find nine patch chunk", ex);
|
throw new CantFind9PatchChunk("Cant find nine patch chunk", ex);
|
||||||
}
|
}
|
||||||
if (di.readInt() == NP_CHUNK_TYPE) {
|
if (di.readInt() == NP_CHUNK_TYPE) {
|
||||||
return;
|
return;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package brut.androlib.res.decoder;
|
package brut.androlib.res.decoder;
|
||||||
|
|
||||||
import brut.androlib.AndrolibException;
|
import brut.androlib.AndrolibException;
|
||||||
|
import brut.androlib.err.CantFind9PatchChunk;
|
||||||
import brut.androlib.res.data.ResResource;
|
import brut.androlib.res.data.ResResource;
|
||||||
import brut.androlib.res.data.value.ResFileValue;
|
import brut.androlib.res.data.value.ResFileValue;
|
||||||
import brut.directory.Directory;
|
import brut.directory.Directory;
|
||||||
@ -62,8 +63,19 @@ public class ResFileDecoder {
|
|||||||
if (typeName.equals("drawable")) {
|
if (typeName.equals("drawable")) {
|
||||||
if (inFileName.toLowerCase().endsWith(".9.png")) {
|
if (inFileName.toLowerCase().endsWith(".9.png")) {
|
||||||
outFileName = outResName + ".9" + ext;
|
outFileName = outResName + ".9" + ext;
|
||||||
decode(inDir, inFileName, outDir, outFileName, "9patch");
|
|
||||||
return;
|
try {
|
||||||
|
decode(
|
||||||
|
inDir, inFileName, outDir, outFileName, "9patch");
|
||||||
|
return;
|
||||||
|
} catch (CantFind9PatchChunk ex) {
|
||||||
|
LOGGER.log(Level.WARNING, String.format(
|
||||||
|
"Cant find 9patch chunk in file: \"%s\". Renaming it to *.png.",
|
||||||
|
inFileName
|
||||||
|
), ex);
|
||||||
|
outDir.removeFile(outFileName);
|
||||||
|
outFileName = outResName + ext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! ext.equals(".xml")) {
|
if (! ext.equals(".xml")) {
|
||||||
decode(inDir, inFileName, outDir, outFileName, "raw");
|
decode(inDir, inFileName, outDir, outFileName, "raw");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user