working on force fix for string-array with @string in it

This commit is contained in:
Connor Tumbleson 2012-08-26 23:25:08 -05:00
parent 62b2e6a03c
commit 036cce8df1
2 changed files with 17 additions and 17 deletions

View File

@ -22,11 +22,13 @@ import brut.androlib.res.xml.ResValuesXmlSerializable;
import brut.util.Duo;
import java.io.IOException;
import org.xmlpull.v1.XmlSerializer;
import org.apache.commons.lang3.StringUtils;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializable {
private String mRawItems;
ResArrayValue(ResReferenceValue parent,
Duo<Integer, ResScalarValue>[] items) {
super(parent);
@ -58,32 +60,26 @@ public class ResArrayValue extends ResBagValue implements ResValuesXmlSerializab
serializer.endTag(null, type);
}
public String getType() {
public String getType() throws AndrolibException {
if (mItems.length == 0) {
return null;
}
String type = mItems[0].getType();
if (! "string".equals(type) && ! "integer".equals(type)) {
if (!"string".equals(type) && !"integer".equals(type)) {
return null;
}
boolean hasDifferentTypeItem = false;
for (int i = 1; i < mItems.length; i++) {
String itemType = mItems[i].getType();
if (itemType.equals("string")) {
//If there is at least one string item in mixed bag, it must be string-array.
return "string";
} else if (!type.equals(itemType)) {
hasDifferentTypeItem = true;
if (StringUtils.containsIgnoreCase("@string", mItems[i].encodeAsResXmlItemValue()) || mItems[i].getType().equalsIgnoreCase("string")) {
return "string";
}
if (!type.equals(mItems[i].getType())) {
return null;
}
}
if (hasDifferentTypeItem) {
return null;
}
return type;
}

View File

@ -20,4 +20,8 @@
<item>10.0sp</item>
<item>#ff123456</item>
</array>
<string-array name="test_array4">
<item>@string/test_string1</item>
<item>@string/test_string2</item>
</string-array>
</resources>