fix(res): fixes ns value (PR #1029)
* Fixes ns value * fix formatting Co-authored-by: bagipro <bugi@MacBook-Pro.local> Co-authored-by: Skylot <skylot@gmail.com>
This commit is contained in:
@@ -313,17 +313,23 @@ public class BinaryXMLParser extends CommonBinaryParser {
|
||||
}
|
||||
|
||||
private String generateNameForNS(String attrUrl) {
|
||||
for (int i = 1;; i++) {
|
||||
String attrName = "ns" + i;
|
||||
if (!nsMap.containsValue(attrName) && !nsMapGenerated.contains(attrName)) {
|
||||
nsMapGenerated.add(attrName);
|
||||
// do not add generated value to nsMap
|
||||
// because attrUrl might be used in a neighbor element, but never defined
|
||||
writer.add("xmlns:").add(attrName)
|
||||
.add("=\"").add(attrUrl).add("\" ");
|
||||
return attrName;
|
||||
String attrName;
|
||||
if (ANDROID_NS_URL.equals(attrUrl)) {
|
||||
attrName = ANDROID_NS_VALUE;
|
||||
nsMap.put(ANDROID_NS_URL, attrName);
|
||||
} else {
|
||||
for (int i = 1;; i++) {
|
||||
attrName = "ns" + i;
|
||||
if (!nsMapGenerated.contains(attrName) && !nsMap.containsValue(attrName)) {
|
||||
nsMapGenerated.add(attrName);
|
||||
// do not add generated value to nsMap
|
||||
// because attrUrl might be used in a neighbor element, but never defined
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.add("xmlns:").add(attrName).add("=\"").add(attrUrl).add("\" ");
|
||||
return attrName;
|
||||
}
|
||||
|
||||
private String getAttributeName(int id) {
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ParserConstants {
|
||||
}
|
||||
|
||||
protected static final String ANDROID_NS_URL = "http://schemas.android.com/apk/res/android";
|
||||
protected static final String ANDROID_NS_VALUE = "android";
|
||||
|
||||
/**
|
||||
* Chunk types
|
||||
|
||||
Reference in New Issue
Block a user