Handle strings with style index at end of string

This commit is contained in:
Connor Tumbleson 2017-05-19 09:28:44 -04:00
parent e1f7ac355e
commit 390ecae6c5
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75
2 changed files with 19 additions and 0 deletions

View File

@ -139,6 +139,7 @@ public class StringBlock {
StringBuilder html = new StringBuilder(raw.length() + 32);
int[] opened = new int[style.length / 3];
int offset = 0, depth = 0;
boolean closeTagOnEnd = false;
while (true) {
int i = -1, j;
for (j = 0; j != style.length; j += 3) {
@ -154,6 +155,9 @@ public class StringBlock {
int last = opened[j];
int end = style[last + 2];
if (end >= start) {
if (style[last + 1] == -1 && end != -1) {
closeTagOnEnd = true;
}
break;
}
if (offset <= end) {
@ -165,6 +169,11 @@ public class StringBlock {
depth = j + 1;
if (offset < start) {
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, start)));
if (closeTagOnEnd) {
if (j > 0) {
outputStyleTag(getString(style[opened[j]]), html, true);
}
}
offset = start;
}
if (i == -1) {

View File

@ -31,4 +31,14 @@ bar"</string>
<string name="test_string29" formatted="false">category=temp%temp%foo</string>
<string name="test_string30">res/foo/</string>
<string name="test_string31">res/foo</string>
<string name="test_string32">[<font size="17">TEST STRING</font>]</string>
<string name="test_string33"><font size="17">[TEST STRING]</font></string>
<string name="test_string34">[<font size="17">TEST STRING]</font></string>
<string name="test_string35"><font size="17">[TEST STRING</font>]</string>
<string name="test_string36"><font size="17">TEST STRING</font></string>
<string name="test_string37">[<font size="17">Ţåþ ţö ţýþé þåššŵöŕð one two three]</font></string>
<string name="test_string38">[<font size="17">Ţåþ ţö ţýþé þåššŵöŕð one two three</font>]</string>
<string name="test_string39"><font size="17">[Ţåþ ţö ţýþé þåššŵöŕð one two three</font>]</string>
<string name="test_string40">[<font size="17">]Ţåþ ţö ţýþé þåššŵöŕð one two three</font></string>
<string name="test_string41"><font size="17">[Ţåþ ţö ţýþé þåššŵöŕð one two three]</font></string>
</resources>