Reformat & Rearrange

This commit is contained in:
Goooler 2021-08-27 01:25:11 +08:00
parent 7ff89c4f44
commit c3e8be3e8a
6 changed files with 82 additions and 77 deletions

View File

@ -15,9 +15,8 @@
*/
package android.content.res;
import org.xmlpull.v1.XmlPullParser;
import android.util.AttributeSet;
import org.xmlpull.v1.XmlPullParser;
/**
* 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.
*/
public interface XmlResourceParser extends XmlPullParser, AttributeSet {
/**
* Close this interface to the resource. Calls on the interface are no
* longer value after this call.
*/
/**
* Close this interface to the resource. Calls on the interface are no
* longer value after this call.
*/
void close();
}

View File

@ -16,58 +16,52 @@
package android.util;
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,
String[] options, int defaultValue);
int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue);
boolean getAttributeBooleanValue(String namespace, String attribute,
boolean defaultValue);
boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue);
int getAttributeResourceValue(String namespace, String attribute,
int defaultValue);
int getAttributeResourceValue(String namespace, String attribute, int defaultValue);
int getAttributeIntValue(String namespace, String attribute,
int defaultValue);
int getAttributeIntValue(String namespace, String attribute, int defaultValue);
int getAttributeUnsignedIntValue(String namespace, String attribute,
int defaultValue);
int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue);
float getAttributeFloatValue(String namespace, String attribute,
float defaultValue);
float getAttributeFloatValue(String namespace, String attribute, float defaultValue);
// TODO: remove
int getAttributeValueType(int index);
// TODO: remove
int getAttributeValueType(int index);
int getAttributeValueData(int index);
int getAttributeValueData(int index);
}

View File

@ -35,14 +35,13 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable {
mL10n = l10n;
}
public String convertToResXmlFormat(ResScalarValue value)
throws AndrolibException {
public String convertToResXmlFormat(ResScalarValue value) throws AndrolibException {
return null;
}
@Override
public void serializeToResValuesXml(XmlSerializer serializer,
ResResource res) throws IOException, AndrolibException {
public void serializeToResValuesXml(XmlSerializer serializer, ResResource res)
throws IOException, AndrolibException {
String type = getTypeAsString();
serializer.startTag(null, "attr");
@ -90,30 +89,24 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable {
if (i == items.length) {
return new ResAttr(parent, scalarType, min, max, l10n);
}
Duo<ResReferenceValue, ResIntValue>[] attrItems = new Duo[items.length
- i];
Duo<ResReferenceValue, ResIntValue>[] attrItems = new Duo[items.length - i];
int j = 0;
for (; i < items.length; i++) {
int resId = items[i].m1;
pkg.addSynthesizedRes(resId);
attrItems[j++] = new Duo<>(
factory.newReference(resId, null),
(ResIntValue) items[i].m2);
attrItems[j++] = new Duo<>(factory.newReference(resId, null), (ResIntValue) items[i].m2);
}
switch (type & 0xff0000) {
case TYPE_ENUM:
return new ResEnumAttr(parent, scalarType, min, max, l10n,
attrItems);
return new ResEnumAttr(parent, scalarType, min, max, l10n, attrItems);
case TYPE_FLAGS:
return new ResFlagsAttr(parent, scalarType, min, max, l10n,
attrItems);
return new ResFlagsAttr(parent, scalarType, min, max, l10n, attrItems);
}
throw new AndrolibException("Could not decode attr value");
}
protected void serializeBody(XmlSerializer serializer, ResResource res)
throws AndrolibException, IOException {
protected void serializeBody(XmlSerializer serializer, ResResource res) throws AndrolibException, IOException {
}
protected String getTypeAsString() {

View File

@ -25,12 +25,15 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
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 {
@Override
public void decode(InputStream in, OutputStream out)
throws AndrolibException {
public void decode(InputStream in, OutputStream out) throws AndrolibException {
try {
byte[] data = IOUtils.toByteArray(in);
@ -112,29 +115,29 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
ImageIO.write(im2, "png", out);
} 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);
} // 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,
IOException {
IOException {
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
find9patchChunk(di, NP_CHUNK_TYPE);
return NinePatch.decode(di);
}
private OpticalInset getOpticalInset(byte[] data) throws AndrolibException,
IOException {
IOException {
ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data));
find9patchChunk(di, OI_CHUNK_TYPE);
return OpticalInset.decode(di);
}
private void find9patchChunk(DataInput di, int magic) throws AndrolibException,
IOException {
IOException {
di.skipBytes(8);
while (true) {
int size;
@ -195,19 +198,18 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
int[] xDivs = di.readIntArray(numXDivs);
int[] yDivs = di.readIntArray(numYDivs);
return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs,
yDivs);
return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs, yDivs);
}
}
private static class OpticalInset {
public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom;
public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom;
public OpticalInset(int layoutBoundsLeft, int layoutBoundsTop,
int layoutBoundsRight, int layoutBoundsBottom) {
this.layoutBoundsLeft = layoutBoundsLeft;
this.layoutBoundsTop = layoutBoundsTop;
this.layoutBoundsRight = layoutBoundsRight;
int layoutBoundsRight, int layoutBoundsBottom) {
this.layoutBoundsLeft = layoutBoundsLeft;
this.layoutBoundsTop = layoutBoundsTop;
this.layoutBoundsRight = layoutBoundsRight;
this.layoutBoundsBottom = layoutBoundsBottom;
}
@ -217,7 +219,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
int layoutBoundsRight = Integer.reverseBytes(di.readInt());
int layoutBoundsBottom = Integer.reverseBytes(di.readInt());
return new OpticalInset(layoutBoundsLeft, layoutBoundsTop,
layoutBoundsRight, layoutBoundsBottom);
layoutBoundsRight, layoutBoundsBottom);
}
}
}

View File

@ -468,7 +468,8 @@ public class MXSerializer implements XmlSerializer {
// now check that prefix is still in scope
for (int p = namespaceEnd - 1; p > i; --p) {
if (prefix == namespacePrefix[p]) {
} // too bad - prefix is redeclared with different namespace
// too bad - prefix is redeclared with different namespace
}
}
return prefix;
}

View File

@ -16,44 +16,60 @@
*/
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.Set;
public interface Directory {
Set<String> getFiles();
Set<String> getFiles(boolean recursive);
Map<String, Directory> getDirs();
Map<String, Directory> getDirs(boolean recursive);
boolean containsFile(String path);
boolean containsDir(String path);
InputStream getFileInput(String path) throws DirectoryException;
OutputStream getFileOutput(String path) throws DirectoryException;
Directory getDir(String path) throws PathNotExist;
Directory createDir(String path) throws DirectoryException;
boolean removeFile(String path);
void copyToDir(Directory out) throws DirectoryException;
void copyToDir(Directory out, String[] fileNames)
throws DirectoryException;
void copyToDir(Directory out, String fileName)
throws DirectoryException;
void copyToDir(File out) throws DirectoryException;
void copyToDir(File out, String[] fileNames)
throws DirectoryException;
void copyToDir(File out, String fileName)
throws DirectoryException;
long getSize(String fileName)
throws DirectoryException;
long getCompressedSize(String fileName)
throws DirectoryException;
int getCompressionLevel(String fileName)
throws DirectoryException;
throws DirectoryException;
long getCompressedSize(String fileName)
throws DirectoryException;
int getCompressionLevel(String fileName)
throws DirectoryException;
void close() throws IOException;