Skip to content

Commit abfe4ea

Browse files
committed
[DEX] Smali resource comment with ResConfig
1 parent 70a740c commit abfe4ea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/com/reandroid/dex/smali/formatters/ResourceIdComment.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.reandroid.arsc.chunk.TableBlock;
2020
import com.reandroid.arsc.model.ResourceEntry;
2121
import com.reandroid.arsc.value.Entry;
22+
import com.reandroid.arsc.value.ResConfig;
2223
import com.reandroid.arsc.value.ResValue;
2324
import com.reandroid.arsc.value.ValueType;
2425
import com.reandroid.dex.smali.SmaliWriter;
@@ -43,7 +44,7 @@ class ResourceTableComment implements ResourceIdComment {
4344

4445
private final PackageBlock packageBlock;
4546
private final TableBlock tableBlock;
46-
private final Locale locale;
47+
private final ResConfig localeConfig;
4748
private final Map<Integer, Object> mCachedComment;
4849
private final Object mNoComment;
4950

@@ -53,7 +54,10 @@ public ResourceTableComment(PackageBlock packageBlock, Locale locale) {
5354
if (locale == null) {
5455
locale = new Locale("en");
5556
}
56-
this.locale = locale;
57+
ResConfig resConfig = new ResConfig();
58+
resConfig.setLanguage(locale.getLanguage());
59+
resConfig.setRegion(locale.getLanguage());
60+
this.localeConfig = resConfig;
5761
this.mCachedComment = new HashMap<>();
5862
this.mNoComment = new Object();
5963
}
@@ -71,7 +75,7 @@ public void writeComment(SmaliWriter writer, int resourceId) {
7175
writer.appendComment(comment);
7276
}
7377
}
74-
private String getComment(int resourceId) {
78+
private synchronized String getComment(int resourceId) {
7579
Integer id = resourceId;
7680
Map<Integer, Object> map = this.mCachedComment;
7781
Object obj = map.get(id);
@@ -104,7 +108,7 @@ private String buildComment(int resourceId) {
104108
if ("id".equals(resourceEntry.getType())) {
105109
return ref;
106110
}
107-
Entry entry = resourceEntry.forLocale(this.locale);
111+
Entry entry = resourceEntry.getMatchingOrAny(this.localeConfig);
108112
if (entry == null) {
109113
return ref;
110114
}

0 commit comments

Comments
 (0)