Code Cleanup

Translation errors are now silenced unless developer mode is enabled
This commit is contained in:
Konloch 2021-07-21 08:20:38 -07:00
parent e3d16031b8
commit 0203a13472
28 changed files with 258 additions and 184 deletions

View file

@ -127,7 +127,7 @@ public class XposedGenerator extends Plugin
if (template != null && !template.equals("Empty")) if (template != null && !template.equals("Empty"))
{ {
try { try {
//TODO: Prompt save dialogue //TODO: Prompt save dialog
File file = new File("./XposedClassTest.java"); File file = new File("./XposedClassTest.java");
// if file doesn't exists, then create it // if file doesn't exists, then create it

View file

@ -1,5 +1,5 @@
import the.bytecode.club.bytecodeviewer.api.* 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.util.ArrayList;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -17,12 +17,12 @@ public class ExampleStringDecrypter extends Plugin {
public void execute(ArrayList<ClassNode> classNodesList) { public void execute(ArrayList<ClassNode> classNodesList) {
PluginConsole gui = new PluginConsole("Example String Decrypter"); 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" "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.", + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"}); new String[]{"Continue", "Cancel"});
if(dialogue.promptChoice() == 0) if(dialog.promptChoice() == 0)
{ {
for(ClassNode cn : classNodesList) for(ClassNode cn : classNodesList)
{ {

View file

@ -1,5 +1,5 @@
import the.bytecode.club.bytecodeviewer.api.* 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.util.ArrayList;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -17,12 +17,12 @@ public class ExampleStringDecrypter extends Plugin {
public void execute(ArrayList<ClassNode> classNodesList) { public void execute(ArrayList<ClassNode> classNodesList) {
PluginConsole gui = new PluginConsole(activeContainer.name + "Example String Decrypter"); 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" "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.", + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"}); new String[]{"Continue", "Cancel"});
if(dialogue.promptChoice() == 0) if(dialog.promptChoice() == 0)
{ {
for(ClassNode cn : classNodesList) for(ClassNode cn : classNodesList)
{ {

View file

@ -3,10 +3,10 @@
*/ */
var PluginConsole = Java.type("the.bytecode.club.bytecodeviewer.api.PluginConsole"); 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 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" "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.", + "\nfor each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
["Continue", "Cancel"]); ["Continue", "Cancel"]);
@ -16,7 +16,7 @@ function execute(classNodeList)
{ {
gui = new PluginConsole("Skeleton"); gui = new PluginConsole("Skeleton");
if(dialogue.promptChoice() == 0) if(dialog.promptChoice() == 0)
{ {
var needsWarning = false; var needsWarning = false;

View file

@ -291,9 +291,12 @@ public class BytecodeViewer
resourceContainers.add(container); resourceContainers.add(container);
SwingUtilities.invokeLater(() -> SwingUtilities.invokeLater(() ->
{ {
try { try
{
viewer.resourcePane.addResourceContainer(container); viewer.resourcePane.addResourceContainer(container);
} catch (Exception e) { }
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
}); });
@ -344,7 +347,7 @@ public class BytecodeViewer
/** /**
* Returns the ClassNode by the specified name * Returns the ClassNode by the specified name
* * <p>
* TODO anything relying on this should be rewritten to search using the resource container * TODO anything relying on this should be rewritten to search using the resource container
* *
* @param name the class name * @param name the class name
@ -378,13 +381,14 @@ public class BytecodeViewer
/** /**
* Returns all of the loaded resource containers * Returns all of the loaded resource containers
*/ */
public static List<ResourceContainer> getResourceContainers() { public static List<ResourceContainer> getResourceContainers()
{
return resourceContainers; return resourceContainers;
} }
/** /**
* Grabs the file contents of the loaded resources. * Grabs the file contents of the loaded resources.
* * <p>
* TODO anything relying on this should be rewritten to use the resource container's getFileContents * TODO anything relying on this should be rewritten to use the resource container's getFileContents
* *
* @param name the file name * @param name the file name
@ -410,7 +414,7 @@ public class BytecodeViewer
/** /**
* Gets all of the loaded classes as an array list * Gets all of the loaded classes as an array list
* * <p>
* TODO: remove this and replace it with: * TODO: remove this and replace it with:
* BytecodeViewer.getResourceContainers().forEach(container -> { * BytecodeViewer.getResourceContainers().forEach(container -> {
* execute(new ArrayList<>(container.resourceClasses.values())); * execute(new ArrayList<>(container.resourceClasses.values()));
@ -439,9 +443,12 @@ public class BytecodeViewer
if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected())
return true; return true;
try { try
{
return compile(false, false); return compile(false, false);
} catch (NullPointerException ignored) { }
catch (NullPointerException ignored)
{
return false; return false;
} }
} }
@ -539,7 +546,9 @@ public class BytecodeViewer
PluginWriter writer = new PluginWriter(DiskReader.loadAsString(file.getAbsolutePath()), file.getName()); PluginWriter writer = new PluginWriter(DiskReader.loadAsString(file.getAbsolutePath()), file.getName());
writer.setSourceFile(file); writer.setSourceFile(file);
writer.setVisible(true); writer.setVisible(true);
} catch (Exception e) { }
catch (Exception e)
{
BytecodeViewer.handleException(e); BytecodeViewer.handleException(e);
} }
@ -672,12 +681,12 @@ public class BytecodeViewer
{ {
if (ask) 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?" + "Are you sure you want to reset the workspace?" +
"\n\rIt will also reset your file navigator and search.", "\n\rIt will also reset your file navigator and search.",
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() != 0) if (dialog.promptChoice() != 0)
return; return;
} }

View file

@ -26,9 +26,13 @@ public class Configuration
public static String javaTools = ""; public static String javaTools = "";
public static File krakatauTempDir; public static File krakatauTempDir;
public static File krakatauTempJar; public static File krakatauTempJar;
public static boolean displayParentInTab = false; //also change in the main GUI public static boolean displayParentInTab = false; //also change in the main GUI
public static boolean simplifiedTabNames = false; 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 forceResourceUpdateFromClassNode = false; //TODO add to GUI
public static boolean showDarkLAFComponentIcons = false; public static boolean showDarkLAFComponentIcons = false;
public static boolean currentlyDumping = false; public static boolean currentlyDumping = false;

View file

@ -2,7 +2,7 @@ package the.bytecode.club.bytecodeviewer;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.gui.components.RunOptions; 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 the.bytecode.club.bytecodeviewer.util.JarUtils;
import javax.swing.*; import javax.swing.*;
@ -31,7 +31,7 @@ public class GlobalHotKeys
{ {
Configuration.lastHotKeyExecuted = System.currentTimeMillis(); 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", "APKs, DEX, Class Files or Zip/Jar/War Archives",
Constants.SUPPORTED_FILE_EXTENSIONS); Constants.SUPPORTED_FILE_EXTENSIONS);
@ -101,7 +101,7 @@ public class GlobalHotKeys
if (!file.getAbsolutePath().endsWith(".zip")) if (!file.getAbsolutePath().endsWith(".zip"))
file = new File(file.getAbsolutePath() + ".zip"); file = new File(file.getAbsolutePath() + ".zip");
if (!DialogueUtils.canOverwriteFile(file)) if (!DialogUtils.canOverwriteFile(file))
return; return;
final File file2 = file; final File file2 = file;

View file

@ -14,7 +14,7 @@ import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -229,7 +229,7 @@ public class BCV
* Asks if the user would like to overwrite the file * Asks if the user would like to overwrite the file
*/ */
public static boolean canOverwriteFile(File file) { public static boolean canOverwriteFile(File file) {
return DialogueUtils.canOverwriteFile(file); return DialogUtils.canOverwriteFile(file);
} }
public static void hideFrame(JFrame frame, long milliseconds) public static void hideFrame(JFrame frame, long milliseconds)
@ -247,6 +247,40 @@ public class BCV
}, "Timed Swing Hide").start(); }, "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. * Returns the wrapped Krakatau Decompiler instance.
* *

View file

@ -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.TranslatedJMenu;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; 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.*; import static the.bytecode.club.bytecodeviewer.Constants.*;
/*************************************************************************** /***************************************************************************
@ -127,13 +127,13 @@ public class MainViewerGUI extends JFrame
//all of the settings main menu components //all of the settings main menu components
public final JMenu rstaTheme = new TranslatedJMenu("Text Area Theme", TranslatedComponents.TEXT_AREA_THEME); 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 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 JMenu lafTheme = new TranslatedJMenu("Window Theme", TranslatedComponents.WINDOW_THEME);
public final JMenuItem lafThemeSettings = new TranslatedJMenuItem("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 JMenu language = new TranslatedJMenu("Language", TranslatedComponents.LANGUAGE);
public final JMenuItem languageSettings = new TranslatedJMenuItem("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 JMenu fontSize = new TranslatedJMenu("Font Size", TranslatedComponents.FONT_SIZE);
public final JSpinner fontSpinner = new JSpinner(); public final JSpinner fontSpinner = new JSpinner();
public final Map<RSTATheme, JRadioButtonMenuItem> rstaThemes = new HashMap<>(); public final Map<RSTATheme, JRadioButtonMenuItem> rstaThemes = new HashMap<>();
@ -163,7 +163,7 @@ public class MainViewerGUI extends JFrame
//apk conversion settings //apk conversion settings
public final JMenu apkConversionSecondaryMenu = new TranslatedJMenu("APK Conversion/Decoding", TranslatedComponents.APK_CONVERSION_DECODING); 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 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 ButtonGroup apkConversionGroup = new ButtonGroup();
public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar"); public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar");
public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify"); public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify");
@ -171,14 +171,14 @@ public class MainViewerGUI extends JFrame
//CFIDE settings //CFIDE settings
public final JMenu bytecodeDecompilerSettingsSecondaryMenu = new TranslatedJMenu("Bytecode Decompiler", TranslatedComponents.BYTECODE_DECOMPILER); public final JMenu bytecodeDecompilerSettingsSecondaryMenu = new TranslatedJMenu("Bytecode Decompiler", TranslatedComponents.BYTECODE_DECOMPILER);
public final JMenuItem bytecodeDecompilerSettings = new TranslatedJMenuItem("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 final JCheckBoxMenuItem appendBracketsToLabels = new TranslatedJCheckBoxMenuItem("Append Brackets To Labels", TranslatedComponents.APPEND_BRACKETS_TO_LABEL);
public JCheckBoxMenuItem debugHelpers = new TranslatedJCheckBoxMenuItem("Debug Helpers", TranslatedComponents.DEBUG_HELPERS); public JCheckBoxMenuItem debugHelpers = new TranslatedJCheckBoxMenuItem("Debug Helpers", TranslatedComponents.DEBUG_HELPERS);
//FernFlower settings //FernFlower settings
public final JMenu fernFlowerSettingsSecondaryMenu = new TranslatedJMenu("FernFlower Settings", TranslatedComponents.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 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 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 rsy = new TranslatedJCheckBoxMenuItem("Hide synthetic class members", TranslatedComponents.HIDE_SYNTHETIC_CLASS_MEMBERS);
public TranslatedJCheckBoxMenuItem din = new TranslatedJCheckBoxMenuItem("Decompile inner classes", TranslatedComponents.DECOMPILE_INNER_CLASSES); public TranslatedJCheckBoxMenuItem din = new TranslatedJCheckBoxMenuItem("Decompile inner classes", TranslatedComponents.DECOMPILE_INNER_CLASSES);
@ -202,7 +202,7 @@ public class MainViewerGUI extends JFrame
//Procyon //Procyon
public final JMenu procyonSettingsSecondaryMenu = new TranslatedJMenu("Procyon Settings", TranslatedComponents.PROCYON_SETTINGS); public final JMenu procyonSettingsSecondaryMenu = new TranslatedJMenu("Procyon Settings", TranslatedComponents.PROCYON_SETTINGS);
public final JMenuItem procyonSettings = new TranslatedJMenuItem("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 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 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); 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 //CFR
public final JMenu cfrSettingsSecondaryMenu = new TranslatedJMenu("CFR Settings", TranslatedComponents.CFR_SETTINGS); public final JMenu cfrSettingsSecondaryMenu = new TranslatedJMenu("CFR Settings", TranslatedComponents.CFR_SETTINGS);
public final JMenuItem cfrSettings = new TranslatedJMenuItem("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 decodeEnumSwitch = new TranslatedJCheckBoxMenuItem("Decode Enum Switch", TranslatedComponents.DECODE_ENUM_SWITCH);
public final JCheckBoxMenuItem sugarEnums = new TranslatedJCheckBoxMenuItem("SugarEnums", TranslatedComponents.SUGARENUMS); public final JCheckBoxMenuItem sugarEnums = new TranslatedJCheckBoxMenuItem("SugarEnums", TranslatedComponents.SUGARENUMS);
public final JCheckBoxMenuItem decodeStringSwitch = new TranslatedJCheckBoxMenuItem("Decode String Switch", TranslatedComponents.DECODE_STRING_SWITCH); 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(setJavac);
settingsMainMenu.add(new JSeparator()); 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 // it might be better to leave it as a secondary menu
settingsMainMenu.add(apkConversionSecondaryMenu); settingsMainMenu.add(apkConversionSecondaryMenu);
//settingsMainMenu.add(useNewSettingsDialogue ? apkConversionSettings : apkConversionMenu); //settingsMainMenu.add(useNewSettingsDialog ? apkConversionSettings : apkConversionMenu);
settingsMainMenu.add(new JSeparator()); settingsMainMenu.add(new JSeparator());
@ -420,8 +420,8 @@ public class MainViewerGUI extends JFrame
apkConversionGroup.add(apkConversionDex); apkConversionGroup.add(apkConversionDex);
apkConversionGroup.add(apkConversionEnjarify); apkConversionGroup.add(apkConversionEnjarify);
apkConversionGroup.setSelected(apkConversionDex.getModel(), true); apkConversionGroup.setSelected(apkConversionDex.getModel(), true);
//apkConversionSettingsDialogue = new SettingsDialogue(apkConversionSecondaryMenu, new JPanel()); //apkConversionSettingsDialog = new SettingsDialogue(apkConversionSecondaryMenu, new JPanel());
apkConversionSettings.addActionListener((e)-> apkConversionSettingsDialogue.showDialogue()); apkConversionSettings.addActionListener((e)-> apkConversionSettingsDialog.showDialog());
ButtonGroup rstaGroup = new ButtonGroup(); ButtonGroup rstaGroup = new ButtonGroup();
for (RSTATheme t : RSTATheme.values()) for (RSTATheme t : RSTATheme.values())
@ -444,8 +444,8 @@ public class MainViewerGUI extends JFrame
rstaTheme.add(item); rstaTheme.add(item);
} }
rstaThemeSettingsDialogue = new SettingsDialogue(rstaTheme, new JPanel()); rstaThemeSettingsDialog = new SettingsDialog(rstaTheme, new JPanel());
rstaThemeSettings.addActionListener((e)-> rstaThemeSettingsDialogue.showDialogue()); rstaThemeSettings.addActionListener((e)-> rstaThemeSettingsDialog.showDialog());
ButtonGroup lafGroup = new ButtonGroup(); ButtonGroup lafGroup = new ButtonGroup();
for (LAFTheme theme : LAFTheme.values()) for (LAFTheme theme : LAFTheme.values())
@ -479,8 +479,8 @@ public class MainViewerGUI extends JFrame
lafTheme.add(item); lafTheme.add(item);
} }
lafThemeSettingsDialogue = new SettingsDialogue(lafTheme, new JPanel()); lafThemeSettingsDialog = new SettingsDialog(lafTheme, new JPanel());
lafThemeSettings.addActionListener((e)-> lafThemeSettingsDialogue.showDialogue()); lafThemeSettings.addActionListener((e)-> lafThemeSettingsDialog.showDialog());
ButtonGroup languageGroup = new ButtonGroup(); ButtonGroup languageGroup = new ButtonGroup();
for (Language l : Language.values()) for (Language l : Language.values())
@ -501,12 +501,12 @@ public class MainViewerGUI extends JFrame
language.add(item); language.add(item);
} }
languageSettingsDialogue = new SettingsDialogue(language, new JPanel()); languageSettingsDialog = new SettingsDialog(language, new JPanel());
languageSettings.addActionListener((e)-> languageSettingsDialogue.showDialogue()); languageSettings.addActionListener((e)-> languageSettingsDialog.showDialog());
visualSettings.add(useNewSettingsDialogue ? lafThemeSettings : lafTheme); visualSettings.add(useNewSettingsDialog ? lafThemeSettings : lafTheme);
visualSettings.add(useNewSettingsDialogue ? rstaThemeSettings : rstaTheme); visualSettings.add(useNewSettingsDialog ? rstaThemeSettings : rstaTheme);
visualSettings.add(useNewSettingsDialogue ? languageSettings : language); visualSettings.add(useNewSettingsDialog ? languageSettings : language);
visualSettings.add(fontSize); visualSettings.add(fontSize);
visualSettings.add(showFileInTabTitle); visualSettings.add(showFileInTabTitle);
visualSettings.add(simplifyNameInTabTitle); visualSettings.add(simplifyNameInTabTitle);
@ -514,7 +514,7 @@ public class MainViewerGUI extends JFrame
visualSettings.add(showClassMethods); visualSettings.add(showClassMethods);
//PROCYON SETTINGS //PROCYON SETTINGS
settingsMainMenu.add(useNewSettingsDialogue ? procyonSettings : procyonSettingsSecondaryMenu); settingsMainMenu.add(useNewSettingsDialog ? procyonSettings : procyonSettingsSecondaryMenu);
procyonSettingsSecondaryMenu.add(alwaysGenerateExceptionVars); procyonSettingsSecondaryMenu.add(alwaysGenerateExceptionVars);
procyonSettingsSecondaryMenu.add(excludeNestedTypes); procyonSettingsSecondaryMenu.add(excludeNestedTypes);
procyonSettingsSecondaryMenu.add(showDebugLineNumbers); procyonSettingsSecondaryMenu.add(showDebugLineNumbers);
@ -529,11 +529,11 @@ public class MainViewerGUI extends JFrame
procyonSettingsSecondaryMenu.add(retainPointlessSwitches); procyonSettingsSecondaryMenu.add(retainPointlessSwitches);
procyonSettingsSecondaryMenu.add(retainRedunantCasts); procyonSettingsSecondaryMenu.add(retainRedunantCasts);
procyonSettingsSecondaryMenu.add(unicodeOutputEnabled); procyonSettingsSecondaryMenu.add(unicodeOutputEnabled);
procyonSettingsDialogue = new SettingsDialogue(procyonSettingsSecondaryMenu, new JPanel()); procyonSettingsDialog = new SettingsDialog(procyonSettingsSecondaryMenu, new JPanel());
procyonSettings.addActionListener((e)-> procyonSettingsDialogue.showDialogue()); procyonSettings.addActionListener((e)-> procyonSettingsDialog.showDialog());
//CFR SETTINGS //CFR SETTINGS
settingsMainMenu.add(useNewSettingsDialogue ? cfrSettings : cfrSettingsSecondaryMenu); settingsMainMenu.add(useNewSettingsDialog ? cfrSettings : cfrSettingsSecondaryMenu);
cfrSettingsSecondaryMenu.add(decodeEnumSwitch); cfrSettingsSecondaryMenu.add(decodeEnumSwitch);
cfrSettingsSecondaryMenu.add(sugarEnums); cfrSettingsSecondaryMenu.add(sugarEnums);
cfrSettingsSecondaryMenu.add(decodeStringSwitch); cfrSettingsSecondaryMenu.add(decodeStringSwitch);
@ -578,11 +578,11 @@ public class MainViewerGUI extends JFrame
cfrSettingsSecondaryMenu.add(recoveryTypehInts); cfrSettingsSecondaryMenu.add(recoveryTypehInts);
cfrSettingsSecondaryMenu.add(forceTurningIFs); cfrSettingsSecondaryMenu.add(forceTurningIFs);
cfrSettingsSecondaryMenu.add(forLoopAGGCapture); cfrSettingsSecondaryMenu.add(forLoopAGGCapture);
cfrSettingsDialogue = new SettingsDialogue(cfrSettingsSecondaryMenu, new JPanel()); cfrSettingsDialog = new SettingsDialog(cfrSettingsSecondaryMenu, new JPanel());
cfrSettings.addActionListener((e)-> cfrSettingsDialogue.showDialogue()); cfrSettings.addActionListener((e)-> cfrSettingsDialog.showDialog());
//FERNFLOWER SETTINGS //FERNFLOWER SETTINGS
settingsMainMenu.add(useNewSettingsDialogue ? fernFlowerSettings : fernFlowerSettingsSecondaryMenu); settingsMainMenu.add(useNewSettingsDialog ? fernFlowerSettings : fernFlowerSettingsSecondaryMenu);
fernFlowerSettingsSecondaryMenu.add(ren); fernFlowerSettingsSecondaryMenu.add(ren);
fernFlowerSettingsSecondaryMenu.add(dc4); fernFlowerSettingsSecondaryMenu.add(dc4);
fernFlowerSettingsSecondaryMenu.add(nns); fernFlowerSettingsSecondaryMenu.add(nns);
@ -602,15 +602,15 @@ public class MainViewerGUI extends JFrame
fernFlowerSettingsSecondaryMenu.add(udv); fernFlowerSettingsSecondaryMenu.add(udv);
fernFlowerSettingsSecondaryMenu.add(fdi); fernFlowerSettingsSecondaryMenu.add(fdi);
fernFlowerSettingsSecondaryMenu.add(asc); fernFlowerSettingsSecondaryMenu.add(asc);
fernFlowerSettingsDialogue = new SettingsDialogue(fernFlowerSettingsSecondaryMenu, new JPanel()); fernFlowerSettingsDialog = new SettingsDialog(fernFlowerSettingsSecondaryMenu, new JPanel());
fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialogue.showDialogue()); fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialog.showDialog());
//CFIDE SETTINGS //CFIDE SETTINGS
settingsMainMenu.add(useNewSettingsDialogue ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu); settingsMainMenu.add(useNewSettingsDialog ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu);
bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers); bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers);
bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels); bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels);
bytecodeDecompilerSettingsDialogue = new SettingsDialogue(bytecodeDecompilerSettingsSecondaryMenu, new JPanel()); bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel());
bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialogue.showDialogue()); bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog());
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning()); deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync()); forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync());
@ -853,11 +853,11 @@ public class MainViewerGUI extends JFrame
public void reloadResources() 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?", "Are you sure you wish to reload the resources?",
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0) if (dialog.promptChoice() == 0)
{ {
LazyNameUtil.reset(); LazyNameUtil.reset();
ArrayList<File> reopen = new ArrayList<>(); ArrayList<File> reopen = new ArrayList<>();
@ -885,7 +885,7 @@ public class MainViewerGUI extends JFrame
public void selectFile() 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", "APKs, DEX, Class Files or Zip/Jar/War Archives",
Constants.SUPPORTED_FILE_EXTENSIONS); Constants.SUPPORTED_FILE_EXTENSIONS);
@ -899,7 +899,7 @@ public class MainViewerGUI extends JFrame
public void openExternalPlugin() public void openExternalPlugin()
{ {
final File file = DialogueUtils.fileChooser("Select External Plugin", final File file = DialogUtils.fileChooser("Select External Plugin",
"External Plugin", "External Plugin",
Configuration.getLastPluginDirectory(), Configuration.getLastPluginDirectory(),
PluginManager.fileFilter(), PluginManager.fileFilter(),
@ -917,11 +917,11 @@ public class MainViewerGUI extends JFrame
public void askBeforeExiting() public void askBeforeExiting()
{ {
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Exit", MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Exit",
"Are you sure you want to exit?", "Are you sure you want to exit?",
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0) if (dialog.promptChoice() == 0)
{ {
Configuration.canExit = true; Configuration.canExit = true;
System.exit(0); System.exit(0);

View file

@ -4,7 +4,6 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.lang.reflect.Method;
import static javax.swing.JOptionPane.*; import static javax.swing.JOptionPane.*;
@ -86,7 +85,7 @@ public class BetterJOptionPane
getRootFrame() : parentComponent).getComponentOrientation()); getRootFrame() : parentComponent).getComponentOrientation());
int style = styleFromMessageType(messageType); int style = styleFromMessageType(messageType);
JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)->
{ {
pane.selectInitialValue(); pane.selectInitialValue();
}); });
@ -130,7 +129,7 @@ public class BetterJOptionPane
getRootFrame() : parentComponent).getComponentOrientation()); getRootFrame() : parentComponent).getComponentOrientation());
int style = styleFromMessageType(messageType); int style = styleFromMessageType(messageType);
JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)->
{ {
pane.selectInitialValue(); pane.selectInitialValue();
}); });
@ -145,14 +144,14 @@ public class BetterJOptionPane
return value; 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 throws HeadlessException
{ {
//create a new option pane with a empty text and just 'ok' //create a new option pane with a empty text and just 'ok'
JOptionPane pane = new JOptionPane(""); JOptionPane pane = new JOptionPane("");
pane.add(panel, 0); 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()); int newHeight = Math.min(minimumHeight, d.getHeight());
d.setMinimumSize(new Dimension(d.getWidth(), newHeight)); 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); JDialog dialog = pane.createDialog(parentComponent, title);
if (JDialog.isDefaultLookAndFeelDecorated()) { if (JDialog.isDefaultLookAndFeelDecorated()) {
@ -177,7 +176,7 @@ public class BetterJOptionPane
onCreate.onCreate(dialog); 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) 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 dialog.setLocationRelativeTo(null); //TODO check if BytecodeViewer.viewer is better on multi monitor for this edgecase
else else

View file

@ -8,13 +8,13 @@ import javax.swing.*;
* @author Konloch * @author Konloch
* @since 6/26/2021 * @since 6/26/2021
*/ */
public class MultipleChoiceDialogue public class MultipleChoiceDialog
{ {
private final String title; private final String title;
private final String description; private final String description;
private final String[] options; private final String[] options;
public MultipleChoiceDialogue(String title, String description, String[] options) public MultipleChoiceDialog(String title, String description, String[] options)
{ {
this.title = title; this.title = title;
this.description = description; this.description = description;

View file

@ -5,7 +5,7 @@ import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -30,22 +30,22 @@ import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialo
* @since 7/19/2021 * @since 7/19/2021
*/ */
public class SettingsDialogue extends JScrollPane public class SettingsDialog extends JScrollPane
{ {
public static final List<JComponent> components = new ArrayList<>(); public static final List<JComponent> components = new ArrayList<>();
public static final List<JDialog> dialogues = new ArrayList<>(); public static final List<JDialog> dialogs = new ArrayList<>();
private final List<JMenuItem> options = new ArrayList<>(); private final List<JMenuItem> options = new ArrayList<>();
private final JMenu menu; private final JMenu menu;
private final JPanel display; private final JPanel display;
public SettingsDialogue(JMenu menu, JPanel display) public SettingsDialog(JMenu menu, JPanel display)
{ {
super(display); super(display);
this.menu = menu; this.menu = menu;
this.display = display; this.display = display;
if(!useNewSettingsDialogue) if(!useNewSettingsDialog)
return; return;
List<JMenuItem> options = new ArrayList<>(); List<JMenuItem> options = new ArrayList<>();
@ -75,9 +75,9 @@ public class SettingsDialogue extends JScrollPane
options.forEach(jMenuItem -> jMenuItem.setArmed(false)); 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() private void buildPanel()

View file

@ -4,7 +4,7 @@ import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.*; import com.github.weisj.darklaf.theme.*;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; 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.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents;
@ -118,13 +118,14 @@ public enum LAFTheme
if(BytecodeViewer.viewer != null) if(BytecodeViewer.viewer != null)
{ {
BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon); 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 //TODO instead of hiding the currently opened dialogs it should update/rebuild the dialogs
SettingsDialogue.dialogues.forEach(Dialog::dispose);
//hide any existing jDialogs
SettingsDialog.dialogs.forEach(Dialog::dispose);
} }
} }

View file

@ -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.TranslatedComponents;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; 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.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage;
@ -101,7 +101,7 @@ public class PluginWriter extends JFrame
public void openPlugin() public void openPlugin()
{ {
final File file = DialogueUtils.fileChooser("Select External Plugin", final File file = DialogUtils.fileChooser("Select External Plugin",
"External Plugin", "External Plugin",
Configuration.getLastPluginDirectory(), Configuration.getLastPluginDirectory(),
PluginManager.fileFilter(), PluginManager.fileFilter(),
@ -177,7 +177,7 @@ public class PluginWriter extends JFrame
if (!path.endsWith("." + ext)) if (!path.endsWith("." + ext))
path = path + "." + ext; path = path + "." + ext;
if (!DialogueUtils.canOverwriteFile(path)) if (!DialogUtils.canOverwriteFile(path))
return; return;
//swap from save-as to having a defined path each save //swap from save-as to having a defined path each save

View file

@ -10,7 +10,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.resources.IconResources; import the.bytecode.club.bytecodeviewer.resources.IconResources;
import the.bytecode.club.bytecodeviewer.api.*; 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 the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import javax.swing.*; import javax.swing.*;
@ -55,12 +55,12 @@ public class AllatoriStringDecrypter extends Plugin
{ {
PluginConsole frame = new PluginConsole(activeContainer.name + " - Allatori String Decrypter"); 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" "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.", + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"}); new String[]{"Continue", "Cancel"});
if (dialogue.promptChoice() == 0) if (dialog.promptChoice() == 0)
{ {
try try
{ {

View file

@ -23,7 +23,7 @@ public class ChangeClassFileVersions extends Plugin
@Override @Override
public void execute(ArrayList<ClassNode> classNodeList) public void execute(ArrayList<ClassNode> classNodeList)
{ {
//prompt dialogue for version number //prompt dialog for version number
// TODO: include a little diagram of what JDK is which number // TODO: include a little diagram of what JDK is which number
int newVersion = Integer.parseInt(BytecodeViewer.showInput("Class Version Number: (52 = JDK 8)")); int newVersion = Integer.parseInt(BytecodeViewer.showInput("Class Version Number: (52 = JDK 8)"));

View file

@ -10,7 +10,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.BCV; import the.bytecode.club.bytecodeviewer.api.BCV;
import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole; 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.*; import static the.bytecode.club.bytecodeviewer.Constants.*;
@ -47,12 +47,12 @@ public class ZStringArrayDecrypter extends Plugin
PluginConsole gui = new PluginConsole(activeContainer.name + " - ZStringArray Decrypter"); PluginConsole gui = new PluginConsole(activeContainer.name + " - ZStringArray Decrypter");
StringBuilder out = new StringBuilder(); 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" "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.", + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"}); new String[]{"Continue", "Cancel"});
if (dialogue.promptChoice() == 0) if (dialog.promptChoice() == 0)
{ {
boolean needsWarning = false; boolean needsWarning = false;
for (Class<?> cn : for (Class<?> cn :

View file

@ -5,7 +5,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.SettingsSerializer; import the.bytecode.club.bytecodeviewer.SettingsSerializer;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; 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 the.bytecode.club.bytecodeviewer.util.JRTExtractor;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -222,7 +222,7 @@ public class ExternalResources
public void selectPython2() 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(), TranslatedStrings.PYTHON_2_EXECUTABLE.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -236,7 +236,7 @@ public class ExternalResources
public void selectPython3() 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(), TranslatedStrings.PYTHON_3_EXECUTABLE.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -250,7 +250,7 @@ public class ExternalResources
public void selectJava() 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(), TranslatedStrings.JAVA_EXECUTABLE.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -263,7 +263,7 @@ public class ExternalResources
public void selectJavac() 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(), TranslatedStrings.JAVAC_EXECUTABLE.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -276,7 +276,7 @@ public class ExternalResources
public void selectJRERTLibrary() 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(), TranslatedStrings.JAVA_RT_JAR.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -289,7 +289,7 @@ public class ExternalResources
public void selectJavaTools() 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(), TranslatedStrings.JAVA_TOOLS_JAR.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);
@ -302,7 +302,7 @@ public class ExternalResources
public void selectOptionalLibraryFolder() 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(), TranslatedStrings.OPTIONAL_LIBRARY_FOLDER.toString(),
FileChooser.EVERYTHING); FileChooser.EVERYTHING);

View file

@ -8,7 +8,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -51,7 +51,7 @@ public class ResourceDecompiling
if (!file.getAbsolutePath().endsWith(".zip")) if (!file.getAbsolutePath().endsWith(".zip"))
file = new File(file.getAbsolutePath() + ".zip"); file = new File(file.getAbsolutePath() + ".zip");
if (!DialogueUtils.canOverwriteFile(file)) if (!DialogUtils.canOverwriteFile(file))
return; return;
final File javaSucks = file; final File javaSucks = file;
@ -210,7 +210,7 @@ public class ResourceDecompiling
BytecodeViewer.updateBusyStatus(true); BytecodeViewer.updateBusyStatus(true);
final String path = MiscUtils.append(file, ".java"); final String path = MiscUtils.append(file, ".java");
if (!DialogueUtils.canOverwriteFile(path)) if (!DialogUtils.canOverwriteFile(path))
return; return;
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(

View file

@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.resources.exporting.impl;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; 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.ResourceContainer;
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter;
import the.bytecode.club.bytecodeviewer.util.*; 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.fs;
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* @author Konloch * @author Konloch
* @since 6/27/2021 * @since 6/27/2021
*/ */
public class APKExport implements Exporter public class APKExport implements Exporter
{ {
@Override @Override
@ -49,11 +68,11 @@ public class APKExport implements Exporter
//if theres only one file in the container don't bother asking //if theres only one file in the container don't bother asking
if (validContainers.size() >= 2) 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?", "Which file would you like to export as an APK?",
validContainersNames.toArray(new String[0])); validContainersNames.toArray(new String[0]));
container = containers.get(dialogue.promptChoice()); container = containers.get(dialog.promptChoice());
} }
} else { } else {
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on." + 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"; output = output + ".apk";
final File file2 = new File(output); final File file2 = new File(output);
if (!DialogueUtils.canOverwriteFile(file2)) if (!DialogUtils.canOverwriteFile(file2))
return; return;
Thread saveThread = new Thread(() -> Thread saveThread = new Thread(() ->

View file

@ -5,7 +5,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter;
import the.bytecode.club.bytecodeviewer.util.Dex2Jar; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -51,7 +51,7 @@ public class DexExport implements Exporter
output = output + ".dex"; output = output + ".dex";
File outputPath = new File(output); File outputPath = new File(output);
if (!DialogueUtils.canOverwriteFile(outputPath)) if (!DialogUtils.canOverwriteFile(outputPath))
return; return;
Thread saveAsJar = new Thread(() -> Thread saveAsJar = new Thread(() ->

View file

@ -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.ExportJar;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; 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 javax.swing.*;
import java.io.File; import java.io.File;
@ -44,7 +44,7 @@ public class RunnableJarExporter implements Exporter
if (!path.endsWith(".jar")) if (!path.endsWith(".jar"))
path = path + ".jar"; path = path + ".jar";
if (!DialogueUtils.canOverwriteFile(path)) if (!DialogUtils.canOverwriteFile(path))
return; return;
new ExportJar(path).setVisible(true); new ExportJar(path).setVisible(true);

View file

@ -4,7 +4,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; 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 the.bytecode.club.bytecodeviewer.util.JarUtils;
import javax.swing.*; import javax.swing.*;
@ -43,7 +43,7 @@ public class ZipExport implements Exporter
if (!file.getAbsolutePath().endsWith(".zip")) if (!file.getAbsolutePath().endsWith(".zip"))
file = new File(file.getAbsolutePath() + ".zip"); file = new File(file.getAbsolutePath() + ".zip");
if (!DialogueUtils.canOverwriteFile(file)) if (!DialogUtils.canOverwriteFile(file))
return; return;
final File file2 = file; final File file2 = file;

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.translation;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections4.map.LinkedMap; import org.apache.commons.collections4.map.LinkedMap;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.BCV;
import the.bytecode.club.bytecodeviewer.resources.IconResources; import the.bytecode.club.bytecodeviewer.resources.IconResources;
import java.io.IOException; import java.io.IOException;
@ -114,7 +115,7 @@ public enum Language
//skip translating if the language config is missing the translation key //skip translating if the language config is missing the translation key
if(!translationMap.containsKey(text.key)) if(!translationMap.containsKey(text.key))
{ {
System.err.println("MISSING TRANSLATION KEY: " + text.key); BCV.logE(true, "MISSING TRANSLATION KEY: " + text.key);
continue; continue;
} }
@ -132,7 +133,7 @@ public enum Language
if(translatedComponents.getTranslatedComponentReference().runOnUpdate.isEmpty()) if(translatedComponents.getTranslatedComponentReference().runOnUpdate.isEmpty())
//&& TranslatedStrings.nameSet.contains(translation.name())) //&& 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; continue;
} }
@ -175,7 +176,7 @@ public enum Language
for(String key : translationMap.keySet()) for(String key : translationMap.keySet())
if(!existingKeys.contains(key)) if(!existingKeys.contains(key))
System.err.println(key + ","); BCV.logE(true, key + ",");
} }
public String getResourcePath() public String getResourcePath()

View file

@ -22,7 +22,7 @@ package the.bytecode.club.bytecodeviewer.translation;
* Translation keys for components (updates the component text on language change). * 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. * 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 * @author Konloch
* @since 6/28/2021 * @since 6/28/2021

View file

@ -1,5 +1,7 @@
package the.bytecode.club.bytecodeviewer.translation; package the.bytecode.club.bytecodeviewer.translation;
import the.bytecode.club.bytecodeviewer.api.BCV;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; 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). * 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 * @author Konloch
* @since 7/6/2021 * @since 7/6/2021
@ -32,10 +34,12 @@ import java.util.HashSet;
public enum TranslatedStrings public enum TranslatedStrings
{ {
BCV("BytecodeViewer"), PRODUCT("BCV"),
BYTECODEVIEWER("BytecodeViewer"), PRODUCTNAME("BytecodeViewer"),
BYTECODE_VIEWER("Bytecode Viewer"), PRODUCT_NAME("Bytecode Viewer"),
BYTECODE_H_VIEWER("Bytecode-Viewer"), PRODUCT_H_NAME("Bytecode-Viewer"),
WEBSITE("https://bytecodeviewer.com"),
TBC("https://the.bytecode.club"),
EDITABLE, EDITABLE,
JAVA, JAVA,
@ -124,14 +128,18 @@ public enum TranslatedStrings
{ {
if(text == null) if(text == null)
{ {
System.err.println("TranslatedStrings:"+name() + " - Missing Translation"); BCV.logE(true, "TranslatedStrings:"+name() + " - Missing Translation");
text = TEXT_ERROR; text = TEXT_ERROR;
} }
text = text.replace("%PRODUCTNAME%", BYTECODEVIEWER.toString()) //TODO this should be tokenized against the TranslatedStrings enum
.replace("%PRODUCT_NAME%", BYTECODE_VIEWER.toString()) text = text.replace("{PRODUCTNAME}", PRODUCTNAME.toString())
.replace("%PRODUCT-NAME%", BYTECODE_H_VIEWER.toString()) .replace("{PRODUCT_NAME}", PRODUCT_NAME.toString())
.replace("%BCV%", BCV.toString()); .replace("{PRODUCT-NAME}", PRODUCT_H_NAME.toString())
.replace("{PRODUCT}", PRODUCT.toString())
.replace("{TBV}", TBC.toString())
.replace("{WEBSITE}", WEBSITE.toString())
;
this.text = text; this.text = text;
} }

View file

@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.util;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; 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 the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*; import javax.swing.*;
@ -32,7 +32,7 @@ import java.io.File;
* @author Konloch * @author Konloch
* @since 7/1/2021 * @since 7/1/2021
*/ */
public class DialogueUtils public class DialogUtils
{ {
/** /**
* Asks if the user would like to overwrite the file * Asks if the user would like to overwrite the file
@ -48,11 +48,11 @@ public class DialogueUtils
public static boolean canOverwriteFile(File file) { public static boolean canOverwriteFile(File file) {
if (file.exists()) 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?", "Are you sure you wish to overwrite this existing file?",
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0) { if (dialog.promptChoice() == 0) {
file.delete(); file.delete();
return true; return true;

View file

@ -1,11 +1,10 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import java.util.Objects;
import me.konloch.kontainer.io.HTTPRequest; import me.konloch.kontainer.io.HTTPRequest;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; 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 the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*; import javax.swing.*;
@ -61,12 +60,12 @@ public class VersionChecker implements Runnable
if (VERSION != null && !VERSION.equals(version)) 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: " "Your version: " + VERSION + ", latest version: "
+ version + nl + "What would you like to do?", + version + nl + "What would you like to do?",
new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"}); new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"});
int result = outdatedDialogue.promptChoice(); int result = outdatedDialog.promptChoice();
if (result == 0) if (result == 0)
{ {
@ -100,11 +99,11 @@ public class VersionChecker implements Runnable
if (file.exists()) 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?", "The file " + file + " exists, would you like to overwrite it?",
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()}); new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (overwriteDialogue.promptChoice() != 0) if (overwriteDialog.promptChoice() != 0)
return; return;
file.delete(); file.delete();