Commit 56798e71 authored by Skylot's avatar Skylot

gui: min and max deobf lengths must be positive

parent 904f0a11
...@@ -9,8 +9,6 @@ import java.util.List; ...@@ -9,8 +9,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import jadx.gui.utils.LangLocale;
import jadx.gui.utils.NLS;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -18,6 +16,8 @@ import org.slf4j.LoggerFactory; ...@@ -18,6 +16,8 @@ import org.slf4j.LoggerFactory;
import jadx.api.JadxArgs; import jadx.api.JadxArgs;
import jadx.cli.JadxCLIArgs; import jadx.cli.JadxCLIArgs;
import jadx.gui.ui.CodeArea; import jadx.gui.ui.CodeArea;
import jadx.gui.utils.LangLocale;
import jadx.gui.utils.NLS;
import static jadx.gui.utils.Utils.FONT_HACK; import static jadx.gui.utils.Utils.FONT_HACK;
...@@ -58,6 +58,12 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -58,6 +58,12 @@ public class JadxSettings extends JadxCLIArgs {
if (threadsCount <= 0) { if (threadsCount <= 0) {
threadsCount = JadxArgs.DEFAULT_THREADS_COUNT; threadsCount = JadxArgs.DEFAULT_THREADS_COUNT;
} }
if (deobfuscationMinLength < 0) {
deobfuscationMinLength = 0;
}
if (deobfuscationMaxLength < 0) {
deobfuscationMaxLength = 0;
}
if (settingsVersion != CURRENT_SETTINGS_VERSION) { if (settingsVersion != CURRENT_SETTINGS_VERSION) {
upgradeSettings(settingsVersion); upgradeSettings(settingsVersion);
} }
......
...@@ -8,7 +8,6 @@ import java.awt.event.MouseEvent; ...@@ -8,7 +8,6 @@ import java.awt.event.MouseEvent;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import jadx.gui.utils.LangLocale;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import say.swing.JFontChooser; import say.swing.JFontChooser;
...@@ -16,6 +15,7 @@ import say.swing.JFontChooser; ...@@ -16,6 +15,7 @@ import say.swing.JFontChooser;
import jadx.gui.ui.CodeArea; import jadx.gui.ui.CodeArea;
import jadx.gui.ui.CodeArea.EditorTheme; import jadx.gui.ui.CodeArea.EditorTheme;
import jadx.gui.ui.MainWindow; import jadx.gui.ui.MainWindow;
import jadx.gui.utils.LangLocale;
import jadx.gui.utils.NLS; import jadx.gui.utils.NLS;
import static jadx.gui.utils.Utils.FONT_HACK; import static jadx.gui.utils.Utils.FONT_HACK;
...@@ -135,17 +135,17 @@ public class JadxSettingsWindow extends JDialog { ...@@ -135,17 +135,17 @@ public class JadxSettingsWindow extends JDialog {
needReload(); needReload();
}); });
JSpinner minLen = new JSpinner(); SpinnerNumberModel minLenModel = new SpinnerNumberModel(settings.getDeobfuscationMinLength(), 0, Integer.MAX_VALUE, 1);
minLen.setValue(settings.getDeobfuscationMinLength()); JSpinner minLenSpinner = new JSpinner(minLenModel);
minLen.addChangeListener(e -> { minLenSpinner.addChangeListener(e -> {
settings.setDeobfuscationMinLength((Integer) minLen.getValue()); settings.setDeobfuscationMinLength((Integer) minLenSpinner.getValue());
needReload(); needReload();
}); });
JSpinner maxLen = new JSpinner(); SpinnerNumberModel maxLenModel = new SpinnerNumberModel(settings.getDeobfuscationMaxLength(), 0, Integer.MAX_VALUE, 1);
maxLen.setValue(settings.getDeobfuscationMaxLength()); JSpinner maxLenSpinner = new JSpinner(maxLenModel);
maxLen.addChangeListener(e -> { maxLenSpinner.addChangeListener(e -> {
settings.setDeobfuscationMaxLength((Integer) maxLen.getValue()); settings.setDeobfuscationMaxLength((Integer) maxLenSpinner.getValue());
needReload(); needReload();
}); });
...@@ -159,12 +159,12 @@ public class JadxSettingsWindow extends JDialog { ...@@ -159,12 +159,12 @@ public class JadxSettingsWindow extends JDialog {
SettingsGroup deobfGroup = new SettingsGroup(NLS.str("preferences.deobfuscation")); SettingsGroup deobfGroup = new SettingsGroup(NLS.str("preferences.deobfuscation"));
deobfGroup.addRow(NLS.str("preferences.deobfuscation_on"), deobfOn); deobfGroup.addRow(NLS.str("preferences.deobfuscation_on"), deobfOn);
deobfGroup.addRow(NLS.str("preferences.deobfuscation_force"), deobfForce); deobfGroup.addRow(NLS.str("preferences.deobfuscation_force"), deobfForce);
deobfGroup.addRow(NLS.str("preferences.deobfuscation_min_len"), minLen); deobfGroup.addRow(NLS.str("preferences.deobfuscation_min_len"), minLenSpinner);
deobfGroup.addRow(NLS.str("preferences.deobfuscation_max_len"), maxLen); deobfGroup.addRow(NLS.str("preferences.deobfuscation_max_len"), maxLenSpinner);
deobfGroup.addRow(NLS.str("preferences.deobfuscation_source_alias"), deobfSourceAlias); deobfGroup.addRow(NLS.str("preferences.deobfuscation_source_alias"), deobfSourceAlias);
deobfGroup.end(); deobfGroup.end();
Collection<JComponent> connectedComponents = Arrays.asList(deobfForce, minLen, maxLen, deobfSourceAlias); Collection<JComponent> connectedComponents = Arrays.asList(deobfForce, minLenSpinner, maxLenSpinner, deobfSourceAlias);
deobfOn.addItemListener(e -> enableComponentList(connectedComponents, e.getStateChange() == ItemEvent.SELECTED)); deobfOn.addItemListener(e -> enableComponentList(connectedComponents, e.getStateChange() == ItemEvent.SELECTED));
enableComponentList(connectedComponents, settings.isDeobfuscationOn()); enableComponentList(connectedComponents, settings.isDeobfuscationOn());
return deobfGroup; return deobfGroup;
......
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