working on adding new plurals fix thanks to @miuirussia

This commit is contained in:
Connor Tumbleson 2012-07-25 09:57:05 -05:00
parent 1e78f27dbd
commit 6f9b83d196
4 changed files with 38 additions and 7 deletions

View File

@ -49,6 +49,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>apktool-lib</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-lang3</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>common</artifactId>
@ -62,5 +68,11 @@
<version>1.3.4-ibot7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<type>jar</type>
</dependency>
</dependencies>
</project>

View File

@ -65,6 +65,11 @@
</build>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>brut.j</groupId>
<artifactId>dir</artifactId>

View File

@ -16,12 +16,13 @@
package brut.androlib.res.data.value;
import brut.androlib.res.xml.ResValuesXmlSerializable;
import brut.androlib.res.xml.ResXmlEncoders;
import brut.androlib.AndrolibException;
import brut.androlib.res.data.ResResource;
import brut.androlib.res.xml.ResValuesXmlSerializable;
import brut.androlib.res.xml.ResXmlEncoders;
import brut.util.Duo;
import java.io.IOException;
import org.apache.commons.lang.StringUtils;
import org.xmlpull.v1.XmlSerializer;
/**
@ -49,9 +50,21 @@ public class ResPluralsValue extends ResBagValue implements ResValuesXmlSerializ
if (item == null) {
continue;
}
ResScalarValue rawValue = item;
serializer.startTag(null, "item");
serializer.attribute(null, "quantity", QUANTITY_MAP[i]);
serializer.text(item.encodeAsResXmlValue());
if (ResXmlEncoders.hasMultipleNonPositionalSubstitutions(rawValue.encodeAsResXmlValue())) {
serializer.text(item.encodeAsResXmlValueExt());
} else {
String recode = item.encodeAsResXmlValue();
//Dirty, but working fix @miuirussia
for (int j = 0; j < 10; j++) {
recode = StringUtils.replace(recode, "%" + Integer.toString(j) + "$" + Integer.toString(j) + "$", "%" + Integer.toString(j) + "$");
}
serializer.text(recode);
}
serializer.endTag(null, "item");
}
serializer.endTag(null, "plurals");

View File

@ -52,7 +52,7 @@ public abstract class ResScalarValue extends ResValue
if (mRawValue != null) {
return mRawValue;
}
return encodeAsResXml();
return encodeAsResXmlValueExt();
}
public String encodeAsResXmlValueExt() throws AndrolibException {
@ -90,15 +90,16 @@ public abstract class ResScalarValue extends ResValue
public void serializeToResValuesXml(XmlSerializer serializer, ResResource res)
throws IOException, AndrolibException {
String type = res.getResSpec().getType().getName();
boolean item = ! "reference".equals(mType) && ! type.equals(mType);
boolean item = !"reference".equals(mType) && !type.equals(mType);
String body = encodeAsResXmlValue();
/* check for resource reference */
if (body.contains("@")){
// item = true;
// messes up strings with @, need to check if strings.xml ignore
if(!res.getFilePath().contains("string")) {
item = true;
}
}
/* check for using attrib as node or item */