Skip to content

Commit

Permalink
fix(gui): add "use imports" option to preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Oct 29, 2018
1 parent 58993b9 commit bc62933
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jadx-gui/src/main/java/jadx/gui/settings/JadxSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class JadxSettings extends JadxCLIArgs {

private static final String USER_HOME = System.getProperty("user.home");
private static final int RECENT_FILES_COUNT = 15;
private static final int CURRENT_SETTINGS_VERSION = 4;
private static final int CURRENT_SETTINGS_VERSION = 5;

private static final Font DEFAULT_FONT = FONT_HACK != null ? FONT_HACK : new RSyntaxTextArea().getFont();

Expand Down Expand Up @@ -206,6 +206,10 @@ public void setReplaceConsts(boolean replaceConsts) {
this.replaceConsts = replaceConsts;
}

public void setUseImports(boolean useImports) {
this.useImports = useImports;
}

public boolean isAutoStartJobs() {
return autoStartJobs;
}
Expand Down Expand Up @@ -274,6 +278,10 @@ private void upgradeSettings(int fromVersion) {
}
if (fromVersion == 3) {
setLangLocale(NLS.defaultLocale());
fromVersion++;
}
if (fromVersion == 4) {
setUseImports(true);
}
settingsVersion = CURRENT_SETTINGS_VERSION;
sync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,20 @@ private SettingsGroup makeDecompilationGroup() {
needReload();
});

JCheckBox useImports = new JCheckBox();
useImports.setSelected(settings.isUseImports());
useImports.addItemListener(e -> {
settings.setUseImports(e.getStateChange() == ItemEvent.SELECTED);
needReload();
});

SettingsGroup other = new SettingsGroup(NLS.str("preferences.decompile"));
other.addRow(NLS.str("preferences.threads"), threadsCount);
other.addRow(NLS.str("preferences.start_jobs"), autoStartJobs);
other.addRow(NLS.str("preferences.showInconsistentCode"), showInconsistentCode);
other.addRow(NLS.str("preferences.escapeUnicode"), escapeUnicode);
other.addRow(NLS.str("preferences.replaceConsts"), replaceConsts);
other.addRow(NLS.str("preferences.useImports"), useImports);
other.addRow(NLS.str("preferences.fallback"), fallback);
other.addRow(NLS.str("preferences.skipResourcesDecode"), resourceDecode);
return other;
Expand Down
1 change: 1 addition & 0 deletions jadx-gui/src/main/resources/i18n/Messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ preferences.fallback=Fallback mode (simple dump)
preferences.showInconsistentCode=Show inconsistent code
preferences.escapeUnicode=Escape unicode
preferences.replaceConsts=Replace constants
preferences.useImports=Use import statements
preferences.skipResourcesDecode=Don't decode resources
preferences.threads=Processing threads count
preferences.cfg=Generate methods CFG graphs (in 'dot' format)
Expand Down

0 comments on commit bc62933

Please sign in to comment.