mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
working on force fix for string-array with @string in it
This commit is contained in:
parent
62b2e6a03c
commit
036cce8df1
@ -22,11 +22,13 @@ import brut.androlib.res.xml.ResValuesXmlSerializable;
|
|||||||
import brut.util.Duo;
|
import brut.util.Duo;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializable {
|
public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializable {
|
||||||
|
private String mRawItems;
|
||||||
ResArrayValue(ResReferenceValue parent,
|
ResArrayValue(ResReferenceValue parent,
|
||||||
Duo<Integer, ResScalarValue>[] items) {
|
Duo<Integer, ResScalarValue>[] items) {
|
||||||
super(parent);
|
super(parent);
|
||||||
@ -58,32 +60,26 @@ public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializab
|
|||||||
serializer.endTag(null, type);
|
serializer.endTag(null, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() throws AndrolibException {
|
||||||
if (mItems.length == 0) {
|
if (mItems.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String type = mItems[0].getType();
|
String type = mItems[0].getType();
|
||||||
if (! "string".equals(type) && ! "integer".equals(type)) {
|
if (!"string".equals(type) && !"integer".equals(type)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasDifferentTypeItem = false;
|
|
||||||
|
|
||||||
for (int i = 1; i < mItems.length; i++) {
|
for (int i = 1; i < mItems.length; i++) {
|
||||||
String itemType = mItems[i].getType();
|
|
||||||
|
if (StringUtils.containsIgnoreCase("@string", mItems[i].encodeAsResXmlItemValue()) || mItems[i].getType().equalsIgnoreCase("string")) {
|
||||||
if (itemType.equals("string")) {
|
return "string";
|
||||||
//If there is at least one string item in mixed bag, it must be string-array.
|
}
|
||||||
return "string";
|
|
||||||
} else if (!type.equals(itemType)) {
|
if (!type.equals(mItems[i].getType())) {
|
||||||
hasDifferentTypeItem = true;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDifferentTypeItem) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,4 +20,8 @@
|
|||||||
<item>10.0sp</item>
|
<item>10.0sp</item>
|
||||||
<item>#ff123456</item>
|
<item>#ff123456</item>
|
||||||
</array>
|
</array>
|
||||||
|
<string-array name="test_array4">
|
||||||
|
<item>@string/test_string1</item>
|
||||||
|
<item>@string/test_string2</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user