Search in sources :

Example 1 with DeobfuscationMapFileMode

use of jadx.api.args.DeobfuscationMapFileMode in project jadx by skylot.

the class Deobfuscator method savePresets.

public void savePresets() {
    DeobfuscationMapFileMode mode = args.getDeobfuscationMapFileMode();
    if (!mode.shouldWrite()) {
        return;
    }
    Path deobfMapFile = deobfPresets.getDeobfMapFile();
    if (mode == DeobfuscationMapFileMode.READ_OR_SAVE && Files.exists(deobfMapFile)) {
        return;
    }
    try {
        deobfPresets.clear();
        fillDeobfPresets();
        deobfPresets.save();
    } catch (Exception e) {
        LOG.error("Failed to save deobfuscation map file '{}'", deobfMapFile.toAbsolutePath(), e);
    }
}
Also used : Path(java.nio.file.Path) DeobfuscationMapFileMode(jadx.api.args.DeobfuscationMapFileMode)

Example 2 with DeobfuscationMapFileMode

use of jadx.api.args.DeobfuscationMapFileMode in project jadx by skylot.

the class JadxSettingsWindow method makeDeobfuscationGroup.

private SettingsGroup makeDeobfuscationGroup() {
    JCheckBox deobfOn = new JCheckBox();
    deobfOn.setSelected(settings.isDeobfuscationOn());
    deobfOn.addItemListener(e -> {
        settings.setDeobfuscationOn(e.getStateChange() == ItemEvent.SELECTED);
        needReload();
    });
    SpinnerNumberModel minLenModel = new SpinnerNumberModel(settings.getDeobfuscationMinLength(), 0, Integer.MAX_VALUE, 1);
    JSpinner minLenSpinner = new JSpinner(minLenModel);
    minLenSpinner.addChangeListener(e -> {
        settings.setDeobfuscationMinLength((Integer) minLenSpinner.getValue());
        needReload();
    });
    SpinnerNumberModel maxLenModel = new SpinnerNumberModel(settings.getDeobfuscationMaxLength(), 0, Integer.MAX_VALUE, 1);
    JSpinner maxLenSpinner = new JSpinner(maxLenModel);
    maxLenSpinner.addChangeListener(e -> {
        settings.setDeobfuscationMaxLength((Integer) maxLenSpinner.getValue());
        needReload();
    });
    JCheckBox deobfSourceAlias = new JCheckBox();
    deobfSourceAlias.setSelected(settings.isDeobfuscationUseSourceNameAsAlias());
    deobfSourceAlias.addItemListener(e -> {
        settings.setDeobfuscationUseSourceNameAsAlias(e.getStateChange() == ItemEvent.SELECTED);
        needReload();
    });
    JCheckBox deobfKotlinMetadata = new JCheckBox();
    deobfKotlinMetadata.setSelected(settings.isDeobfuscationParseKotlinMetadata());
    deobfKotlinMetadata.addItemListener(e -> {
        settings.setDeobfuscationParseKotlinMetadata(e.getStateChange() == ItemEvent.SELECTED);
        needReload();
    });
    JComboBox<DeobfuscationMapFileMode> deobfMapFileModeCB = new JComboBox<>(DeobfuscationMapFileMode.values());
    deobfMapFileModeCB.setSelectedItem(settings.getDeobfuscationMapFileMode());
    deobfMapFileModeCB.addActionListener(e -> {
        DeobfuscationMapFileMode newValue = (DeobfuscationMapFileMode) deobfMapFileModeCB.getSelectedItem();
        if (newValue != settings.getDeobfuscationMapFileMode()) {
            settings.setDeobfuscationMapFileMode(newValue);
            needReload();
        }
    });
    SettingsGroup deobfGroup = new SettingsGroup(NLS.str("preferences.deobfuscation"));
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_on"), deobfOn);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_min_len"), minLenSpinner);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_max_len"), maxLenSpinner);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_source_alias"), deobfSourceAlias);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_kotlin_metadata"), deobfKotlinMetadata);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_map_file_mode"), deobfMapFileModeCB);
    deobfGroup.end();
    Collection<JComponent> connectedComponents = Arrays.asList(minLenSpinner, maxLenSpinner, deobfSourceAlias, deobfKotlinMetadata);
    deobfOn.addItemListener(e -> enableComponentList(connectedComponents, e.getStateChange() == ItemEvent.SELECTED));
    enableComponentList(connectedComponents, settings.isDeobfuscationOn());
    return deobfGroup;
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JSpinner(javax.swing.JSpinner) DeobfuscationMapFileMode(jadx.api.args.DeobfuscationMapFileMode)

Aggregations

DeobfuscationMapFileMode (jadx.api.args.DeobfuscationMapFileMode)2 Path (java.nio.file.Path)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JComponent (javax.swing.JComponent)1 JSpinner (javax.swing.JSpinner)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1