Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui] Sort resources by deobfuscated name #1595

Closed
longnghia opened this issue Jul 31, 2022 · 2 comments · Fixed by #1598
Closed

[gui] Sort resources by deobfuscated name #1595

longnghia opened this issue Jul 31, 2022 · 2 comments · Fixed by #1598
Labels
deobfuscation GUI Issues in jadx-gui module resources

Comments

@longnghia
Copy link
Contributor

longnghia commented Jul 31, 2022

Resource files are currently sorted by original names. They should be sorted by deobfuscated name.

Before After
image image

I changed in jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java:

private JResource getHierarchyResources(List<ResourceFile> resources) {
JResource root = new JResource(null, NLS.str("tree.resources_title"), JResType.ROOT);
String splitPathStr = Pattern.quote(File.separator);
for (ResourceFile rf : resources) {
	String rfName;
	if (rf.getZipRef() != null) {
		rfName = rf.getDeobfName();
	} else {
		rfName = new File(rf.getDeobfName()).getName();
	}
	String[] parts = new File(rfName).getPath().split(splitPathStr);
	JResource curRf = root;
	int count = parts.length;
	for (int i = 0; i < count; i++) {
		String name = parts[i];
		JResource subRF = getResourceByName(curRf, name);
		if (subRF == null) {
			if (i != count - 1) {
				subRF = new JResource(null, name, JResType.DIR);
			} else {
				subRF = new JResource(rf, rf.getDeobfName(), name, JResType.FILE); //here
			}
			curRf.getFiles().add(subRF);
		}
		curRf = subRF;
	}
}
root.update();
return root;
}
@skylot
Copy link
Owner

skylot commented Aug 1, 2022

@longnghia thanks! Looks like this is a correct fix. Do you want to make a PR to get some credit? 🙂

@longnghia
Copy link
Contributor Author

@longnghia thanks! Looks like this is a correct fix. Do you want to make a PR to get some credit? slightly_smiling_face

I would love to! Thank you 😅️

skylot pushed a commit that referenced this issue Aug 1, 2022
Co-authored-by: /paul-nguyen-goldenowl <paul.nguyen.goldenowl@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deobfuscation GUI Issues in jadx-gui module resources
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants