mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-08 11:05:52 +01:00
Reformat & Rearrange
This commit is contained in:
parent
7ff89c4f44
commit
c3e8be3e8a
@ -15,9 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package android.content.res;
|
package android.content.res;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XML parsing interface returned for an XML resource. This is a standard
|
* The XML parsing interface returned for an XML resource. This is a standard
|
||||||
@ -26,9 +25,9 @@ import android.util.AttributeSet;
|
|||||||
* it is done reading the resource.
|
* it is done reading the resource.
|
||||||
*/
|
*/
|
||||||
public interface XmlResourceParser extends XmlPullParser, AttributeSet {
|
public interface XmlResourceParser extends XmlPullParser, AttributeSet {
|
||||||
/**
|
/**
|
||||||
* Close this interface to the resource. Calls on the interface are no
|
* Close this interface to the resource. Calls on the interface are no
|
||||||
* longer value after this call.
|
* longer value after this call.
|
||||||
*/
|
*/
|
||||||
void close();
|
void close();
|
||||||
}
|
}
|
||||||
|
@ -16,58 +16,52 @@
|
|||||||
package android.util;
|
package android.util;
|
||||||
|
|
||||||
public interface AttributeSet {
|
public interface AttributeSet {
|
||||||
int getAttributeCount();
|
int getAttributeCount();
|
||||||
|
|
||||||
String getAttributeName(int index);
|
String getAttributeName(int index);
|
||||||
|
|
||||||
String getAttributeValue(int index);
|
String getAttributeValue(int index);
|
||||||
|
|
||||||
String getPositionDescription();
|
String getPositionDescription();
|
||||||
|
|
||||||
int getAttributeNameResource(int index);
|
int getAttributeNameResource(int index);
|
||||||
|
|
||||||
int getAttributeListValue(int index, String[] options, int defaultValue);
|
int getAttributeListValue(int index, String[] options, int defaultValue);
|
||||||
|
|
||||||
boolean getAttributeBooleanValue(int index, boolean defaultValue);
|
boolean getAttributeBooleanValue(int index, boolean defaultValue);
|
||||||
|
|
||||||
int getAttributeResourceValue(int index, int defaultValue);
|
int getAttributeResourceValue(int index, int defaultValue);
|
||||||
|
|
||||||
int getAttributeIntValue(int index, int defaultValue);
|
int getAttributeIntValue(int index, int defaultValue);
|
||||||
|
|
||||||
int getAttributeUnsignedIntValue(int index, int defaultValue);
|
int getAttributeUnsignedIntValue(int index, int defaultValue);
|
||||||
|
|
||||||
float getAttributeFloatValue(int index, float defaultValue);
|
float getAttributeFloatValue(int index, float defaultValue);
|
||||||
|
|
||||||
String getIdAttribute();
|
String getIdAttribute();
|
||||||
|
|
||||||
String getClassAttribute();
|
String getClassAttribute();
|
||||||
|
|
||||||
int getIdAttributeResourceValue(int index);
|
int getIdAttributeResourceValue(int index);
|
||||||
|
|
||||||
int getStyleAttribute();
|
int getStyleAttribute();
|
||||||
|
|
||||||
String getAttributeValue(String namespace, String attribute);
|
String getAttributeValue(String namespace, String attribute);
|
||||||
|
|
||||||
int getAttributeListValue(String namespace, String attribute,
|
int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue);
|
||||||
String[] options, int defaultValue);
|
|
||||||
|
|
||||||
boolean getAttributeBooleanValue(String namespace, String attribute,
|
boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue);
|
||||||
boolean defaultValue);
|
|
||||||
|
|
||||||
int getAttributeResourceValue(String namespace, String attribute,
|
int getAttributeResourceValue(String namespace, String attribute, int defaultValue);
|
||||||
int defaultValue);
|
|
||||||
|
|
||||||
int getAttributeIntValue(String namespace, String attribute,
|
int getAttributeIntValue(String namespace, String attribute, int defaultValue);
|
||||||
int defaultValue);
|
|
||||||
|
|
||||||
int getAttributeUnsignedIntValue(String namespace, String attribute,
|
int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue);
|
||||||
int defaultValue);
|
|
||||||
|
|
||||||
float getAttributeFloatValue(String namespace, String attribute,
|
float getAttributeFloatValue(String namespace, String attribute, float defaultValue);
|
||||||
float defaultValue);
|
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
int getAttributeValueType(int index);
|
int getAttributeValueType(int index);
|
||||||
|
|
||||||
int getAttributeValueData(int index);
|
int getAttributeValueData(int index);
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,13 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable {
|
|||||||
mL10n = l10n;
|
mL10n = l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String convertToResXmlFormat(ResScalarValue value)
|
public String convertToResXmlFormat(ResScalarValue value) throws AndrolibException {
|
||||||
throws AndrolibException {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serializeToResValuesXml(XmlSerializer serializer,
|
public void serializeToResValuesXml(XmlSerializer serializer, ResResource res)
|
||||||
ResResource res) throws IOException, AndrolibException {
|
throws IOException, AndrolibException {
|
||||||
String type = getTypeAsString();
|
String type = getTypeAsString();
|
||||||
|
|
||||||
serializer.startTag(null, "attr");
|
serializer.startTag(null, "attr");
|
||||||
@ -90,30 +89,24 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable {
|
|||||||
if (i == items.length) {
|
if (i == items.length) {
|
||||||
return new ResAttr(parent, scalarType, min, max, l10n);
|
return new ResAttr(parent, scalarType, min, max, l10n);
|
||||||
}
|
}
|
||||||
Duo<ResReferenceValue, ResIntValue>[] attrItems = new Duo[items.length
|
Duo<ResReferenceValue, ResIntValue>[] attrItems = new Duo[items.length - i];
|
||||||
- i];
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (; i < items.length; i++) {
|
for (; i < items.length; i++) {
|
||||||
int resId = items[i].m1;
|
int resId = items[i].m1;
|
||||||
pkg.addSynthesizedRes(resId);
|
pkg.addSynthesizedRes(resId);
|
||||||
attrItems[j++] = new Duo<>(
|
attrItems[j++] = new Duo<>(factory.newReference(resId, null), (ResIntValue) items[i].m2);
|
||||||
factory.newReference(resId, null),
|
|
||||||
(ResIntValue) items[i].m2);
|
|
||||||
}
|
}
|
||||||
switch (type & 0xff0000) {
|
switch (type & 0xff0000) {
|
||||||
case TYPE_ENUM:
|
case TYPE_ENUM:
|
||||||
return new ResEnumAttr(parent, scalarType, min, max, l10n,
|
return new ResEnumAttr(parent, scalarType, min, max, l10n, attrItems);
|
||||||
attrItems);
|
|
||||||
case TYPE_FLAGS:
|
case TYPE_FLAGS:
|
||||||
return new ResFlagsAttr(parent, scalarType, min, max, l10n,
|
return new ResFlagsAttr(parent, scalarType, min, max, l10n, attrItems);
|
||||||
attrItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new AndrolibException("Could not decode attr value");
|
throw new AndrolibException("Could not decode attr value");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serializeBody(XmlSerializer serializer, ResResource res)
|
protected void serializeBody(XmlSerializer serializer, ResResource res) throws AndrolibException, IOException {
|
||||||
throws AndrolibException, IOException {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTypeAsString() {
|
protected String getTypeAsString() {
|
||||||
|
@ -25,12 +25,15 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.Raster;
|
import java.awt.image.Raster;
|
||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class Res9patchStreamDecoder implements ResStreamDecoder {
|
public class Res9patchStreamDecoder implements ResStreamDecoder {
|
||||||
@Override
|
@Override
|
||||||
public void decode(InputStream in, OutputStream out)
|
public void decode(InputStream in, OutputStream out) throws AndrolibException {
|
||||||
throws AndrolibException {
|
|
||||||
try {
|
try {
|
||||||
byte[] data = IOUtils.toByteArray(in);
|
byte[] data = IOUtils.toByteArray(in);
|
||||||
|
|
||||||
@ -112,29 +115,29 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
|||||||
|
|
||||||
ImageIO.write(im2, "png", out);
|
ImageIO.write(im2, "png", out);
|
||||||
} catch (IOException | NullPointerException ex) {
|
} catch (IOException | NullPointerException ex) {
|
||||||
|
// In my case this was triggered because a .png file was
|
||||||
|
// containing a html document instead of an image.
|
||||||
|
// This could be more verbose and try to MIME ?
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
} // In my case this was triggered because a .png file was
|
}
|
||||||
// containing a html document instead of an image.
|
|
||||||
// This could be more verbose and try to MIME ?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NinePatch getNinePatch(byte[] data) throws AndrolibException,
|
private NinePatch getNinePatch(byte[] data) throws AndrolibException,
|
||||||
IOException {
|
IOException {
|
||||||
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
|
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
|
||||||
find9patchChunk(di, NP_CHUNK_TYPE);
|
find9patchChunk(di, NP_CHUNK_TYPE);
|
||||||
return NinePatch.decode(di);
|
return NinePatch.decode(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpticalInset getOpticalInset(byte[] data) throws AndrolibException,
|
private OpticalInset getOpticalInset(byte[] data) throws AndrolibException,
|
||||||
IOException {
|
IOException {
|
||||||
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
|
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
|
||||||
find9patchChunk(di, OI_CHUNK_TYPE);
|
find9patchChunk(di, OI_CHUNK_TYPE);
|
||||||
return OpticalInset.decode(di);
|
return OpticalInset.decode(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void find9patchChunk(DataInput di, int magic) throws AndrolibException,
|
private void find9patchChunk(DataInput di, int magic) throws AndrolibException,
|
||||||
IOException {
|
IOException {
|
||||||
di.skipBytes(8);
|
di.skipBytes(8);
|
||||||
while (true) {
|
while (true) {
|
||||||
int size;
|
int size;
|
||||||
@ -195,19 +198,18 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
|||||||
int[] xDivs = di.readIntArray(numXDivs);
|
int[] xDivs = di.readIntArray(numXDivs);
|
||||||
int[] yDivs = di.readIntArray(numYDivs);
|
int[] yDivs = di.readIntArray(numYDivs);
|
||||||
|
|
||||||
return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs,
|
return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs, yDivs);
|
||||||
yDivs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OpticalInset {
|
private static class OpticalInset {
|
||||||
public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom;
|
public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom;
|
||||||
|
|
||||||
public OpticalInset(int layoutBoundsLeft, int layoutBoundsTop,
|
public OpticalInset(int layoutBoundsLeft, int layoutBoundsTop,
|
||||||
int layoutBoundsRight, int layoutBoundsBottom) {
|
int layoutBoundsRight, int layoutBoundsBottom) {
|
||||||
this.layoutBoundsLeft = layoutBoundsLeft;
|
this.layoutBoundsLeft = layoutBoundsLeft;
|
||||||
this.layoutBoundsTop = layoutBoundsTop;
|
this.layoutBoundsTop = layoutBoundsTop;
|
||||||
this.layoutBoundsRight = layoutBoundsRight;
|
this.layoutBoundsRight = layoutBoundsRight;
|
||||||
this.layoutBoundsBottom = layoutBoundsBottom;
|
this.layoutBoundsBottom = layoutBoundsBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +219,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
|||||||
int layoutBoundsRight = Integer.reverseBytes(di.readInt());
|
int layoutBoundsRight = Integer.reverseBytes(di.readInt());
|
||||||
int layoutBoundsBottom = Integer.reverseBytes(di.readInt());
|
int layoutBoundsBottom = Integer.reverseBytes(di.readInt());
|
||||||
return new OpticalInset(layoutBoundsLeft, layoutBoundsTop,
|
return new OpticalInset(layoutBoundsLeft, layoutBoundsTop,
|
||||||
layoutBoundsRight, layoutBoundsBottom);
|
layoutBoundsRight, layoutBoundsBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,8 @@ public class MXSerializer implements XmlSerializer {
|
|||||||
// now check that prefix is still in scope
|
// now check that prefix is still in scope
|
||||||
for (int p = namespaceEnd - 1; p > i; --p) {
|
for (int p = namespaceEnd - 1; p > i; --p) {
|
||||||
if (prefix == namespacePrefix[p]) {
|
if (prefix == namespacePrefix[p]) {
|
||||||
} // too bad - prefix is redeclared with different namespace
|
// too bad - prefix is redeclared with different namespace
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
@ -16,44 +16,60 @@
|
|||||||
*/
|
*/
|
||||||
package brut.directory;
|
package brut.directory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface Directory {
|
public interface Directory {
|
||||||
Set<String> getFiles();
|
Set<String> getFiles();
|
||||||
|
|
||||||
Set<String> getFiles(boolean recursive);
|
Set<String> getFiles(boolean recursive);
|
||||||
|
|
||||||
Map<String, Directory> getDirs();
|
Map<String, Directory> getDirs();
|
||||||
|
|
||||||
Map<String, Directory> getDirs(boolean recursive);
|
Map<String, Directory> getDirs(boolean recursive);
|
||||||
|
|
||||||
boolean containsFile(String path);
|
boolean containsFile(String path);
|
||||||
|
|
||||||
boolean containsDir(String path);
|
boolean containsDir(String path);
|
||||||
|
|
||||||
InputStream getFileInput(String path) throws DirectoryException;
|
InputStream getFileInput(String path) throws DirectoryException;
|
||||||
|
|
||||||
OutputStream getFileOutput(String path) throws DirectoryException;
|
OutputStream getFileOutput(String path) throws DirectoryException;
|
||||||
|
|
||||||
Directory getDir(String path) throws PathNotExist;
|
Directory getDir(String path) throws PathNotExist;
|
||||||
|
|
||||||
Directory createDir(String path) throws DirectoryException;
|
Directory createDir(String path) throws DirectoryException;
|
||||||
|
|
||||||
boolean removeFile(String path);
|
boolean removeFile(String path);
|
||||||
|
|
||||||
void copyToDir(Directory out) throws DirectoryException;
|
void copyToDir(Directory out) throws DirectoryException;
|
||||||
|
|
||||||
void copyToDir(Directory out, String[] fileNames)
|
void copyToDir(Directory out, String[] fileNames)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
|
|
||||||
void copyToDir(Directory out, String fileName)
|
void copyToDir(Directory out, String fileName)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
|
|
||||||
void copyToDir(File out) throws DirectoryException;
|
void copyToDir(File out) throws DirectoryException;
|
||||||
|
|
||||||
void copyToDir(File out, String[] fileNames)
|
void copyToDir(File out, String[] fileNames)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
|
|
||||||
void copyToDir(File out, String fileName)
|
void copyToDir(File out, String fileName)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
|
|
||||||
long getSize(String fileName)
|
long getSize(String fileName)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
long getCompressedSize(String fileName)
|
|
||||||
throws DirectoryException;
|
|
||||||
int getCompressionLevel(String fileName)
|
|
||||||
throws DirectoryException;
|
|
||||||
|
|
||||||
|
long getCompressedSize(String fileName)
|
||||||
|
throws DirectoryException;
|
||||||
|
|
||||||
|
int getCompressionLevel(String fileName)
|
||||||
|
throws DirectoryException;
|
||||||
|
|
||||||
void close() throws IOException;
|
void close() throws IOException;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user