diff --git a/plugins/XposedGenerator.java b/plugins/XposedGenerator.java index 01caa929..4eb83368 100644 --- a/plugins/XposedGenerator.java +++ b/plugins/XposedGenerator.java @@ -127,7 +127,7 @@ public class XposedGenerator extends Plugin if (template != null && !template.equals("Empty")) { try { - //TODO: Prompt save dialogue + //TODO: Prompt save dialog File file = new File("./XposedClassTest.java"); // if file doesn't exists, then create it diff --git a/plugins/example/ExampleStringDecrypter.gy b/plugins/example/ExampleStringDecrypter.gy index 86f9216e..917ceacb 100644 --- a/plugins/example/ExampleStringDecrypter.gy +++ b/plugins/example/ExampleStringDecrypter.gy @@ -1,5 +1,5 @@ import the.bytecode.club.bytecodeviewer.api.* -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import java.util.ArrayList; import java.lang.reflect.Field; @@ -17,12 +17,12 @@ public class ExampleStringDecrypter extends Plugin { public void execute(ArrayList classNodesList) { PluginConsole gui = new PluginConsole("Example String Decrypter"); - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"}); - if(dialogue.promptChoice() == 0) + if(dialog.promptChoice() == 0) { for(ClassNode cn : classNodesList) { diff --git a/plugins/example/ExampleStringDecrypter.java b/plugins/example/ExampleStringDecrypter.java index b6307a54..278fdee1 100644 --- a/plugins/example/ExampleStringDecrypter.java +++ b/plugins/example/ExampleStringDecrypter.java @@ -1,5 +1,5 @@ import the.bytecode.club.bytecodeviewer.api.* -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import java.util.ArrayList; import java.lang.reflect.Field; @@ -17,12 +17,12 @@ public class ExampleStringDecrypter extends Plugin { public void execute(ArrayList classNodesList) { PluginConsole gui = new PluginConsole(activeContainer.name + "Example String Decrypter"); - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"}); - if(dialogue.promptChoice() == 0) + if(dialog.promptChoice() == 0) { for(ClassNode cn : classNodesList) { diff --git a/plugins/example/ExampleStringDecrypter.js b/plugins/example/ExampleStringDecrypter.js index d038673e..1e5cb2ab 100644 --- a/plugins/example/ExampleStringDecrypter.js +++ b/plugins/example/ExampleStringDecrypter.js @@ -3,10 +3,10 @@ */ var PluginConsole = Java.type("the.bytecode.club.bytecodeviewer.api.PluginConsole"); -var MultipleChoiceDialogue = Java.type("the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue") +var MultipleChoiceDialog = Java.type("the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog") var BytecodeViewer = Java.type("the.bytecode.club.bytecodeviewer.api.BCV") -var dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING", +var dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + "\nfor each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", ["Continue", "Cancel"]); @@ -16,7 +16,7 @@ function execute(classNodeList) { gui = new PluginConsole("Skeleton"); - if(dialogue.promptChoice() == 0) + if(dialog.promptChoice() == 0) { var needsWarning = false; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index afc8208f..d272900b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -152,7 +152,7 @@ public class BytecodeViewer private static final Thread pingBack = new Thread(new PingBack(), "Pingback"); private static final Thread installFatJar = new Thread(new InstallFatJar(), "Install Fat-Jar"); private static final Thread bootCheck = new Thread(new BootCheck(), "Boot Check"); - + /** * Main startup * @@ -164,7 +164,7 @@ public class BytecodeViewer //welcome message System.out.print("Bytecode Viewer " + VERSION); - if(FAT_JAR) + if (FAT_JAR) System.out.print(" [Fat Jar]"); System.out.println(" - Created by @Konloch"); @@ -192,14 +192,14 @@ public class BytecodeViewer Configuration.bootState = Configuration.BootState.SETTINGS_LOADED; //set translation language - if(!Settings.hasSetLanguageAsSystemLanguage) + if (!Settings.hasSetLanguageAsSystemLanguage) MiscUtils.setLanguage(guessLanguage()); //handle CLI int CLI = CommandLineInput.parseCommandLine(args); if (CLI == CommandLineInput.STOP) return; - + //load with shaded libraries if (FAT_JAR) { @@ -228,7 +228,7 @@ public class BytecodeViewer BytecodeViewer.handleException(e); } } - + /** * Boot after all of the libraries have been loaded * @@ -247,13 +247,13 @@ public class BytecodeViewer SettingsSerializer.saveSettings(); cleanup(); }, "Shutdown Hook")); - + //setup the viewer viewer.calledAfterLoad(); //setup the recent files Settings.resetRecentFilesMenu(); - + //ping back once on first boot to add to global user count if (!Configuration.pingback) { @@ -264,16 +264,16 @@ public class BytecodeViewer //version checking if (viewer.updateCheck.isSelected() && !DEV_MODE) versionChecker.start(); - + //show the main UI if (!cli) viewer.setVisible(true); - + //print startup time System.out.println("Start up took " + ((System.currentTimeMillis() - Configuration.start) / 1000) + " seconds"); //request focus on GUI for hotkeys on start - if(!cli) + if (!cli) viewer.requestFocus(); //open files from launch args @@ -289,11 +289,14 @@ public class BytecodeViewer public static void addResourceContainer(ResourceContainer container) { resourceContainers.add(container); - SwingUtilities.invokeLater(()-> + SwingUtilities.invokeLater(() -> { - try { + try + { viewer.resourcePane.addResourceContainer(container); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } }); @@ -331,7 +334,7 @@ public class BytecodeViewer { return BytecodeViewer.viewer.workPane.getActiveResource(); } - + /** * Returns the currently opened ClassNode * @@ -341,10 +344,10 @@ public class BytecodeViewer { return getActiveResource().resource.getResourceClassNode(); } - + /** * Returns the ClassNode by the specified name - * + *

* TODO anything relying on this should be rewritten to search using the resource container * * @param name the class name @@ -356,10 +359,10 @@ public class BytecodeViewer for (ResourceContainer container : resourceContainers) { ClassNode node = container.getClassNode(name); - if(node != null) + if (node != null) return node; } - + return null; } @@ -371,20 +374,21 @@ public class BytecodeViewer for (ResourceContainer container : resourceContainers) if (container.name.equals(name)) return container; - + return null; } /** * Returns all of the loaded resource containers */ - public static List getResourceContainers() { + public static List getResourceContainers() + { return resourceContainers; } - + /** * Grabs the file contents of the loaded resources. - * + *

* TODO anything relying on this should be rewritten to use the resource container's getFileContents * * @param name the file name @@ -396,7 +400,7 @@ public class BytecodeViewer for (ResourceContainer container : resourceContainers) if (container.resourceFiles.containsKey(name)) return container.resourceFiles.get(name); - + return null; } @@ -407,14 +411,14 @@ public class BytecodeViewer { return ClassFileUtils.getClassFileBytes(clazz); } - + /** * Gets all of the loaded classes as an array list - * + *

* TODO: remove this and replace it with: - * BytecodeViewer.getResourceContainers().forEach(container -> { - * execute(new ArrayList<>(container.resourceClasses.values())); - * }); + * BytecodeViewer.getResourceContainers().forEach(container -> { + * execute(new ArrayList<>(container.resourceClasses.values())); + * }); * * @return the loaded classes as an array list */ @@ -422,30 +426,33 @@ public class BytecodeViewer public static ArrayList getLoadedClasses() { ArrayList a = new ArrayList<>(); - + for (ResourceContainer container : resourceContainers) for (ClassNode c : container.resourceClasses.values()) if (!a.contains(c)) a.add(c); - + return a; } - + /** * Called any time refresh is called to automatically compile all of the compilable panes that're opened. */ public static boolean autoCompileSuccessful() { - if(!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) + if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) return true; - try { + try + { return compile(false, false); - } catch (NullPointerException ignored) { + } + catch (NullPointerException ignored) + { return false; } } - + /** * Compile all of the compilable panes that're opened. * @@ -464,27 +471,27 @@ public class BytecodeViewer { ClassViewer cv = (ClassViewer) c; - if(noErrors && !cv.bytecodeViewPanel1.compile()) + if (noErrors && !cv.bytecodeViewPanel1.compile()) noErrors = false; - if(noErrors && !cv.bytecodeViewPanel2.compile()) + if (noErrors && !cv.bytecodeViewPanel2.compile()) noErrors = false; - if(noErrors && !cv.bytecodeViewPanel3.compile()) + if (noErrors && !cv.bytecodeViewPanel3.compile()) noErrors = false; - if(cv.bytecodeViewPanel1.textArea != null && cv.bytecodeViewPanel1.textArea.isEditable()) + if (cv.bytecodeViewPanel1.textArea != null && cv.bytecodeViewPanel1.textArea.isEditable()) actuallyTried = true; - if(cv.bytecodeViewPanel2.textArea != null && cv.bytecodeViewPanel2.textArea.isEditable()) + if (cv.bytecodeViewPanel2.textArea != null && cv.bytecodeViewPanel2.textArea.isEditable()) actuallyTried = true; - if(cv.bytecodeViewPanel3.textArea != null && cv.bytecodeViewPanel3.textArea.isEditable()) + if (cv.bytecodeViewPanel3.textArea != null && cv.bytecodeViewPanel3.textArea.isEditable()) actuallyTried = true; } } - + if (message) { if (actuallyTried) { - if(noErrors && successAlert) + if (noErrors && successAlert) BytecodeViewer.showMessage("Compiled Successfully."); } else @@ -496,7 +503,7 @@ public class BytecodeViewer BytecodeViewer.updateBusyStatus(false); return true; } - + /** * Opens a file, optional if it should append to the recent files menu * @@ -513,13 +520,13 @@ public class BytecodeViewer SettingsSerializer.saveSettingsAsync(); } - + BytecodeViewer.updateBusyStatus(true); Configuration.needsReDump = true; Thread t = new Thread(new ImportResource(files), "Import Resource"); t.start(); } - + /** * Starts the specified plugin * @@ -539,13 +546,15 @@ public class BytecodeViewer PluginWriter writer = new PluginWriter(DiskReader.loadAsString(file.getAbsolutePath()), file.getName()); writer.setSourceFile(file); writer.setVisible(true); - } catch (Exception e) { + } + catch (Exception e) + { BytecodeViewer.handleException(e); } addRecentPlugin(file); } - + /** * Send a message to alert the user * @@ -555,7 +564,7 @@ public class BytecodeViewer { BetterJOptionPane.showMessageDialog(viewer, message); } - + /** * Send a message to alert the user * @@ -672,12 +681,12 @@ public class BytecodeViewer { if (ask) { - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reset Workspace", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Reset Workspace", "Are you sure you want to reset the workspace?" + "\n\rIt will also reset your file navigator and search.", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); - if (dialogue.promptChoice() != 0) + if (dialog.promptChoice() != 0) return; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java index b109edcd..6285e30e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java @@ -26,9 +26,13 @@ public class Configuration public static String javaTools = ""; public static File krakatauTempDir; public static File krakatauTempJar; + public static boolean displayParentInTab = false; //also change in the main GUI public static boolean simplifiedTabNames = false; - public static boolean useNewSettingsDialogue = true; //TODO add to GUI + + //if true it will show a settings dialog on click instead of more menu items + public static boolean useNewSettingsDialog = true; //TODO add to GUI + public static boolean forceResourceUpdateFromClassNode = false; //TODO add to GUI public static boolean showDarkLAFComponentIcons = false; public static boolean currentlyDumping = false; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java index b0406248..7d1d0e79 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java @@ -2,7 +2,7 @@ package the.bytecode.club.bytecodeviewer; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.RunOptions; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import javax.swing.*; @@ -31,7 +31,7 @@ public class GlobalHotKeys { Configuration.lastHotKeyExecuted = System.currentTimeMillis(); - final File file = DialogueUtils.fileChooser("Select File or Folder to open in BCV", + final File file = DialogUtils.fileChooser("Select File or Folder to open in BCV", "APKs, DEX, Class Files or Zip/Jar/War Archives", Constants.SUPPORTED_FILE_EXTENSIONS); @@ -101,7 +101,7 @@ public class GlobalHotKeys if (!file.getAbsolutePath().endsWith(".zip")) file = new File(file.getAbsolutePath() + ".zip"); - if (!DialogueUtils.canOverwriteFile(file)) + if (!DialogUtils.canOverwriteFile(file)) return; final File file2 = file; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java index e689a362..f5a0b088 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java @@ -14,7 +14,7 @@ import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; @@ -229,7 +229,7 @@ public class BCV * Asks if the user would like to overwrite the file */ public static boolean canOverwriteFile(File file) { - return DialogueUtils.canOverwriteFile(file); + return DialogUtils.canOverwriteFile(file); } public static void hideFrame(JFrame frame, long milliseconds) @@ -246,6 +246,40 @@ public class BCV frame.setVisible(false); }, "Timed Swing Hide").start(); } + + /** + * Log to System.out + */ + public static void log(String s) + { + log(false, s); + } + + /** + * Log to System.out + */ + public static void log(boolean devModeOnly, String s) + { + if(!devModeOnly || DEV_MODE) + System.out.println(s); + } + + /** + * Log to System.err + */ + public static void logE(String s) + { + logE(false, s); + } + + /** + * Log to System.err + */ + public static void logE(boolean devModeOnly, String s) + { + if(!devModeOnly || DEV_MODE) + System.err.println(s); + } /** * Returns the wrapped Krakatau Decompiler instance. diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index f9bb025b..c771692d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -40,7 +40,7 @@ import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; -import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialogue; +import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialog; import static the.bytecode.club.bytecodeviewer.Constants.*; /*************************************************************************** @@ -127,13 +127,13 @@ public class MainViewerGUI extends JFrame //all of the settings main menu components public final JMenu rstaTheme = new TranslatedJMenu("Text Area Theme", TranslatedComponents.TEXT_AREA_THEME); public final JMenuItem rstaThemeSettings = new TranslatedJMenuItem("Text Area Theme", TranslatedComponents.TEXT_AREA_THEME); - public SettingsDialogue rstaThemeSettingsDialogue; + public SettingsDialog rstaThemeSettingsDialog; public final JMenu lafTheme = new TranslatedJMenu("Window Theme", TranslatedComponents.WINDOW_THEME); public final JMenuItem lafThemeSettings = new TranslatedJMenuItem("Window Theme", TranslatedComponents.WINDOW_THEME); - public SettingsDialogue lafThemeSettingsDialogue; + public SettingsDialog lafThemeSettingsDialog; public final JMenu language = new TranslatedJMenu("Language", TranslatedComponents.LANGUAGE); public final JMenuItem languageSettings = new TranslatedJMenuItem("Language", TranslatedComponents.LANGUAGE); - public SettingsDialogue languageSettingsDialogue; + public SettingsDialog languageSettingsDialog; public final JMenu fontSize = new TranslatedJMenu("Font Size", TranslatedComponents.FONT_SIZE); public final JSpinner fontSpinner = new JSpinner(); public final Map rstaThemes = new HashMap<>(); @@ -163,7 +163,7 @@ public class MainViewerGUI extends JFrame //apk conversion settings public final JMenu apkConversionSecondaryMenu = new TranslatedJMenu("APK Conversion/Decoding", TranslatedComponents.APK_CONVERSION_DECODING); public final JMenuItem apkConversionSettings = new TranslatedJMenuItem("APK Conversion/Decoding", TranslatedComponents.APK_CONVERSION_DECODING); - public SettingsDialogue apkConversionSettingsDialogue; + public SettingsDialog apkConversionSettingsDialog; public final ButtonGroup apkConversionGroup = new ButtonGroup(); public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar"); public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify"); @@ -171,14 +171,14 @@ public class MainViewerGUI extends JFrame //CFIDE settings public final JMenu bytecodeDecompilerSettingsSecondaryMenu = new TranslatedJMenu("Bytecode Decompiler", TranslatedComponents.BYTECODE_DECOMPILER); public final JMenuItem bytecodeDecompilerSettings = new TranslatedJMenuItem("Bytecode Decompiler", TranslatedComponents.BYTECODE_DECOMPILER); - public SettingsDialogue bytecodeDecompilerSettingsDialogue; + public SettingsDialog bytecodeDecompilerSettingsDialog; public final JCheckBoxMenuItem appendBracketsToLabels = new TranslatedJCheckBoxMenuItem("Append Brackets To Labels", TranslatedComponents.APPEND_BRACKETS_TO_LABEL); public JCheckBoxMenuItem debugHelpers = new TranslatedJCheckBoxMenuItem("Debug Helpers", TranslatedComponents.DEBUG_HELPERS); //FernFlower settings public final JMenu fernFlowerSettingsSecondaryMenu = new TranslatedJMenu("FernFlower Settings", TranslatedComponents.FERNFLOWER_SETTINGS); public final JMenuItem fernFlowerSettings = new TranslatedJMenuItem("FernFlower Settings", TranslatedComponents.FERNFLOWER_SETTINGS); - public SettingsDialogue fernFlowerSettingsDialogue; + public SettingsDialog fernFlowerSettingsDialog; public TranslatedJCheckBoxMenuItem rbr = new TranslatedJCheckBoxMenuItem("Hide bridge methods", TranslatedComponents.HIDE_BRIDGE_METHODS); public TranslatedJCheckBoxMenuItem rsy = new TranslatedJCheckBoxMenuItem("Hide synthetic class members", TranslatedComponents.HIDE_SYNTHETIC_CLASS_MEMBERS); public TranslatedJCheckBoxMenuItem din = new TranslatedJCheckBoxMenuItem("Decompile inner classes", TranslatedComponents.DECOMPILE_INNER_CLASSES); @@ -202,7 +202,7 @@ public class MainViewerGUI extends JFrame //Procyon public final JMenu procyonSettingsSecondaryMenu = new TranslatedJMenu("Procyon Settings", TranslatedComponents.PROCYON_SETTINGS); public final JMenuItem procyonSettings = new TranslatedJMenuItem("Procyon Settings", TranslatedComponents.PROCYON_SETTINGS); - public SettingsDialogue procyonSettingsDialogue; + public SettingsDialog procyonSettingsDialog; public final JCheckBoxMenuItem alwaysGenerateExceptionVars = new TranslatedJCheckBoxMenuItem("Always Generate Exception Variable For Catch Blocks", TranslatedComponents.ALWAYS_GENERATE_EXCEPTION_VARIABLE_FOR_CATCH_BLOCKS); public final JCheckBoxMenuItem excludeNestedTypes = new TranslatedJCheckBoxMenuItem("Exclude Nested Types", TranslatedComponents.EXCLUDE_NESTED_TYPES); public final JCheckBoxMenuItem showDebugLineNumbers = new TranslatedJCheckBoxMenuItem("Show Debug Line Numbers", TranslatedComponents.SHOW_DEBUG_LINE_NUMBERS); @@ -221,7 +221,7 @@ public class MainViewerGUI extends JFrame //CFR public final JMenu cfrSettingsSecondaryMenu = new TranslatedJMenu("CFR Settings", TranslatedComponents.CFR_SETTINGS); public final JMenuItem cfrSettings = new TranslatedJMenuItem("CFR Settings", TranslatedComponents.CFR_SETTINGS); - public SettingsDialogue cfrSettingsDialogue; + public SettingsDialog cfrSettingsDialog; public final JCheckBoxMenuItem decodeEnumSwitch = new TranslatedJCheckBoxMenuItem("Decode Enum Switch", TranslatedComponents.DECODE_ENUM_SWITCH); public final JCheckBoxMenuItem sugarEnums = new TranslatedJCheckBoxMenuItem("SugarEnums", TranslatedComponents.SUGARENUMS); public final JCheckBoxMenuItem decodeStringSwitch = new TranslatedJCheckBoxMenuItem("Decode String Switch", TranslatedComponents.DECODE_STRING_SWITCH); @@ -402,10 +402,10 @@ public class MainViewerGUI extends JFrame settingsMainMenu.add(setJavac); settingsMainMenu.add(new JSeparator()); - //TODO the dialogue below works but for 3 options, + //TODO the dialog below works but for 3 options, // it might be better to leave it as a secondary menu settingsMainMenu.add(apkConversionSecondaryMenu); - //settingsMainMenu.add(useNewSettingsDialogue ? apkConversionSettings : apkConversionMenu); + //settingsMainMenu.add(useNewSettingsDialog ? apkConversionSettings : apkConversionMenu); settingsMainMenu.add(new JSeparator()); @@ -420,8 +420,8 @@ public class MainViewerGUI extends JFrame apkConversionGroup.add(apkConversionDex); apkConversionGroup.add(apkConversionEnjarify); apkConversionGroup.setSelected(apkConversionDex.getModel(), true); - //apkConversionSettingsDialogue = new SettingsDialogue(apkConversionSecondaryMenu, new JPanel()); - apkConversionSettings.addActionListener((e)-> apkConversionSettingsDialogue.showDialogue()); + //apkConversionSettingsDialog = new SettingsDialogue(apkConversionSecondaryMenu, new JPanel()); + apkConversionSettings.addActionListener((e)-> apkConversionSettingsDialog.showDialog()); ButtonGroup rstaGroup = new ButtonGroup(); for (RSTATheme t : RSTATheme.values()) @@ -444,8 +444,8 @@ public class MainViewerGUI extends JFrame rstaTheme.add(item); } - rstaThemeSettingsDialogue = new SettingsDialogue(rstaTheme, new JPanel()); - rstaThemeSettings.addActionListener((e)-> rstaThemeSettingsDialogue.showDialogue()); + rstaThemeSettingsDialog = new SettingsDialog(rstaTheme, new JPanel()); + rstaThemeSettings.addActionListener((e)-> rstaThemeSettingsDialog.showDialog()); ButtonGroup lafGroup = new ButtonGroup(); for (LAFTheme theme : LAFTheme.values()) @@ -479,8 +479,8 @@ public class MainViewerGUI extends JFrame lafTheme.add(item); } - lafThemeSettingsDialogue = new SettingsDialogue(lafTheme, new JPanel()); - lafThemeSettings.addActionListener((e)-> lafThemeSettingsDialogue.showDialogue()); + lafThemeSettingsDialog = new SettingsDialog(lafTheme, new JPanel()); + lafThemeSettings.addActionListener((e)-> lafThemeSettingsDialog.showDialog()); ButtonGroup languageGroup = new ButtonGroup(); for (Language l : Language.values()) @@ -501,12 +501,12 @@ public class MainViewerGUI extends JFrame language.add(item); } - languageSettingsDialogue = new SettingsDialogue(language, new JPanel()); - languageSettings.addActionListener((e)-> languageSettingsDialogue.showDialogue()); + languageSettingsDialog = new SettingsDialog(language, new JPanel()); + languageSettings.addActionListener((e)-> languageSettingsDialog.showDialog()); - visualSettings.add(useNewSettingsDialogue ? lafThemeSettings : lafTheme); - visualSettings.add(useNewSettingsDialogue ? rstaThemeSettings : rstaTheme); - visualSettings.add(useNewSettingsDialogue ? languageSettings : language); + visualSettings.add(useNewSettingsDialog ? lafThemeSettings : lafTheme); + visualSettings.add(useNewSettingsDialog ? rstaThemeSettings : rstaTheme); + visualSettings.add(useNewSettingsDialog ? languageSettings : language); visualSettings.add(fontSize); visualSettings.add(showFileInTabTitle); visualSettings.add(simplifyNameInTabTitle); @@ -514,7 +514,7 @@ public class MainViewerGUI extends JFrame visualSettings.add(showClassMethods); //PROCYON SETTINGS - settingsMainMenu.add(useNewSettingsDialogue ? procyonSettings : procyonSettingsSecondaryMenu); + settingsMainMenu.add(useNewSettingsDialog ? procyonSettings : procyonSettingsSecondaryMenu); procyonSettingsSecondaryMenu.add(alwaysGenerateExceptionVars); procyonSettingsSecondaryMenu.add(excludeNestedTypes); procyonSettingsSecondaryMenu.add(showDebugLineNumbers); @@ -529,11 +529,11 @@ public class MainViewerGUI extends JFrame procyonSettingsSecondaryMenu.add(retainPointlessSwitches); procyonSettingsSecondaryMenu.add(retainRedunantCasts); procyonSettingsSecondaryMenu.add(unicodeOutputEnabled); - procyonSettingsDialogue = new SettingsDialogue(procyonSettingsSecondaryMenu, new JPanel()); - procyonSettings.addActionListener((e)-> procyonSettingsDialogue.showDialogue()); + procyonSettingsDialog = new SettingsDialog(procyonSettingsSecondaryMenu, new JPanel()); + procyonSettings.addActionListener((e)-> procyonSettingsDialog.showDialog()); //CFR SETTINGS - settingsMainMenu.add(useNewSettingsDialogue ? cfrSettings : cfrSettingsSecondaryMenu); + settingsMainMenu.add(useNewSettingsDialog ? cfrSettings : cfrSettingsSecondaryMenu); cfrSettingsSecondaryMenu.add(decodeEnumSwitch); cfrSettingsSecondaryMenu.add(sugarEnums); cfrSettingsSecondaryMenu.add(decodeStringSwitch); @@ -578,11 +578,11 @@ public class MainViewerGUI extends JFrame cfrSettingsSecondaryMenu.add(recoveryTypehInts); cfrSettingsSecondaryMenu.add(forceTurningIFs); cfrSettingsSecondaryMenu.add(forLoopAGGCapture); - cfrSettingsDialogue = new SettingsDialogue(cfrSettingsSecondaryMenu, new JPanel()); - cfrSettings.addActionListener((e)-> cfrSettingsDialogue.showDialogue()); + cfrSettingsDialog = new SettingsDialog(cfrSettingsSecondaryMenu, new JPanel()); + cfrSettings.addActionListener((e)-> cfrSettingsDialog.showDialog()); //FERNFLOWER SETTINGS - settingsMainMenu.add(useNewSettingsDialogue ? fernFlowerSettings : fernFlowerSettingsSecondaryMenu); + settingsMainMenu.add(useNewSettingsDialog ? fernFlowerSettings : fernFlowerSettingsSecondaryMenu); fernFlowerSettingsSecondaryMenu.add(ren); fernFlowerSettingsSecondaryMenu.add(dc4); fernFlowerSettingsSecondaryMenu.add(nns); @@ -602,15 +602,15 @@ public class MainViewerGUI extends JFrame fernFlowerSettingsSecondaryMenu.add(udv); fernFlowerSettingsSecondaryMenu.add(fdi); fernFlowerSettingsSecondaryMenu.add(asc); - fernFlowerSettingsDialogue = new SettingsDialogue(fernFlowerSettingsSecondaryMenu, new JPanel()); - fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialogue.showDialogue()); + fernFlowerSettingsDialog = new SettingsDialog(fernFlowerSettingsSecondaryMenu, new JPanel()); + fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialog.showDialog()); //CFIDE SETTINGS - settingsMainMenu.add(useNewSettingsDialogue ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu); + settingsMainMenu.add(useNewSettingsDialog ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu); bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers); bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels); - bytecodeDecompilerSettingsDialogue = new SettingsDialogue(bytecodeDecompilerSettingsSecondaryMenu, new JPanel()); - bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialogue.showDialogue()); + bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel()); + bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog()); deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning()); forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync()); @@ -853,11 +853,11 @@ public class MainViewerGUI extends JFrame public void reloadResources() { - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reload Resources", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Reload Resources", "Are you sure you wish to reload the resources?", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); - if (dialogue.promptChoice() == 0) + if (dialog.promptChoice() == 0) { LazyNameUtil.reset(); ArrayList reopen = new ArrayList<>(); @@ -885,7 +885,7 @@ public class MainViewerGUI extends JFrame public void selectFile() { - final File file = DialogueUtils.fileChooser("Select File or Folder to open in BCV", + final File file = DialogUtils.fileChooser("Select File or Folder to open in BCV", "APKs, DEX, Class Files or Zip/Jar/War Archives", Constants.SUPPORTED_FILE_EXTENSIONS); @@ -899,7 +899,7 @@ public class MainViewerGUI extends JFrame public void openExternalPlugin() { - final File file = DialogueUtils.fileChooser("Select External Plugin", + final File file = DialogUtils.fileChooser("Select External Plugin", "External Plugin", Configuration.getLastPluginDirectory(), PluginManager.fileFilter(), @@ -917,11 +917,11 @@ public class MainViewerGUI extends JFrame public void askBeforeExiting() { - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Exit", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Exit", "Are you sure you want to exit?", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); - if (dialogue.promptChoice() == 0) + if (dialog.promptChoice() == 0) { Configuration.canExit = true; System.exit(0); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java index bf23503f..6aeeabe3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java @@ -4,7 +4,6 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import javax.swing.*; import java.awt.*; -import java.lang.reflect.Method; import static javax.swing.JOptionPane.*; @@ -86,7 +85,7 @@ public class BetterJOptionPane getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); - JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> + JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> { pane.selectInitialValue(); }); @@ -130,7 +129,7 @@ public class BetterJOptionPane getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); - JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> + JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> { pane.selectInitialValue(); }); @@ -145,14 +144,14 @@ public class BetterJOptionPane return value; } - public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight, OnCreate onCreate) + public static void showJPanelDialog(Component parentComponent, JScrollPane panel, int minimumHeight, OnCreate onCreate) throws HeadlessException { //create a new option pane with a empty text and just 'ok' JOptionPane pane = new JOptionPane(""); pane.add(panel, 0); - JDialog dialog = createNewJDialogue(parentComponent, pane, panel.getName(), ERROR_MESSAGE, (d)-> + JDialog dialog = createNewJDialog(parentComponent, pane, panel.getName(), ERROR_MESSAGE, (d)-> { int newHeight = Math.min(minimumHeight, d.getHeight()); d.setMinimumSize(new Dimension(d.getWidth(), newHeight)); @@ -163,7 +162,7 @@ public class BetterJOptionPane }); } - private static JDialog createNewJDialogue(Component parentComponent, JOptionPane pane, String title, int style, OnCreate onCreate) + private static JDialog createNewJDialog(Component parentComponent, JOptionPane pane, String title, int style, OnCreate onCreate) { JDialog dialog = pane.createDialog(parentComponent, title); if (JDialog.isDefaultLookAndFeelDecorated()) { @@ -177,7 +176,7 @@ public class BetterJOptionPane onCreate.onCreate(dialog); - //check if the dialogue is in a poor location, attempt to correct + //check if the dialog is in a poor location, attempt to correct if (dialog.getLocation().getY() == 0 || dialog.getLocation().getY() == 1) dialog.setLocationRelativeTo(null); //TODO check if BytecodeViewer.viewer is better on multi monitor for this edgecase else diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialogue.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialog.java similarity index 86% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialogue.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialog.java index fd119d85..bde5ecd9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialogue.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/MultipleChoiceDialog.java @@ -8,13 +8,13 @@ import javax.swing.*; * @author Konloch * @since 6/26/2021 */ -public class MultipleChoiceDialogue +public class MultipleChoiceDialog { private final String title; private final String description; private final String[] options; - public MultipleChoiceDialogue(String title, String description, String[] options) + public MultipleChoiceDialog(String title, String description, String[] options) { this.title = title; this.description = description; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialogue.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialog.java similarity index 89% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialogue.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialog.java index 240c2d67..0de12a70 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialogue.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SettingsDialog.java @@ -5,7 +5,7 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; -import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialogue; +import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialog; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -30,22 +30,22 @@ import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialo * @since 7/19/2021 */ -public class SettingsDialogue extends JScrollPane +public class SettingsDialog extends JScrollPane { public static final List components = new ArrayList<>(); - public static final List dialogues = new ArrayList<>(); + public static final List dialogs = new ArrayList<>(); private final List options = new ArrayList<>(); private final JMenu menu; private final JPanel display; - public SettingsDialogue(JMenu menu, JPanel display) + public SettingsDialog(JMenu menu, JPanel display) { super(display); this.menu = menu; this.display = display; - if(!useNewSettingsDialogue) + if(!useNewSettingsDialog) return; List options = new ArrayList<>(); @@ -75,9 +75,9 @@ public class SettingsDialogue extends JScrollPane options.forEach(jMenuItem -> jMenuItem.setArmed(false)); } - public void showDialogue() + public void showDialog() { - BetterJOptionPane.showJPanelDialogue(null, this, 460, dialogues::add); + BetterJOptionPane.showJPanelDialog(null, this, 460, dialogs::add); } private void buildPanel() diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java index 3d95e07e..dde659f2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java @@ -4,7 +4,7 @@ import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.theme.*; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; -import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialog; import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; @@ -118,13 +118,14 @@ public enum LAFTheme if(BytecodeViewer.viewer != null) { BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon); - //update all of the setting dialogue components - SettingsDialogue.components.forEach(SwingUtilities::updateComponentTreeUI); - //TODO instead of hiding this should update/rebuild the dialogue + //update all of the setting dialog components + SettingsDialog.components.forEach(SwingUtilities::updateComponentTreeUI); - //hide any existing jDialogues - SettingsDialogue.dialogues.forEach(Dialog::dispose); + //TODO instead of hiding the currently opened dialogs it should update/rebuild the dialogs + + //hide any existing jDialogs + SettingsDialog.dialogs.forEach(Dialog::dispose); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index a204b3a7..1b697d29 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -11,7 +11,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; @@ -101,7 +101,7 @@ public class PluginWriter extends JFrame public void openPlugin() { - final File file = DialogueUtils.fileChooser("Select External Plugin", + final File file = DialogUtils.fileChooser("Select External Plugin", "External Plugin", Configuration.getLastPluginDirectory(), PluginManager.fileFilter(), @@ -177,7 +177,7 @@ public class PluginWriter extends JFrame if (!path.endsWith("." + ext)) path = path + "." + ext; - if (!DialogueUtils.canOverwriteFile(path)) + if (!DialogUtils.canOverwriteFile(path)) return; //swap from save-as to having a defined path each save diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java index c4db38b1..08d0aad2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java @@ -10,7 +10,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.resources.IconResources; import the.bytecode.club.bytecodeviewer.api.*; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.plugin.PluginManager; import javax.swing.*; @@ -55,12 +55,12 @@ public class AllatoriStringDecrypter extends Plugin { PluginConsole frame = new PluginConsole(activeContainer.name + " - Allatori String Decrypter"); - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the allatori decrypter function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"}); - if (dialogue.promptChoice() == 0) + if (dialog.promptChoice() == 0) { try { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ChangeClassFileVersions.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ChangeClassFileVersions.java index e76cba38..ebc97058 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ChangeClassFileVersions.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ChangeClassFileVersions.java @@ -23,7 +23,7 @@ public class ChangeClassFileVersions extends Plugin @Override public void execute(ArrayList classNodeList) { - //prompt dialogue for version number + //prompt dialog for version number // TODO: include a little diagram of what JDK is which number int newVersion = Integer.parseInt(BytecodeViewer.showInput("Class Version Number: (52 = JDK 8)")); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java index 5b590f29..e8c14a38 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java @@ -10,7 +10,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.BCV; import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import static the.bytecode.club.bytecodeviewer.Constants.*; @@ -47,12 +47,12 @@ public class ZStringArrayDecrypter extends Plugin PluginConsole gui = new PluginConsole(activeContainer.name + " - ZStringArray Decrypter"); StringBuilder out = new StringBuilder(); - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"}); - if (dialogue.promptChoice() == 0) + if (dialog.promptChoice() == 0) { boolean needsWarning = false; for (Class cn : diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java index b79e4a3c..deb94db2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java @@ -5,7 +5,7 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.SettingsSerializer; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JRTExtractor; import java.io.BufferedReader; @@ -222,7 +222,7 @@ public class ExternalResources public void selectPython2() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_2.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_2.toString(), TranslatedStrings.PYTHON_2_EXECUTABLE.toString(), FileChooser.EVERYTHING); @@ -236,7 +236,7 @@ public class ExternalResources public void selectPython3() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_3.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_3.toString(), TranslatedStrings.PYTHON_3_EXECUTABLE.toString(), FileChooser.EVERYTHING); @@ -250,7 +250,7 @@ public class ExternalResources public void selectJava() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_JAVA.toString(), TranslatedStrings.JAVA_EXECUTABLE.toString(), FileChooser.EVERYTHING); @@ -263,7 +263,7 @@ public class ExternalResources public void selectJavac() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVAC.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_JAVAC.toString(), TranslatedStrings.JAVAC_EXECUTABLE.toString(), FileChooser.EVERYTHING); @@ -276,7 +276,7 @@ public class ExternalResources public void selectJRERTLibrary() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA_RT.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_JAVA_RT.toString(), TranslatedStrings.JAVA_RT_JAR.toString(), FileChooser.EVERYTHING); @@ -289,7 +289,7 @@ public class ExternalResources public void selectJavaTools() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA_TOOLS.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_JAVA_TOOLS.toString(), TranslatedStrings.JAVA_TOOLS_JAR.toString(), FileChooser.EVERYTHING); @@ -302,7 +302,7 @@ public class ExternalResources public void selectOptionalLibraryFolder() { - final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_LIBRARY_FOLDER.toString(), + final File file = DialogUtils.fileChooser(TranslatedStrings.SELECT_LIBRARY_FOLDER.toString(), TranslatedStrings.OPTIONAL_LIBRARY_FOLDER.toString(), FileChooser.EVERYTHING); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java index 93736b94..3376ee92 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java @@ -8,7 +8,7 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; @@ -51,7 +51,7 @@ public class ResourceDecompiling if (!file.getAbsolutePath().endsWith(".zip")) file = new File(file.getAbsolutePath() + ".zip"); - if (!DialogueUtils.canOverwriteFile(file)) + if (!DialogUtils.canOverwriteFile(file)) return; final File javaSucks = file; @@ -210,7 +210,7 @@ public class ResourceDecompiling BytecodeViewer.updateBusyStatus(true); final String path = MiscUtils.append(file, ".java"); - if (!DialogueUtils.canOverwriteFile(path)) + if (!DialogUtils.canOverwriteFile(path)) return; JOptionPane pane = new JOptionPane( diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java index 1bd8eba8..f70a4eb8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java @@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.resources.exporting.impl; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.util.*; @@ -16,10 +16,29 @@ import java.util.List; import static the.bytecode.club.bytecodeviewer.Constants.fs; import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; +/*************************************************************************** + * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * + * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + /** * @author Konloch * @since 6/27/2021 */ + public class APKExport implements Exporter { @Override @@ -49,11 +68,11 @@ public class APKExport implements Exporter //if theres only one file in the container don't bother asking if (validContainers.size() >= 2) { - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Select APK", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Select APK", "Which file would you like to export as an APK?", validContainersNames.toArray(new String[0])); - container = containers.get(dialogue.promptChoice()); + container = containers.get(dialog.promptChoice()); } } else { BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on." + @@ -86,7 +105,7 @@ public class APKExport implements Exporter output = output + ".apk"; final File file2 = new File(output); - if (!DialogueUtils.canOverwriteFile(file2)) + if (!DialogUtils.canOverwriteFile(file2)) return; Thread saveThread = new Thread(() -> diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java index 2d32aefd..f84624dc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java @@ -5,7 +5,7 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.util.Dex2Jar; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; @@ -51,7 +51,7 @@ public class DexExport implements Exporter output = output + ".dex"; File outputPath = new File(output); - if (!DialogueUtils.canOverwriteFile(outputPath)) + if (!DialogUtils.canOverwriteFile(outputPath)) return; Thread saveAsJar = new Thread(() -> diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java index 81c53305..18d63a82 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java @@ -5,7 +5,7 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.ExportJar; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import javax.swing.*; import java.io.File; @@ -44,7 +44,7 @@ public class RunnableJarExporter implements Exporter if (!path.endsWith(".jar")) path = path + ".jar"; - if (!DialogueUtils.canOverwriteFile(path)) + if (!DialogUtils.canOverwriteFile(path)) return; new ExportJar(path).setVisible(true); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java index ac6b81d1..c5591d59 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java @@ -4,7 +4,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; -import the.bytecode.club.bytecodeviewer.util.DialogueUtils; +import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import javax.swing.*; @@ -43,7 +43,7 @@ public class ZipExport implements Exporter if (!file.getAbsolutePath().endsWith(".zip")) file = new File(file.getAbsolutePath() + ".zip"); - if (!DialogueUtils.canOverwriteFile(file)) + if (!DialogUtils.canOverwriteFile(file)) return; final File file2 = file; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java index e9e03567..6614bdee 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java @@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.translation; import com.google.gson.reflect.TypeToken; import org.apache.commons.collections4.map.LinkedMap; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.api.BCV; import the.bytecode.club.bytecodeviewer.resources.IconResources; import java.io.IOException; @@ -114,7 +115,7 @@ public enum Language //skip translating if the language config is missing the translation key if(!translationMap.containsKey(text.key)) { - System.err.println("MISSING TRANSLATION KEY: " + text.key); + BCV.logE(true, "MISSING TRANSLATION KEY: " + text.key); continue; } @@ -132,7 +133,7 @@ public enum Language if(translatedComponents.getTranslatedComponentReference().runOnUpdate.isEmpty()) //&& TranslatedStrings.nameSet.contains(translation.name())) { - System.err.println("Translation Reference " + translatedComponents.name() + " is missing component attachment, skipping..."); + BCV.logE(true, "Translation Reference " + translatedComponents.name() + " is missing component attachment, skipping..."); continue; } @@ -175,7 +176,7 @@ public enum Language for(String key : translationMap.keySet()) if(!existingKeys.contains(key)) - System.err.println(key + ","); + BCV.logE(true, key + ","); } public String getResourcePath() diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java index e3f8174f..173b7f37 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedComponents.java @@ -22,7 +22,7 @@ package the.bytecode.club.bytecodeviewer.translation; * Translation keys for components (updates the component text on language change). * * You only need to add a translation key if it is going to be used by a component. - * If your translation is not tied to a component (Console, Dialogue) use TranslatedStrings + * If your translation is not tied to a component (Console, Dialogs) use TranslatedStrings * * @author Konloch * @since 6/28/2021 diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java index 68c9b8ca..bf1e85af 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java @@ -1,5 +1,7 @@ package the.bytecode.club.bytecodeviewer.translation; +import the.bytecode.club.bytecodeviewer.api.BCV; + import java.io.IOException; import java.util.HashSet; @@ -24,7 +26,7 @@ import java.util.HashSet; /** * Translation keys for constant strings (does not change the component text on language change). * - * You need to add your translation key here if it is not tied to any specific component (Console, Dialogue) + * You need to add your translation key here if it is not tied to any specific component (Console, Dialogs) * * @author Konloch * @since 7/6/2021 @@ -32,10 +34,12 @@ import java.util.HashSet; public enum TranslatedStrings { - BCV("BytecodeViewer"), - BYTECODEVIEWER("BytecodeViewer"), - BYTECODE_VIEWER("Bytecode Viewer"), - BYTECODE_H_VIEWER("Bytecode-Viewer"), + PRODUCT("BCV"), + PRODUCTNAME("BytecodeViewer"), + PRODUCT_NAME("Bytecode Viewer"), + PRODUCT_H_NAME("Bytecode-Viewer"), + WEBSITE("https://bytecodeviewer.com"), + TBC("https://the.bytecode.club"), EDITABLE, JAVA, @@ -124,14 +128,18 @@ public enum TranslatedStrings { if(text == null) { - System.err.println("TranslatedStrings:"+name() + " - Missing Translation"); + BCV.logE(true, "TranslatedStrings:"+name() + " - Missing Translation"); text = TEXT_ERROR; } - text = text.replace("%PRODUCTNAME%", BYTECODEVIEWER.toString()) - .replace("%PRODUCT_NAME%", BYTECODE_VIEWER.toString()) - .replace("%PRODUCT-NAME%", BYTECODE_H_VIEWER.toString()) - .replace("%BCV%", BCV.toString()); + //TODO this should be tokenized against the TranslatedStrings enum + text = text.replace("{PRODUCTNAME}", PRODUCTNAME.toString()) + .replace("{PRODUCT_NAME}", PRODUCT_NAME.toString()) + .replace("{PRODUCT-NAME}", PRODUCT_H_NAME.toString()) + .replace("{PRODUCT}", PRODUCT.toString()) + .replace("{TBV}", TBC.toString()) + .replace("{WEBSITE}", WEBSITE.toString()) + ; this.text = text; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/DialogueUtils.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/DialogUtils.java similarity index 95% rename from src/main/java/the/bytecode/club/bytecodeviewer/util/DialogueUtils.java rename to src/main/java/the/bytecode/club/bytecodeviewer/util/DialogUtils.java index 3f3e431c..9941d92b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/DialogueUtils.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/DialogUtils.java @@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.util; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import javax.swing.*; @@ -32,7 +32,7 @@ import java.io.File; * @author Konloch * @since 7/1/2021 */ -public class DialogueUtils +public class DialogUtils { /** * Asks if the user would like to overwrite the file @@ -48,11 +48,11 @@ public class DialogueUtils public static boolean canOverwriteFile(File file) { if (file.exists()) { - MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Overwrite File", + MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File", "Are you sure you wish to overwrite this existing file?", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); - if (dialogue.promptChoice() == 0) { + if (dialog.promptChoice() == 0) { file.delete(); return true; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java index 1d185727..83c16f78 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java @@ -1,11 +1,10 @@ package the.bytecode.club.bytecodeviewer.util; -import java.util.Objects; import me.konloch.kontainer.io.HTTPRequest; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; +import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import javax.swing.*; @@ -61,12 +60,12 @@ public class VersionChecker implements Runnable if (VERSION != null && !VERSION.equals(version)) { - MultipleChoiceDialogue outdatedDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Outdated Version", + MultipleChoiceDialog outdatedDialog = new MultipleChoiceDialog("Bytecode Viewer - Outdated Version", "Your version: " + VERSION + ", latest version: " + version + nl + "What would you like to do?", new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"}); - int result = outdatedDialogue.promptChoice(); + int result = outdatedDialog.promptChoice(); if (result == 0) { @@ -100,11 +99,11 @@ public class VersionChecker implements Runnable if (file.exists()) { - MultipleChoiceDialogue overwriteDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Overwrite File", + MultipleChoiceDialog overwriteDialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File", "The file " + file + " exists, would you like to overwrite it?", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); - if (overwriteDialogue.promptChoice() != 0) + if (overwriteDialog.promptChoice() != 0) return; file.delete();