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

View File

@ -48,23 +48,17 @@ public interface AttributeSet {
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);

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,11 +115,11 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
ImageIO.write(im2, "png", out);
} catch (IOException | NullPointerException ex) {
throw new AndrolibException(ex);
} // In my case this was triggered because a .png file was
// 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);
}
}
private NinePatch getNinePatch(byte[] data) throws AndrolibException,
@ -195,8 +198,7 @@ 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);
}
}

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,45 +16,61 @@
*/
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;
void close() throws IOException;
char separator = '/';