aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/xml
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-01-10 13:10:47 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-10 13:12:55 -0800
commitee28bc3a15a7eeeccf21b39b3d307b64ae8acee4 (patch)
tree744dd777fafa131fe1d644da0b5d4a4637fd9c03 /src/tools/android/java/com/google/devtools/build/android/xml
parentea41dc4f5179533c3c54a786848157cc17dccac2 (diff)
Fix parsing for some aapt2-generated resources.
RELNOTES: none PiperOrigin-RevId: 181506851
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/xml')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java3
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java14
2 files changed, 9 insertions, 8 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
index 9b9285621a..cab46c7186 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
@@ -258,7 +258,8 @@ public class SimpleXmlResourceValue implements XmlResourceValue {
} else if (resourceType == ResourceType.BOOL && item.hasPrim()) {
stringValue = item.getPrim().getData() == 0 ? "false" : "true";
} else if (resourceType == ResourceType.FRACTION
- || resourceType == ResourceType.DIMEN) {
+ || resourceType == ResourceType.DIMEN
+ || resourceType == ResourceType.STRING) {
stringValue = Integer.toString(item.getPrim().getData());
} else {
throw new IllegalArgumentException(
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
index 0f6369d68b..5cd0f6e0a5 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
@@ -75,11 +75,6 @@ public class StyleXmlResourceValue implements XmlResourceValue {
return of(proto.hasValue() ? proto.getValue() : null, proto.getMappedStringValue());
}
- private StyleXmlResourceValue(@Nullable String parent, ImmutableMap<String, String> values) {
- this.parent = parent;
- this.values = values;
- }
-
public static XmlResourceValue from(Value proto) {
Style style = proto.getCompoundValue().getStyle();
String parent = "";
@@ -87,7 +82,7 @@ public class StyleXmlResourceValue implements XmlResourceValue {
if (style.hasParent()) {
parent = proto.getCompoundValue().getStyle().getParent().getName();
if (parent.startsWith("style/")) {
- //Aapt2 compile breaks when style parent references are prepended with 'style/'
+ // Aapt2 compile breaks when style parent references are prepended with 'style/'
parent = parent.substring(6);
}
}
@@ -97,6 +92,11 @@ public class StyleXmlResourceValue implements XmlResourceValue {
return of(parent, items);
}
+ private StyleXmlResourceValue(@Nullable String parent, ImmutableMap<String, String> values) {
+ this.parent = parent;
+ this.values = values;
+ }
+
private static Map<String, String> itemMapFromProto(Style style) {
Map<String, String> result = new HashMap<>();
@@ -112,7 +112,7 @@ public class StyleXmlResourceValue implements XmlResourceValue {
itemValue = "@null";
}
} else {
- throw new IllegalArgumentException("Could not parse item value from Style resource.");
+ itemValue = styleEntry.getItem().getStr().getValue();
}
result.put(itemName, itemValue);
}