Allow change of minSdkVersion via settings

This commit is contained in:
Nico Mexis 2021-08-11 22:42:09 +02:00
parent 63df81e378
commit 68383dca5e
No known key found for this signature in database
GPG key ID: 27D6E17CE092AB78
6 changed files with 33 additions and 11 deletions

View file

@ -163,7 +163,7 @@ public class SettingsSerializer
save("deprecated"); save("deprecated");
save("deprecated"); save("deprecated");
save("deprecated"); save("deprecated");
save(BytecodeViewer.viewer.fontSpinner.getValue()); save(BytecodeViewer.viewer.getFontSize());
save(Configuration.deleteForeignLibraries); save(Configuration.deleteForeignLibraries);
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
@ -200,6 +200,7 @@ public class SettingsSerializer
save(Configuration.lastPluginDirectory); save(Configuration.lastPluginDirectory);
save(Configuration.python2Extra); save(Configuration.python2Extra);
save(Configuration.python3Extra); save(Configuration.python3Extra);
save(BytecodeViewer.viewer.getMinSdkVersion());
} catch (Exception e) { } catch (Exception e) {
BytecodeViewer.handleException(e); BytecodeViewer.handleException(e);
} }
@ -396,6 +397,7 @@ public class SettingsSerializer
Configuration.lastPluginDirectory = asString(138); Configuration.lastPluginDirectory = asString(138);
Configuration.python2Extra = asBoolean(139); Configuration.python2Extra = asBoolean(139);
Configuration.python3Extra = asBoolean(140); Configuration.python3Extra = asBoolean(140);
BytecodeViewer.viewer.minSdkVersionSpinner.setValue(asInt(141));
} }
catch (IndexOutOfBoundsException e) catch (IndexOutOfBoundsException e)
{ {

View file

@ -267,6 +267,10 @@ public class MainViewerGUI extends JFrame
public final JCheckBoxMenuItem forceTurningIFs = new TranslatedJCheckBoxMenuItem("Force Returning IFs", TranslatedComponents.FORCE_RETURNING_IFS); public final JCheckBoxMenuItem forceTurningIFs = new TranslatedJCheckBoxMenuItem("Force Returning IFs", TranslatedComponents.FORCE_RETURNING_IFS);
public final JCheckBoxMenuItem forLoopAGGCapture = new TranslatedJCheckBoxMenuItem("For Loop AGG Capture", TranslatedComponents.FOR_LOOP_AGG_CAPTURE); public final JCheckBoxMenuItem forLoopAGGCapture = new TranslatedJCheckBoxMenuItem("For Loop AGG Capture", TranslatedComponents.FOR_LOOP_AGG_CAPTURE);
//Smali/D2Jar
public final JMenu minSdkVersionMenu = new TranslatedJMenu("Minimum SDK version", TranslatedComponents.MIN_SDK_VERSION);
public final JSpinner minSdkVersionSpinner = new JSpinner();
//obfuscation //obfuscation
public final JMenu obfuscate = new JMenu("Obfuscate"); public final JMenu obfuscate = new JMenu("Obfuscate");
public final JMenuItem renameFields = new JMenuItem("Rename Fields"); public final JMenuItem renameFields = new JMenuItem("Rename Fields");
@ -612,6 +616,13 @@ public class MainViewerGUI extends JFrame
bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel()); bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel());
bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog()); bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog());
//Smali minSdkVersion
minSdkVersionSpinner.setPreferredSize(new Dimension(60, 24));
minSdkVersionSpinner.setMinimumSize(new Dimension(60, 24));
minSdkVersionSpinner.setModel(new SpinnerNumberModel(26, 1, null, 1));
minSdkVersionMenu.add(minSdkVersionSpinner);
settingsMainMenu.add(minSdkVersionMenu);
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning()); deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync()); forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync());
setPython2.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython2()); setPython2.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython2());
@ -799,6 +810,11 @@ public class MainViewerGUI extends JFrame
return (int) fontSpinner.getValue(); return (int) fontSpinner.getValue();
} }
public int getMinSdkVersion()
{
return (int) minSdkVersionSpinner.getValue();
}
public synchronized void clearBusyStatus() public synchronized void clearBusyStatus()
{ {
SwingUtilities.invokeLater(()-> SwingUtilities.invokeLater(()->

View file

@ -250,6 +250,7 @@ public enum TranslatedComponents
DESC, DESC,
RESULTS, RESULTS,
REFRESH, REFRESH,
MIN_SDK_VERSION,
; ;

View file

@ -1,9 +1,8 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import com.googlecode.d2j.dex.Dex2jar; import com.googlecode.d2j.dex.Dex2jar;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import java.io.File; import java.io.File;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -60,7 +59,9 @@ public class Dex2Jar {
public static synchronized void saveAsDex(File input, File output, boolean delete) { public static synchronized void saveAsDex(File input, File output, boolean delete) {
try { try {
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(), "-o", output.getAbsolutePath()); com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(),
"-o", output.getAbsolutePath(),
"-s", BytecodeViewer.viewer.getMinSdkVersion() + "");
if (delete) if (delete)
input.delete(); input.delete();
} catch (Exception e) { } catch (Exception e) {

View file

@ -279,5 +279,6 @@
"SAVE": "Save...", "SAVE": "Save...",
"SAVE_AS": "Save As...", "SAVE_AS": "Save As...",
"RESULTS": "Results", "RESULTS": "Results",
"REFRESH": "Refresh" "REFRESH": "Refresh",
"MIN_SDK_VERSION": "Minimum SDK version"
} }

View file

@ -254,5 +254,6 @@
"CLOSE_ALL_BUT_THIS": "Alle außer diesen schließen", "CLOSE_ALL_BUT_THIS": "Alle außer diesen schließen",
"CLOSE_TAB": "Tab schließen", "CLOSE_TAB": "Tab schließen",
"PLEASE_SEND_THIS_ERROR_LOG_TO": "Bitte senden Sie dieses Fehlerprotokoll an", "PLEASE_SEND_THIS_ERROR_LOG_TO": "Bitte senden Sie dieses Fehlerprotokoll an",
"PLEASE_SEND_RESOURCES": "Wenn Sie entsprechende gesetzliche Rechte an der jeweiligen Klasse besitzen" "PLEASE_SEND_RESOURCES": "Wenn Sie entsprechende gesetzliche Rechte an der jeweiligen Klasse besitzen",
"MIN_SDK_VERSION": "Minimale SDK-Version"
} }