mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 10:35:52 +01:00
ResEnumAttr: added support for many enum names with same int value.
This commit is contained in:
parent
a85eff1aef
commit
db439f2b8c
@ -34,11 +34,7 @@ public class ResEnumAttr extends ResAttr {
|
|||||||
ResEnumAttr(ResReferenceValue parent, int type, Integer min, Integer max,
|
ResEnumAttr(ResReferenceValue parent, int type, Integer min, Integer max,
|
||||||
Boolean l10n, Duo<ResReferenceValue, ResIntValue>[] items) {
|
Boolean l10n, Duo<ResReferenceValue, ResIntValue>[] items) {
|
||||||
super(parent, type, min, max, l10n);
|
super(parent, type, min, max, l10n);
|
||||||
|
mItems = items;
|
||||||
mItems = new LinkedHashMap<Integer, ResReferenceValue>();
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
mItems.put(items[i].m2.getValue(), items[i].m1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,9 +52,11 @@ public class ResEnumAttr extends ResAttr {
|
|||||||
@Override
|
@Override
|
||||||
protected void serializeBody(XmlSerializer serializer, ResResource res)
|
protected void serializeBody(XmlSerializer serializer, ResResource res)
|
||||||
throws AndrolibException, IOException {
|
throws AndrolibException, IOException {
|
||||||
for (int intVal : mItems.keySet()) {
|
for (Duo<ResReferenceValue, ResIntValue> duo : mItems) {
|
||||||
|
int intVal = duo.m2.getValue();
|
||||||
|
|
||||||
serializer.startTag(null, "enum");
|
serializer.startTag(null, "enum");
|
||||||
serializer.attribute(null, "name", decodeValue(intVal));
|
serializer.attribute(null, "name", duo.m1.getReferent().getName());
|
||||||
serializer.attribute(null, "value", String.valueOf(intVal));
|
serializer.attribute(null, "value", String.valueOf(intVal));
|
||||||
serializer.endTag(null, "enum");
|
serializer.endTag(null, "enum");
|
||||||
}
|
}
|
||||||
@ -67,7 +65,13 @@ public class ResEnumAttr extends ResAttr {
|
|||||||
private String decodeValue(int value) throws AndrolibException {
|
private String decodeValue(int value) throws AndrolibException {
|
||||||
String value2 = mItemsCache.get(value);
|
String value2 = mItemsCache.get(value);
|
||||||
if (value2 == null) {
|
if (value2 == null) {
|
||||||
ResReferenceValue ref = mItems.get(value);
|
ResReferenceValue ref = null;
|
||||||
|
for (Duo<ResReferenceValue, ResIntValue> duo : mItems) {
|
||||||
|
if (duo.m2.getValue() == value) {
|
||||||
|
ref = duo.m1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
value2 = ref.getReferent().getName();
|
value2 = ref.getReferent().getName();
|
||||||
mItemsCache.put(value, value2);
|
mItemsCache.put(value, value2);
|
||||||
@ -77,7 +81,7 @@ public class ResEnumAttr extends ResAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final Map<Integer, ResReferenceValue> mItems;
|
private final Duo<ResReferenceValue, ResIntValue>[] mItems;
|
||||||
private final Map<Integer, String> mItemsCache =
|
private final Map<Integer, String> mItemsCache =
|
||||||
new HashMap<Integer, String>();
|
new HashMap<Integer, String>();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user