mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Added 9patch fix from Charles, worked on com.htc.resources.apk bugs
This commit is contained in:
parent
ab60071410
commit
de52fcba8c
@ -16,7 +16,6 @@
|
||||
|
||||
package brut.androlib.res.data;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -83,27 +82,27 @@ public class ResConfigFlags {
|
||||
byte uiMode, short smallestScreenWidthDp, short screenWidthDp,
|
||||
short screenHeightDp, boolean isInvalid) {
|
||||
if (orientation < 0 || orientation > 3) {
|
||||
LOGGER.log(Level.WARNING, "Invalid orientation value: {0}", orientation);
|
||||
LOGGER.warning("Invalid orientation value: " + orientation);
|
||||
orientation = 0;
|
||||
isInvalid = true;
|
||||
}
|
||||
if (touchscreen < 0 || touchscreen > 3) {
|
||||
LOGGER.log(Level.WARNING, "Invalid touchscreen value: {0}", touchscreen);
|
||||
LOGGER.warning("Invalid touchscreen value: " + touchscreen);
|
||||
touchscreen = 0;
|
||||
isInvalid = true;
|
||||
}
|
||||
if (density < -1) {
|
||||
LOGGER.log(Level.WARNING, "Invalid density value: {0}", density);
|
||||
LOGGER.warning("Invalid density value: " + density);
|
||||
density = 0;
|
||||
isInvalid = true;
|
||||
}
|
||||
if (keyboard < 0 || keyboard > 3) {
|
||||
LOGGER.log(Level.WARNING, "Invalid keyboard value: {0}", keyboard);
|
||||
LOGGER.warning("Invalid keyboard value: " + keyboard);
|
||||
keyboard = 0;
|
||||
isInvalid = true;
|
||||
}
|
||||
if (navigation < 0 || navigation > 4) {
|
||||
LOGGER.log(Level.WARNING, "Invalid navigation value: {0}", navigation);
|
||||
LOGGER.warning("Invalid navigation value: " + navigation);
|
||||
navigation = 0;
|
||||
isInvalid = true;
|
||||
}
|
||||
@ -197,6 +196,9 @@ public class ResConfigFlags {
|
||||
case UI_MODE_TYPE_DESK:
|
||||
ret.append("-desk");
|
||||
break;
|
||||
case UI_MODE_TYPE_TELEVISION:
|
||||
ret.append("-television");
|
||||
break;
|
||||
}
|
||||
switch (uiMode & MASK_UI_MODE_NIGHT) {
|
||||
case UI_MODE_NIGHT_YES:
|
||||
@ -212,8 +214,8 @@ public class ResConfigFlags {
|
||||
case DENSITY_LOW:
|
||||
ret.append("-ldpi");
|
||||
break;
|
||||
case DENSITY_TV:
|
||||
ret.append("-tvdpi");
|
||||
case DENSITY_MEDIUM:
|
||||
ret.append("-mdpi");
|
||||
break;
|
||||
case DENSITY_HIGH:
|
||||
ret.append("-hdpi");
|
||||
@ -360,12 +362,11 @@ public class ResConfigFlags {
|
||||
public final static byte TOUCHSCREEN_STYLUS = 2;
|
||||
public final static byte TOUCHSCREEN_FINGER = 3;
|
||||
|
||||
public final static short DENSITY_DEFAULT = 160;
|
||||
public final static short DENSITY_DEFAULT = 0;
|
||||
public final static short DENSITY_LOW = 120;
|
||||
public final static short DENSITY_MEDIUM = 160;
|
||||
public final static short DENSITY_HIGH = 240;
|
||||
public final static short DENSITY_XHIGH = 320;
|
||||
public final static short DENSITY_TV = 213;
|
||||
public final static short DENSITY_NONE = -1;
|
||||
|
||||
public final static byte KEYBOARD_ANY = 0;
|
||||
@ -417,4 +418,4 @@ public class ResConfigFlags {
|
||||
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(ResConfigFlags.class.getName());
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@ import brut.androlib.AndrolibException;
|
||||
import brut.androlib.err.CantFind9PatchChunk;
|
||||
import brut.util.ExtDataInput;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.*;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -36,15 +38,31 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
||||
BufferedImage im = ImageIO.read(new ByteArrayInputStream(data));
|
||||
int w = im.getWidth(), h = im.getHeight();
|
||||
|
||||
BufferedImage im2 = new BufferedImage(
|
||||
w + 2, h + 2, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
if (im.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
|
||||
im2.getRaster().setRect(1, 1, im.getRaster());
|
||||
BufferedImage im2 = new BufferedImage(w + 2, h + 2, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Raster src = im.getRaster();
|
||||
|
||||
NinePatch np = getNinePatch(data);
|
||||
WritableRaster dst = im2.getRaster();
|
||||
int nbands = im.getSampleModel().getNumBands();
|
||||
int[] bands = new int[4];
|
||||
if (nbands == 2) {
|
||||
bands[0] = bands[1] = bands[2] = 0;
|
||||
bands[3] = 1;
|
||||
} else {
|
||||
im2.getGraphics().drawImage(im, 1, 1, null);
|
||||
bands[0] = 0;
|
||||
bands[1] = 1;
|
||||
bands[2] = 2;
|
||||
bands[3] = 3;
|
||||
}
|
||||
int[] band = null;
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int bi = 0; bi < 4; bi++) {
|
||||
band = src.getSamples(0, y, w, 1, bands[bi], band);
|
||||
dst.setSamples(1, y + 1, w, 1, bi, band);
|
||||
}
|
||||
}
|
||||
|
||||
NinePatch np = getNinePatch(data);
|
||||
|
||||
drawHLine(im2, h + 1, np.padLeft + 1, w - np.padRight);
|
||||
drawVLine(im2, w + 1, np.padTop + 1, h - np.padBottom);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright 2011 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 1.3.2
|
||||
version: 1.4.7
|
||||
apkFileName: testapp.apk
|
||||
isFrameworkApk: false
|
||||
usesFramework:
|
||||
|
Loading…
Reference in New Issue
Block a user