未验证 提交 fad9e7b8 编写于 作者: J Jan S 提交者: GitHub

fix(gui): initialize project name with loaded files (shown in Jadx title) (#1386)(PR #1393)

上级 35116d0b
......@@ -10,6 +10,7 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -25,6 +26,7 @@ import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxCodeRef;
import jadx.api.data.impl.JadxCodeRename;
import jadx.api.data.impl.JadxNodeRef;
import jadx.api.plugins.utils.CommonFileUtils;
import jadx.core.utils.GsonUtils;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.gui.settings.data.ProjectData;
......@@ -64,11 +66,7 @@ public class JadxProject {
private void setProjectPath(Path projectPath) {
this.projectPath = projectPath;
this.name = projectPath.getFileName().toString();
int dotPos = name.lastIndexOf('.');
if (dotPos != -1) {
name = name.substring(0, dotPos);
}
this.name = CommonFileUtils.removeFileExtension(projectPath.getFileName().toString());
changed();
}
......@@ -79,6 +77,9 @@ public class JadxProject {
public void setFilePath(List<Path> files) {
if (!files.equals(getFilePaths())) {
data.setFiles(files);
String joinedName = files.stream().map(p -> CommonFileUtils.removeFileExtension(p.getFileName().toString()))
.collect(Collectors.joining("_"));
this.name = StringUtils.abbreviate(joinedName, 100);
changed();
}
}
......
......@@ -90,6 +90,14 @@ public class CommonFileUtils {
return fileName.substring(dotIndex + 1);
}
public static String removeFileExtension(String fileName) {
int dotIndex = fileName.lastIndexOf('.');
if (dotIndex == -1) {
return fileName;
}
return fileName.substring(0, dotIndex);
}
private static final Set<String> ZIP_FILE_EXTS = Utils.constSet("zip", "jar", "apk");
public static boolean isZipFileExt(String fileName) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册