Skip to content

Commit

Permalink
Fixed language system, Changed additional stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
BeboKhouja committed Jun 9, 2024
1 parent cd633f4 commit 2f12e7e
Show file tree
Hide file tree
Showing 12 changed files with 751 additions and 139 deletions.
8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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). It is also an alternative to Mauronofrio Matarrese's TOOL ALL IN ONE.
ADB GUI is a free and open source Java based application that adds a GUI based ADB (Android Debug Bridge).

# Getting Started
1. Install Java 17.0.2 or later.
Expand Down
499 changes: 499 additions & 0 deletions hs_err_pid14700.log

Large diffs are not rendered by default.

Binary file added lib/discord-game-sdk4j-0.5.5.jar
Binary file not shown.
53 changes: 19 additions & 34 deletions src/com/mokkachocolata/project/adbgui/App.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
// Copyright (C) 2023 Bebo Khouja
// Copyright (C) 2024 Bebo Khouja

package com.mokkachocolata.project.adbgui;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Scanner;


import com.mokkachocolata.exception.JarNotFoundException;
import com.mokkachocolata.util.*;


import de.jcm.discordgamesdk.Core;
import de.jcm.discordgamesdk.CreateParams;
import org.apache.log4j.*;
import org.json.JSONArray;

import de.jcm.discordgamesdk.activity.*;

import javax.swing.*;

Expand All @@ -23,14 +30,22 @@
* @author Bebo Khouja
*/
public class App {
public static final String version = "1.4.1";
public static final String version = "1.5.0";
private static final Logger logger = Logger.getLogger(App.class);
private static final Link link = new Link();
private static final AddonLoader addonLoader = new AddonLoader();
public static final Event onCommandExecute = new Event();


public static void main(String[] args) throws IOException, URISyntaxException, JarNotFoundException, ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchMethodException, UnsupportedLookAndFeelException, InstantiationException {
// I run first!
File preferences = new File(new File(new Util().getJarLocation()).getParentFile().getPath() + "\\preferences.json");
if (!preferences.exists()) {
//noinspection ResultOfMethodCallIgnored
preferences.createNewFile();
}
JSONArray preferencesJson = new JSONArray(Files.readAllLines(preferences.toPath()));
System.out.println(Files.readAllLines(preferences.toPath()));

ArrayList<LoadedAddon> classes = (ArrayList<LoadedAddon>) addonLoader.LoadAddons().clone();
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setThreshold(Level.ALL);
Expand All @@ -43,36 +58,6 @@ public static void main(String[] args) throws IOException, URISyntaxException, J
}
MainFrame myFrame = new MainFrame();
myFrame.init();
if (Terminal.isOpenedInConsole(args)) {
try (Scanner scanner = new Scanner(System.in)) {
while(true) {
String command = scanner.nextLine();
onCommandExecute.fireEvent();
new Thread(()->{try {
Terminal.GetOutput(Runtime.getRuntime().exec("adb " + command));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}).start();
logger.info("Execute command \"adb "+command+"\"");
if (command.equals("version")) {
logger.info("ADB GUI version " + version);
}
if (command.equals("help")) {
logger.info("Commands:\n1. version\n2. jarlocation\n3. discord\n4. github");
}
if (command.equals("github")) {
link.OpenLink("https://github.com/BeboKhouja/ADB-GUI");
}
if (command.equals("discord")) {
link.OpenLink("https://discord.gg/y6AcUNTKxX");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}

}

}
}
22 changes: 12 additions & 10 deletions src/com/mokkachocolata/project/adbgui/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
package com.mokkachocolata.project.adbgui;

// Project imports

import com.mokkachocolata.util.ExecuteCommand;
import com.mokkachocolata.util.Link;
import com.mokkachocolata.util.Localization;
import com.mokkachocolata.util.ExecuteCommand;
// Sentry imports
import io.sentry.Sentry;
// Java imports
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
Expand All @@ -18,9 +22,6 @@
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import java.net.URISyntaxException;
// Log4j imports
import org.apache.log4j.*;

/**
* The {@code MainFrame} class houses the main frame for the app.
Expand All @@ -35,7 +36,7 @@ public class MainFrame extends JFrame implements ActionListener, MenuListener, K
final JTabbedPane tabbedPane = new JTabbedPane();
JMenuBar menubar1;
JMenu filemenu1,advancedmenu1,helpmenu1;
JMenuItem exitmenu1,aboutmenu1,executecommandmenu2,discordmenu3,githubmenu3;
JMenuItem exitmenu1,aboutmenu1,executecommandmenu2,discordmenu3,githubmenu3,languagemenu1;
JButton button1,button2,button3,button4;
JLabel text1;
final ExecuteCommand CommandBar = new ExecuteCommand();
Expand All @@ -50,7 +51,7 @@ public class MainFrame extends JFrame implements ActionListener, MenuListener, K
final JPanel panel2 = new JPanel(new GridLayout(2, 1));
final JPanel panel3 = new JPanel();
final BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
public void init() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, URISyntaxException {
public void init() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
//Window config
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
setTitle(localization.getLocalizedText("WINDOW_TITLE"));
Expand All @@ -73,9 +74,10 @@ public void init() throws UnsupportedLookAndFeelException, ClassNotFoundExceptio
githubmenu3 = new JMenuItem("GitHub Repository");
button1 = new JButton("Reboot device");
button2 = new JButton("Reboot to recovery");
button3 = new JButton("Reboot to sideload");
languagemenu1 = new JMenuItem(localization.getLocalizedText("LANGUAGE_CHANGE_OPTION"));
button3 = new JButton(localization.getLocalizedText("REBOOT_DEVICE_SIDELOAD"));
button4 = new JButton("Reconnect device");
text1 = new JLabel("Please make sure USB Debugging is enabled. Otherwise, it wont work.");
text1 = new JLabel(localization.getLocalizedText("ENABLE_DEBUGGING_WARNING"));
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
list.setModel(model);
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
Expand Down
88 changes: 88 additions & 0 deletions src/com/mokkachocolata/util/LanguageChange.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.mokkachocolata.util.LanguageChange">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="436" height="151"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="98af6">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<text value="OK"/>
</properties>
</component>
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="da6d5" class="javax.swing.JComboBox" binding="LanguageSelector">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="e9beb" class="javax.swing.JLabel" binding="LanguageCurrent">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Current language: "/>
</properties>
</component>
<component id="23d84" class="javax.swing.JLabel" binding="RestartText">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<text value="A restart of the program is required to change the language."/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
79 changes: 79 additions & 0 deletions src/com/mokkachocolata/util/LanguageChange.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.mokkachocolata.util;

import com.mokkachocolata.enums.Languages;
import com.mokkachocolata.exception.JarNotFoundException;

import javax.swing.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.URISyntaxException;

public class LanguageChange extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
Localization localization = new Localization();
private JComboBox<String> LanguageSelector;
private JLabel LanguageCurrent;
private JLabel RestartText;

private int choiceToLanguage(int index) {
return switch (index) {
case 0 -> Languages.EN_US;
case 1 -> Languages.ID_ID;
default -> 0;
};
}

public LanguageChange() {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
LanguageSelector.addItem("American English");
LanguageSelector.addItem("Indonesian");
buttonOK.setEnabled(false);
RestartText.setVisible(false);
LanguageSelector.addActionListener(e -> {
if (LanguageSelector.getSelectedIndex() != localization.getCurrentLanguage()) {
buttonOK.setEnabled(true);
RestartText.setVisible(true);
} else {
buttonOK.setEnabled(false);
RestartText.setVisible(false);
}
});

LanguageCurrent.setText(localization.languageToString(localization.getCurrentLanguage()));
buttonOK.addActionListener(e -> {
try {
onOK();
} catch (JarNotFoundException | IOException | URISyntaxException 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 JarNotFoundException, URISyntaxException, IOException {
// add your code here
localization.setCurrentLanguageToPreferences(choiceToLanguage(LanguageSelector.getSelectedIndex()));
System.exit(2);
}

private void onCancel() {
// add your code here if necessary
dispose();
}
}
2 changes: 1 addition & 1 deletion src/com/mokkachocolata/util/Link.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Link {
* @author Bebo Khouja
*/
public void OpenLink(String link) {
int dialog = JOptionPane.showConfirmDialog(new JPanel(), "Are you sure you want to open "+link+"? \nNever open links from addons you don't trust!", "Open link", JOptionPane.YES_NO_OPTION);
int dialog = JOptionPane.showConfirmDialog(new JPanel(), "Are you sure you want to open "+link+"?", "Open link", JOptionPane.YES_NO_OPTION);
if (dialog == JOptionPane.YES_OPTION) {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Expand Down
Loading

0 comments on commit 2f12e7e

Please sign in to comment.