Skip to content

Commit

Permalink
Adapt null resource to be treated as reference instead of empty strin…
Browse files Browse the repository at this point in the history
…g. (#3417)

* fix: handle null resolved items as references

* test: add color null test for aapt2
  • Loading branch information
iBotPeaches committed Nov 3, 2023
1 parent 63b1976 commit eec0288
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public ResValueFactory(ResPackage package_) {
public ResScalarValue factory(int type, int value, String rawValue) throws AndrolibException {
switch (type) {
case TypedValue.TYPE_NULL:
if (value == TypedValue.DATA_NULL_UNDEFINED) { // Special case $empty as explicitly defined empty value
return new ResStringValue(null, value);
} else if (value == TypedValue.DATA_NULL_EMPTY) {
if (value == TypedValue.DATA_NULL_EMPTY) {
return new ResEmptyValue(value, rawValue, type);
}
return new ResReferenceValue(mPackage, 0, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void buildAndDecodeTest() {
assertTrue(sTestNewDir.isDirectory());
}

@Test
public void valuesColorsTest() throws BrutException {
compareValuesFiles("values/colors.xml");
}

@Test
public void valuesStringsTest() throws BrutException {
compareValuesFiles("values/strings.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="test_color1">#ff123456</color>
<color name="test_color2">@android:color/white</color>
<color name="test_color3">#00000000</color>
<color name="issue_3416">@null</color>
</resources>

0 comments on commit eec0288

Please sign in to comment.