From 7b70db07a05a0cb6c77616d7242be4797b4f03e7 Mon Sep 17 00:00:00 2001 From: BeboKhouja Date: Sun, 9 Jun 2024 09:49:24 +0700 Subject: [PATCH] Changed code, minor grammar improvements, removed stuff. --- CONTRIBUTING.md | 18 ++--- README.md | 17 ++-- .../project/adbgui/ExceptionHandler.java | 19 ++--- .../project/adbgui/MainFrame.java | 36 +++------ .../mokkachocolata/util/ExecuteCommand.form | 78 ------------------- .../mokkachocolata/util/ExecuteCommand.java | 70 ----------------- src/resources/localizedtexts.json | 4 +- 7 files changed, 36 insertions(+), 206 deletions(-) delete mode 100644 src/com/mokkachocolata/util/ExecuteCommand.form delete mode 100644 src/com/mokkachocolata/util/ExecuteCommand.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c6bc54..980857f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,19 +1,19 @@ # How to contribute -Thank you for contributing to ADB GUI. If you have any quesions please ask me in my [Discord Server](https://discord.gg/y6AcUNTKxX). +Thank you for contributing to ADB GUI. If you have any questions, please ask me in my [Discord Server](https://discord.gg/y6AcUNTKxX). -In this guide I will learn you how to contribute. +In this guide, I will learn you how to contribute. # Getting Started -Please do try to follow the committing style if you wanted to contribute, it makes the repository much more clean and consistent. +Please try to follow the committing style if you want to contribute, it makes the repository much more clean and consistent. - Do not squash commits - Explain what the commit does or what did you do in the commit message with less than 50 characters - Use the commit description if you can't fit what you did in the commit message - Use one of these prefixes in your commit messages: - - `fix` When you fixed a bug or maybe a flaw within the codebase - - `feat` When you added something within the codebase (can be anything) - - `tweak` When you do a little tweak in the codebase, like a tiny UI change - - `chore` When you do fix something, but it doesn't affect the app in terms of functionality - - `refactor` When you refactored the code, like cleaning up the code + - `fix` When you fixed a bug or a flaw within the codebase. + - `feature` When you added something within the codebase (can be anything). + - `tweak` When you do a little tweak in the codebase, like a tiny UI change. + - `minor` When you fix something, but it doesn't affect the app in terms of functionality. + - `refactor` When you refactored the code, like cleaning up the code. # Documentation -If you are writing a documentation for ADB GUI make sure that it's formatted correctly, friendly and understandable. \ No newline at end of file +If you are writing a documentation for ADB GUI, make sure that it's formatted correctly, friendly and understandable. \ No newline at end of file diff --git a/README.md b/README.md index c861972..fcf124c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ADB GUI -ADB GUI is a free and open source Java based application that adds a GUI based ADB (Android Debug Bridge). +ADB GUI is a free and open source Java-based program that adds a GUI-based ADB (Android Debug Bridge). # Getting Started 1. Install Java 17.0.2 or later. @@ -10,18 +10,17 @@ Ubuntu: sudo apt-get install openjdk-17-jre ``` ### Windows -1. To get started download the jar that is included in this application. +1. To get started, download the .jar that's included in this application. 2. Download ADB from the official Android Developers website: https://developer.android.com/studio/releases/platform-tools#downloads -3. Put it on the root folder "C:\adb" -4. Put an environment variable in PATH called "C:\adb" +3. Put it on the folder "C:\adb". +4. Put an environment variable in PATH called "C:\adb". 5. Restart your computer. -6. You are done! Use ADB GUI to have fun! +6. You are done! ### Ubuntu -1. To get started download the jar that is included in this application. +1. To get started, download the .jar that's included in this application. 2. Download ADB from the official Android Developers website: https://developer.android.com/studio/releases/platform-tools#downloads or run `sudo apt-get install adb` -3. You are done! Use ADB GUI to have fun! +3. You are done! # Features 1. Buttons to execute ADB commands. -2. Top bar. -3. Can execute custom commands instead of using buttons. In top bar. \ No newline at end of file +2. Top bar. \ No newline at end of file diff --git a/src/com/mokkachocolata/project/adbgui/ExceptionHandler.java b/src/com/mokkachocolata/project/adbgui/ExceptionHandler.java index fbdad07..825837e 100644 --- a/src/com/mokkachocolata/project/adbgui/ExceptionHandler.java +++ b/src/com/mokkachocolata/project/adbgui/ExceptionHandler.java @@ -7,9 +7,6 @@ import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.swt.widgets.Shell; import java.net.URISyntaxException; @@ -36,14 +33,14 @@ public void uncaughtException(Thread thread, Throwable exception) { if (new AddonLoader().getModsFolder().exists()) { logger.info("The details as explained below is shown.\nJava version " + getVersion() + "\nMods path: " + new AddonLoader().getModsFolder().toPath()); } - } catch (JarNotFoundException ignored) { - } catch (URISyntaxException ignored) { - } - MessageBox message = new MessageBox(new Shell(), SWT.OK); - message.setMessage("An error has occurred. The application will now terminate."); - int chosen = message.open(); - if (chosen == SWT.OK) { - System.exit(0); + } catch (JarNotFoundException | URISyntaxException ignored) { } + System.exit(-1); + // MessageBox message = new MessageBox(new Shell(), SWT.OK); + // message.setMessage("An error has occurred. The application will now terminate."); + // int chosen = message.open(); + // if (chosen == SWT.OK) { + // System.exit(0); + // } } } diff --git a/src/com/mokkachocolata/project/adbgui/MainFrame.java b/src/com/mokkachocolata/project/adbgui/MainFrame.java index 5ddc572..89c02cc 100644 --- a/src/com/mokkachocolata/project/adbgui/MainFrame.java +++ b/src/com/mokkachocolata/project/adbgui/MainFrame.java @@ -4,7 +4,6 @@ // Project imports -import com.mokkachocolata.util.ExecuteCommand; import com.mokkachocolata.util.Link; import com.mokkachocolata.util.Localization; import io.sentry.Sentry; @@ -35,11 +34,10 @@ public class MainFrame extends JFrame implements ActionListener, MenuListener, K //Vars final JTabbedPane tabbedPane = new JTabbedPane(); JMenuBar menubar1; - JMenu filemenu1,advancedmenu1,helpmenu1; - JMenuItem exitmenu1,aboutmenu1,executecommandmenu2,discordmenu3,githubmenu3,languagemenu1; + JMenu filemenu1,helpmenu1; + JMenuItem exitmenu1,aboutmenu1,discordmenu3,githubmenu3,languagemenu1; JButton button1,button2,button3,button4; JLabel text1; - final ExecuteCommand CommandBar = new ExecuteCommand(); // ImageIcon logo = new ImageIcon(".//res//appicon.png") final JList list = new JList<>(); @@ -54,7 +52,7 @@ public class MainFrame extends JFrame implements ActionListener, MenuListener, K public void init() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { //Window config UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - setTitle(localization.getLocalizedText("WINDOW_TITLE")); + setTitle(localization.getLocalizedText("WINDOW_TITLE") + " " + App.version); setIconImage(Toolkit.getDefaultToolkit(). getImage(this.getClass().getResource("/resources/appicon.png"))); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); @@ -65,18 +63,16 @@ public void init() throws UnsupportedLookAndFeelException, ClassNotFoundExceptio panel.setMaximumSize(new Dimension(100, 100)); menubar1 = new JMenuBar(); filemenu1 = new JMenu("File"); - advancedmenu1 = new JMenu("Advanced"); helpmenu1 = new JMenu("Help"); exitmenu1 = new JMenuItem("Exit"); aboutmenu1 = new JMenuItem("About"); - executecommandmenu2 = new JMenuItem("Execute command"); discordmenu3 = new JMenuItem("Discord Server"); githubmenu3 = new JMenuItem("GitHub Repository"); - button1 = new JButton("Reboot device"); - button2 = new JButton("Reboot to recovery"); + button1 = new JButton("Restart device"); + button2 = new JButton("Restart to recovery"); languagemenu1 = new JMenuItem(localization.getLocalizedText("LANGUAGE_CHANGE_OPTION")); button3 = new JButton(localization.getLocalizedText("REBOOT_DEVICE_SIDELOAD")); - button4 = new JButton("Reconnect device"); + button4 = new JButton("Kill server"); text1 = new JLabel(localization.getLocalizedText("ENABLE_DEBUGGING_WARNING")); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); list.setModel(model); @@ -92,19 +88,15 @@ public void init() throws UnsupportedLookAndFeelException, ClassNotFoundExceptio add(wrapper); this.setJMenuBar(menubar1); menubar1.add(filemenu1); - menubar1.add(advancedmenu1); menubar1.add(helpmenu1); - advancedmenu1.setMnemonic(KeyEvent.VK_A); filemenu1.setMnemonic(KeyEvent.VK_F); aboutmenu1.setMnemonic(KeyEvent.VK_A); exitmenu1.setMnemonic(KeyEvent.VK_E); - executecommandmenu2.setMnemonic(KeyEvent.VK_E); helpmenu1.setMnemonic(KeyEvent.VK_H); discordmenu3.setMnemonic(KeyEvent.VK_D); githubmenu3.setMnemonic(KeyEvent.VK_G); filemenu1.add(aboutmenu1); filemenu1.add(exitmenu1); - advancedmenu1.add(executecommandmenu2); helpmenu1.add(discordmenu3); helpmenu1.add(githubmenu3); labelPanel.add(text1); @@ -112,9 +104,9 @@ public void init() throws UnsupportedLookAndFeelException, ClassNotFoundExceptio panel2.add(button2); panel2.add(button3); panel2.add(button4); - button1.setToolTipText("This option reboots the device normally. Usage: 'adb reboot'"); - button2.setToolTipText("This option reboots the device into recovery. Usage: 'adb reboot recovery'"); - button3.setToolTipText("This option reboots the device into recovery then starts sideload mode. Usage: 'adb reboot sideload'"); + button1.setToolTipText("This option restarts the device normally. Usage: 'adb reboot'"); + button2.setToolTipText("This option restarts the device into recovery. Usage: 'adb reboot recovery'"); + button3.setToolTipText("This option restarts the device into recovery, then starts sideload mode. Usage: 'adb reboot sideload'"); button4.setToolTipText("This option kills the ADB server. Usage: 'adb kill-server'"); this.pack(); setSize(500, 350); @@ -122,7 +114,6 @@ public void init() throws UnsupportedLookAndFeelException, ClassNotFoundExceptio //Event add aboutmenu1.addActionListener(this); exitmenu1.addActionListener(this); - executecommandmenu2.addActionListener(this); discordmenu3.addActionListener(this); githubmenu3.addActionListener(this); button1.addActionListener(this); @@ -196,10 +187,6 @@ public void actionPerformed(ActionEvent arg0) { } if (arg0.getSource() == exitmenu1) { System.exit(0); - } - - if (arg0.getSource() == executecommandmenu2) { - CommandBar.setVisible(true); } if (arg0.getSource() == discordmenu3) { link.OpenLink("https://discord.gg/y6AcUNTKxX"); @@ -207,11 +194,6 @@ public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == githubmenu3) { link.OpenLink("https://github.com/BeboKhouja/ADB-GUI"); - try { - throw new IllegalAccessException(); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } } } diff --git a/src/com/mokkachocolata/util/ExecuteCommand.form b/src/com/mokkachocolata/util/ExecuteCommand.form deleted file mode 100644 index 18fd792..0000000 --- a/src/com/mokkachocolata/util/ExecuteCommand.form +++ /dev/null @@ -1,78 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/com/mokkachocolata/util/ExecuteCommand.java b/src/com/mokkachocolata/util/ExecuteCommand.java deleted file mode 100644 index 4cddb6a..0000000 --- a/src/com/mokkachocolata/util/ExecuteCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.mokkachocolata.util; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.io.IOException; - -public class ExecuteCommand extends JDialog { - private JPanel contentPane; - private JButton buttonOK; - private JButton buttonCancel; - private JCheckBox printToStackTraceCheckBox; - private JTextField Command; - private JLabel CmdToExecute; - - public ExecuteCommand() { - setContentPane(contentPane); - setModal(true); - getRootPane().setDefaultButton(buttonOK); - - buttonOK.addActionListener(e -> { - try { - onOK(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - }); - - buttonCancel.addActionListener(e -> onCancel()); - - // call onCancel() when cross is clicked - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - onCancel(); - } - }); - - // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - } - - private void onOK() throws IOException { - // add your code here - if (Command.getText().contains("adb")) { - Runtime.getRuntime().exec(Command.getText()); - } else { - Runtime.getRuntime().exec("adb" + Command.getText()); - } - dispose(); - } - - private void onCancel() { - // add your code here if necessary - dispose(); - } - - public static void main(String[] args) { - ExecuteCommand dialog = new ExecuteCommand(); - dialog.setMinimumSize(new Dimension(250, 400)); - dialog.setTitle("Command"); - dialog.pack(); - dialog.setVisible(true); - System.exit(0); - } - - private void createUIComponents() { - // TODO: place custom component creation code here - } -} diff --git a/src/resources/localizedtexts.json b/src/resources/localizedtexts.json index 57ffc91..4aca9e7 100644 --- a/src/resources/localizedtexts.json +++ b/src/resources/localizedtexts.json @@ -4,7 +4,7 @@ {"language":"id_id", "key":"REBOOT_DEVICE_SIDELOAD", "string":"Mulai ulang perangkat ke sideload"}, {"language":"id_id", "key":"WINDOW_TITLE", "string":"GUI ADB"}, {"language":"en_us", "key":"ENABLE_DEBUGGING_WARNING", "string":"Make sure USB Debugging is enabled in Android Developer Settings."}, - {"language":"en_us", "key":"REBOOT_DEVICE", "string":"Reboot device"}, - {"language":"en_us", "key":"REBOOT_DEVICE_SIDELOAD", "string":"Reboot to sideload"}, + {"language":"en_us", "key":"REBOOT_DEVICE", "string":"Restart device"}, + {"language":"en_us", "key":"REBOOT_DEVICE_SIDELOAD", "string":"Restart to sideload"}, {"language":"en_us", "key":"WINDOW_TITLE", "string":"ADB GUI"} ] \ No newline at end of file