mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-21 01:07:34 +01:00
ResXmlEncodable: splitted toResXmlFormat() into 2 methods: encodeAsResXmlAttr() and encodeAsResXmlValue().
This commit is contained in:
parent
b3866d034d
commit
31274e73dc
@ -51,7 +51,7 @@ public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||
for (int i = 0; i < mItems.length; i++) {
|
||||
serializer.startTag(null, "item");
|
||||
serializer.text(mItems[i].toResXmlFormat());
|
||||
serializer.text(mItems[i].encodeAsResXmlValue());
|
||||
serializer.endTag(null, "item");
|
||||
}
|
||||
serializer.endTag(null, type);
|
||||
|
@ -31,8 +31,7 @@ public class ResBoolValue extends ResScalarValue {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() {
|
||||
protected String encodeAsResXml() {
|
||||
return mValue ? "true" : "false";
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class ResColorValue extends ResIntValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() {
|
||||
protected String encodeAsResXml() {
|
||||
return String.format("#%08x", mValue);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class ResDimenValue extends ResIntValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() throws AndrolibException {
|
||||
protected String encodeAsResXml() throws AndrolibException {
|
||||
return TypedValue.coerceToString(TypedValue.TYPE_DIMENSION, mValue);
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ public class ResFloatValue extends ResScalarValue {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() {
|
||||
protected String encodeAsResXml() {
|
||||
return String.valueOf(mValue);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class ResFractionValue extends ResIntValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() throws AndrolibException {
|
||||
protected String encodeAsResXml() throws AndrolibException {
|
||||
return TypedValue.coerceToString(TypedValue.TYPE_FRACTION, mValue);
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ public class ResIntValue extends ResScalarValue {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() throws AndrolibException {
|
||||
protected String encodeAsResXml() throws AndrolibException {
|
||||
return String.valueOf(mValue);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class ResPluralsValue extends ResBagValue implements ResValuesXmlSerializ
|
||||
mItems = new String[6];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
mItems[items[i].m1 - BAG_KEY_PLURALS_START] =
|
||||
((ResStringValue) items[i].m2).toResXmlFormat();
|
||||
((ResStringValue) items[i].m2).encodeAsResXmlValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,7 @@ public class ResReferenceValue extends ResIntValue {
|
||||
mTheme = theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() throws AndrolibException {
|
||||
protected String encodeAsResXml() throws AndrolibException {
|
||||
if (isNull()) {
|
||||
return "@null";
|
||||
}
|
||||
|
@ -35,7 +35,13 @@ public abstract class ResScalarValue extends ResValue
|
||||
mRawValue = rawValue;
|
||||
}
|
||||
|
||||
public abstract String toResXmlFormat() throws AndrolibException;
|
||||
public String encodeAsResXmlAttr() throws AndrolibException {
|
||||
return encodeAsResXml();
|
||||
}
|
||||
|
||||
public String encodeAsResXmlValue() throws AndrolibException {
|
||||
return encodeAsResXml();
|
||||
}
|
||||
|
||||
public void serializeToResValuesXml(XmlSerializer serializer, ResResource res)
|
||||
throws IOException, AndrolibException {
|
||||
@ -49,7 +55,7 @@ public abstract class ResScalarValue extends ResValue
|
||||
}
|
||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||
|
||||
String body = toResXmlFormat();
|
||||
String body = encodeAsResXmlValue();
|
||||
if (! body.isEmpty()) {
|
||||
serializer.ignorableWhitespace(body);
|
||||
}
|
||||
@ -60,4 +66,6 @@ public abstract class ResScalarValue extends ResValue
|
||||
public String getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
protected abstract String encodeAsResXml() throws AndrolibException;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package brut.androlib.res.data.value;
|
||||
|
||||
import brut.androlib.AndrolibException;
|
||||
|
||||
/**
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
@ -30,12 +31,18 @@ public class ResStringValue extends ResScalarValue {
|
||||
super(type, value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
@Override
|
||||
public String encodeAsResXmlAttr() {
|
||||
return mRawValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toResXmlFormat() {
|
||||
public String encodeAsResXmlValue() {
|
||||
return mRawValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String encodeAsResXml() throws AndrolibException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
serializer.startTag(null, "style");
|
||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||
if (! mParent.isNull()) {
|
||||
serializer.attribute(null, "parent", mParent.toResXmlFormat());
|
||||
serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr());
|
||||
}
|
||||
for (int i = 0; i < mItems.length; i++) {
|
||||
ResResSpec spec = mItems[i].m1.getReferent();
|
||||
@ -52,7 +52,7 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
String value = attr.convertToResXmlFormat(mItems[i].m2);
|
||||
|
||||
if (value == null) {
|
||||
value = mItems[i].m2.toResXmlFormat();
|
||||
value = mItems[i].m2.encodeAsResXmlValue();
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
|
@ -37,7 +37,7 @@ public class ResAttrDecoder {
|
||||
decoded = attr.convertToResXmlFormat(resValue);
|
||||
}
|
||||
|
||||
return decoded != null ? decoded : resValue.toResXmlFormat();
|
||||
return decoded != null ? decoded : resValue.encodeAsResXmlAttr();
|
||||
}
|
||||
|
||||
public ResPackage getCurrentPackage() throws AndrolibException {
|
||||
|
@ -22,5 +22,6 @@ import brut.androlib.AndrolibException;
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*/
|
||||
public interface ResXmlEncodable {
|
||||
public String toResXmlFormat() throws AndrolibException;
|
||||
public String encodeAsResXmlAttr() throws AndrolibException;
|
||||
public String encodeAsResXmlValue() throws AndrolibException;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user