mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-03 15:24:26 +02: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());
|
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||||
for (int i = 0; i < mItems.length; i++) {
|
for (int i = 0; i < mItems.length; i++) {
|
||||||
serializer.startTag(null, "item");
|
serializer.startTag(null, "item");
|
||||||
serializer.text(mItems[i].toResXmlFormat());
|
serializer.text(mItems[i].encodeAsResXmlValue());
|
||||||
serializer.endTag(null, "item");
|
serializer.endTag(null, "item");
|
||||||
}
|
}
|
||||||
serializer.endTag(null, type);
|
serializer.endTag(null, type);
|
||||||
|
@ -31,8 +31,7 @@ public class ResBoolValue extends ResScalarValue {
|
|||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected String encodeAsResXml() {
|
||||||
public String toResXmlFormat() {
|
|
||||||
return mValue ? "true" : "false";
|
return mValue ? "true" : "false";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class ResColorValue extends ResIntValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toResXmlFormat() {
|
protected String encodeAsResXml() {
|
||||||
return String.format("#%08x", mValue);
|
return String.format("#%08x", mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class ResDimenValue extends ResIntValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toResXmlFormat() throws AndrolibException {
|
protected String encodeAsResXml() throws AndrolibException {
|
||||||
return TypedValue.coerceToString(TypedValue.TYPE_DIMENSION, mValue);
|
return TypedValue.coerceToString(TypedValue.TYPE_DIMENSION, mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ public class ResFloatValue extends ResScalarValue {
|
|||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected String encodeAsResXml() {
|
||||||
public String toResXmlFormat() {
|
|
||||||
return String.valueOf(mValue);
|
return String.valueOf(mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class ResFractionValue extends ResIntValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toResXmlFormat() throws AndrolibException {
|
protected String encodeAsResXml() throws AndrolibException {
|
||||||
return TypedValue.coerceToString(TypedValue.TYPE_FRACTION, mValue);
|
return TypedValue.coerceToString(TypedValue.TYPE_FRACTION, mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,7 @@ public class ResIntValue extends ResScalarValue {
|
|||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected String encodeAsResXml() throws AndrolibException {
|
||||||
public String toResXmlFormat() throws AndrolibException {
|
|
||||||
return String.valueOf(mValue);
|
return String.valueOf(mValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class ResPluralsValue extends ResBagValue implements ResValuesXmlSerializ
|
|||||||
mItems = new String[6];
|
mItems = new String[6];
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
mItems[items[i].m1 - BAG_KEY_PLURALS_START] =
|
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;
|
mTheme = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected String encodeAsResXml() throws AndrolibException {
|
||||||
public String toResXmlFormat() throws AndrolibException {
|
|
||||||
if (isNull()) {
|
if (isNull()) {
|
||||||
return "@null";
|
return "@null";
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,13 @@ public abstract class ResScalarValue extends ResValue
|
|||||||
mRawValue = rawValue;
|
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)
|
public void serializeToResValuesXml(XmlSerializer serializer, ResResource res)
|
||||||
throws IOException, AndrolibException {
|
throws IOException, AndrolibException {
|
||||||
@ -49,7 +55,7 @@ public abstract class ResScalarValue extends ResValue
|
|||||||
}
|
}
|
||||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||||
|
|
||||||
String body = toResXmlFormat();
|
String body = encodeAsResXmlValue();
|
||||||
if (! body.isEmpty()) {
|
if (! body.isEmpty()) {
|
||||||
serializer.ignorableWhitespace(body);
|
serializer.ignorableWhitespace(body);
|
||||||
}
|
}
|
||||||
@ -60,4 +66,6 @@ public abstract class ResScalarValue extends ResValue
|
|||||||
public String getType() {
|
public String getType() {
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract String encodeAsResXml() throws AndrolibException;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package brut.androlib.res.data.value;
|
package brut.androlib.res.data.value;
|
||||||
|
|
||||||
|
import brut.androlib.AndrolibException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
@ -30,12 +31,18 @@ public class ResStringValue extends ResScalarValue {
|
|||||||
super(type, value);
|
super(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
@Override
|
||||||
|
public String encodeAsResXmlAttr() {
|
||||||
return mRawValue;
|
return mRawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toResXmlFormat() {
|
public String encodeAsResXmlValue() {
|
||||||
return mRawValue;
|
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.startTag(null, "style");
|
||||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||||
if (! mParent.isNull()) {
|
if (! mParent.isNull()) {
|
||||||
serializer.attribute(null, "parent", mParent.toResXmlFormat());
|
serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < mItems.length; i++) {
|
for (int i = 0; i < mItems.length; i++) {
|
||||||
ResResSpec spec = mItems[i].m1.getReferent();
|
ResResSpec spec = mItems[i].m1.getReferent();
|
||||||
@ -52,7 +52,7 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
|||||||
String value = attr.convertToResXmlFormat(mItems[i].m2);
|
String value = attr.convertToResXmlFormat(mItems[i].m2);
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
value = mItems[i].m2.toResXmlFormat();
|
value = mItems[i].m2.encodeAsResXmlValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -37,7 +37,7 @@ public class ResAttrDecoder {
|
|||||||
decoded = attr.convertToResXmlFormat(resValue);
|
decoded = attr.convertToResXmlFormat(resValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return decoded != null ? decoded : resValue.toResXmlFormat();
|
return decoded != null ? decoded : resValue.encodeAsResXmlAttr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResPackage getCurrentPackage() throws AndrolibException {
|
public ResPackage getCurrentPackage() throws AndrolibException {
|
||||||
|
@ -22,5 +22,6 @@ import brut.androlib.AndrolibException;
|
|||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
*/
|
*/
|
||||||
public interface ResXmlEncodable {
|
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