Commit f8acc31b authored by Skylot's avatar Skylot

fix(gui): remove output directories from persistent settings (#447)

parent bcadc282
...@@ -53,13 +53,18 @@ public class JadxArgsValidator { ...@@ -53,13 +53,18 @@ public class JadxArgsValidator {
} else { } else {
outDir = makeDirFromInput(args); outDir = makeDirFromInput(args);
} }
}
args.setOutDir(outDir); args.setOutDir(outDir);
setFromOut(args); }
if (srcDir == null) {
args.setOutDirSrc(new File(args.getOutDir(), JadxArgs.DEFAULT_SRC_DIR));
}
if (resDir == null) {
args.setOutDirRes(new File(args.getOutDir(), JadxArgs.DEFAULT_RES_DIR));
}
checkDir(args.getOutDir()); checkDir(args.getOutDir(), "Output");
checkDir(args.getOutDirSrc()); checkDir(args.getOutDirSrc(), "Source output");
checkDir(args.getOutDirRes()); checkDir(args.getOutDirRes(), "Resources output");
} }
@NotNull @NotNull
...@@ -79,15 +84,6 @@ public class JadxArgsValidator { ...@@ -79,15 +84,6 @@ public class JadxArgsValidator {
return outDir; return outDir;
} }
private static void setFromOut(JadxArgs args) {
if (args.getOutDirSrc() == null) {
args.setOutDirSrc(new File(args.getOutDir(), JadxArgs.DEFAULT_SRC_DIR));
}
if (args.getOutDirRes() == null) {
args.setOutDirRes(new File(args.getOutDir(), JadxArgs.DEFAULT_RES_DIR));
}
}
private static void checkFile(File file) { private static void checkFile(File file) {
if (!file.exists()) { if (!file.exists()) {
throw new JadxArgsValidateException("File not found " + file.getAbsolutePath()); throw new JadxArgsValidateException("File not found " + file.getAbsolutePath());
...@@ -97,9 +93,9 @@ public class JadxArgsValidator { ...@@ -97,9 +93,9 @@ public class JadxArgsValidator {
} }
} }
private static void checkDir(File dir) { private static void checkDir(File dir, String desc) {
if (dir != null && dir.exists() && !dir.isDirectory()) { if (dir != null && dir.exists() && !dir.isDirectory()) {
throw new JadxArgsValidateException("Output directory exists as file " + dir); throw new JadxArgsValidateException(desc + " directory exists as file " + dir);
} }
} }
......
...@@ -35,7 +35,7 @@ public class JadxWrapper { ...@@ -35,7 +35,7 @@ public class JadxWrapper {
this.decompiler.getArgs().setInputFiles(Collections.singletonList(file)); this.decompiler.getArgs().setInputFiles(Collections.singletonList(file));
this.decompiler.load(); this.decompiler.load();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error load file: {}", file, e); LOG.error("Jadx init error", e);
} }
} }
......
...@@ -26,12 +26,12 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -26,12 +26,12 @@ public class JadxSettings extends JadxCLIArgs {
private static final String USER_HOME = System.getProperty("user.home"); private static final String USER_HOME = System.getProperty("user.home");
private static final int RECENT_FILES_COUNT = 15; private static final int RECENT_FILES_COUNT = 15;
private static final int CURRENT_SETTINGS_VERSION = 7; private static final int CURRENT_SETTINGS_VERSION = 8;
private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont(); private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont();
static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList( static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList(
"files", "input", "outputDir", "verbose", "printHelp" "files", "input", "outDir", "outDirSrc", "outDirRes", "verbose", "printVersion", "printHelp"
)); ));
private String lastOpenFilePath = USER_HOME; private String lastOpenFilePath = USER_HOME;
private String lastSaveFilePath = USER_HOME; private String lastSaveFilePath = USER_HOME;
...@@ -323,6 +323,12 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -323,6 +323,12 @@ public class JadxSettings extends JadxCLIArgs {
if (getFont().getFontName().equals("Hack Regular")) { if (getFont().getFontName().equals("Hack Regular")) {
setFont(null); setFont(null);
} }
fromVersion++;
}
if (fromVersion == 7) {
outDir = null;
outDirSrc = null;
outDirRes = null;
} }
settingsVersion = CURRENT_SETTINGS_VERSION; settingsVersion = CURRENT_SETTINGS_VERSION;
sync(); sync();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment