mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 10:35:52 +01:00
ResXmlEncoders +hasMultipleNonPositionalSubstitutions() +enumerateNonPositionalSubstitutions() .
This commit is contained in:
parent
19b5e2726a
commit
265ee7ceac
@ -53,15 +53,8 @@ public class ResStringValue extends ResScalarValue {
|
|||||||
@Override
|
@Override
|
||||||
protected void serializeExtraXmlAttrs(XmlSerializer serializer,
|
protected void serializeExtraXmlAttrs(XmlSerializer serializer,
|
||||||
ResResource res) throws IOException {
|
ResResource res) throws IOException {
|
||||||
int pos = 0;
|
if (ResXmlEncoders.hasMultipleNonPositionalSubstitutions(mRawValue)) {
|
||||||
int count = 0;
|
serializer.attribute(null, "formatted", "false");
|
||||||
while((pos = mRawValue.indexOf('%', pos)) != -1) {
|
|
||||||
if (mRawValue.charAt(pos + 1) != '%') {
|
|
||||||
if (++count >= 2) {
|
|
||||||
serializer.attribute(null, "formatted", "false");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,38 @@ public final class ResXmlEncoders {
|
|||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasMultipleNonPositionalSubstitutions(String str) {
|
||||||
|
int pos = 0;
|
||||||
|
int count = 0;
|
||||||
|
while((pos = str.indexOf('%', pos)) != -1) {
|
||||||
|
if (str.charAt(pos + 1) != '%') {
|
||||||
|
if (++count >= 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pos += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String enumerateNonPositionalSubstitutions(String str) {
|
||||||
|
StringBuilder out = new StringBuilder(str);
|
||||||
|
int pos = 0;
|
||||||
|
int count = 0;
|
||||||
|
int offset = 0;
|
||||||
|
while((pos = str.indexOf('%', pos)) != -1) {
|
||||||
|
if (str.charAt(pos + 1) != '%') {
|
||||||
|
count++;
|
||||||
|
out.insert(pos + offset + 1, String.valueOf(count) + "$");
|
||||||
|
offset += 2;
|
||||||
|
}
|
||||||
|
pos += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isPrintableChar(char c) {
|
private static boolean isPrintableChar(char c) {
|
||||||
Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
|
Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
|
||||||
return !Character.isISOControl(c)
|
return !Character.isISOControl(c)
|
||||||
|
Loading…
Reference in New Issue
Block a user