Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor login #583

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f452c63
Removing deprecated class
FernandoTBarros Feb 24, 2017
54d1b97
Fixing problem with getStardustCostForPowerup when users has pokemon lvl
FernandoTBarros Feb 24, 2017
10d3926
Try catch NPE when trying to get data from column Fix #554
FernandoTBarros Feb 24, 2017
b593464
Updating eclipse preferences regarding checkstyle
FernandoTBarros Feb 24, 2017
5d959da
Including a column to show item required to evolve
FernandoTBarros Feb 25, 2017
eff10d3
Merge branch 'develop' of
FernandoTBarros Feb 25, 2017
23eb529
Creating new column with new renderer and editor for item required for
FernandoTBarros Feb 27, 2017
e6992d2
Merge branch 'develop' into itemRequiredEvolve
FernandoTBarros Feb 28, 2017
2b25d2a
Fixing codeclimate/codacy issues Work in progress
FernandoTBarros Feb 28, 2017
c1bfbcb
Merge remote-tracking branch 'wolfOrigin/develop' into
FernandoTBarros Feb 28, 2017
f4c7dbd
Fixing codeclimate/codacy issues Work in progress
FernandoTBarros Feb 28, 2017
6a287d6
Refactoring PokemonTab, PokemonTable and creating auxiliar classes to
FernandoTBarros Mar 2, 2017
281dd0d
Merge branch 'develop' into itemRequiredEvolve
FernandoTBarros Mar 2, 2017
39d230d
Updating PokeGOAPI-Java, reworking updateInventories again and update
FernandoTBarros Mar 3, 2017
9194d27
Merge remote-tracking branch 'origin/itemRequiredEvolve' into itemReq…
FernandoTBarros Mar 3, 2017
2e56fde
Fixing codeclimate issue
FernandoTBarros Mar 3, 2017
32096c7
Updating stuffs again
FernandoTBarros Mar 10, 2017
1e5e3f8
Fixing codeclimate issues
FernandoTBarros Mar 12, 2017
7d14f54
Fixing more codeclimate issues
FernandoTBarros Mar 13, 2017
5915571
Rebuilding login form.
FernandoTBarros Mar 14, 2017
f8b1727
No longer show DPS values in the movetype columns since they have the…
Mar 21, 2017
fff8a70
Modify "Evolvable" column to display both the required candy count _w…
Mar 22, 2017
d2ccb76
Add gender unicode symbol rename pattern.
Mar 25, 2017
ec2b5b6
Fixed a bug where %type_1% and %type_2% would always return "Po" as t…
Mar 25, 2017
8cef1c2
Make %level% zero leading if < 10 so returned string always has the s…
Mar 25, 2017
a2930c5
Minor cosmetic changes.
Mar 25, 2017
277c901
Much to my surprise I discovered that the %move_type_1% and %move_typ…
Mar 26, 2017
51dbeaa
Added HP Left and Health Percentage columns.
Apr 5, 2017
237dcd6
Added a setting to config.json without UI part so sorting on the HP c…
Apr 5, 2017
655e9bd
Tssss.... Local settings had excluded this file from showing in commi…
Apr 5, 2017
29b27ef
Made sorting of HP dual value column independent of sorting the Evolv…
Apr 7, 2017
96dc65c
Updating endpoint and API to the latest forced version by Niantic
FernandoTBarros Apr 8, 2017
a112271
Correcting some messages
FernandoTBarros Apr 8, 2017
a7cb4a5
Merge pull request #10 from just-Addict/refactorLogin
FernandoTBarros Apr 8, 2017
037730d
Merge branch 'refactorLogin' of git@github.com:FernandoTBarros/Blosso…
FernandoTBarros Apr 8, 2017
4f5fd99
Saving last login type to auto select radio on the next time BPGM will
FernandoTBarros Apr 8, 2017
76fed6f
Preparing for 0.1.8 version!
FernandoTBarros Apr 8, 2017
893cc54
Merge remote-tracking branch 'wolfOrigin/develop' into refactorLogin
FernandoTBarros Apr 8, 2017
8b09069
Fixing codeclimate and codacy issues
FernandoTBarros Apr 8, 2017
6ff2f92
Fixing codeclimate and codacy issues
FernandoTBarros Apr 8, 2017
3494147
Updating API again to 0.61 this time.
FernandoTBarros Apr 8, 2017
70bb399
Opening new login window for everyone
FernandoTBarros Apr 9, 2017
feb75cd
Implementing Google App Password on Login Window and putting new Help
FernandoTBarros Apr 9, 2017
7a54a9e
Changing "Logout" to "Exit" since this logic is a bit fuzzy after mixing
FernandoTBarros Apr 10, 2017
9af8ff9
Reverted %move_type_1% and %move_type_2% back to old behavior.
Apr 12, 2017
ac7a277
Merge pull request #11 from just-Addict/RevertRenamePatterns
FernandoTBarros Apr 18, 2017
dd720ff
Updated POM to use the new API with encryption update.
May 10, 2017
268be3a
Updating default delay time to 18s~20s
FernandoTBarros May 16, 2017
b933229
Refactoring main window again to work well with MacOS too
FernandoTBarros May 16, 2017
2ee5fc0
Merge pull request #12 from just-Addict/EncryptionUpdate
FernandoTBarros May 16, 2017
30ec5e3
Updating PokeGoAPI-Java to latest hash version and updating endpoint to
FernandoTBarros May 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>BPGM</groupId>
<artifactId>BPGM</artifactId>
<version>0.1.7-hotfix4</version>
<version>0.1.8</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
Expand Down Expand Up @@ -67,7 +67,7 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.name}_v${project.version}</finalName>
<finalName>BlossomsPogoManager</finalName>
<appendAssemblyId>false</appendAssemblyId>
<!-- MainClass in mainfest make a executable jar -->
<archive>
Expand Down Expand Up @@ -102,9 +102,9 @@
</repositories>
<dependencies>
<dependency>
<groupId>com.github.gegy1000</groupId>
<groupId>com.github.FernandoTBarros</groupId>
<artifactId>PokeGOAPI-Java</artifactId>
<version>199cda2914ba0ac037d5e3690dee9021b32f37af</version>
<version>102b17b9d311310f3ecb4f7bc22752ccb5f17c67</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand Down Expand Up @@ -132,6 +132,11 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
</project>
77 changes: 54 additions & 23 deletions src/main/resources/layout/Login.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,68 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<StackPane xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<children>
<StackPane prefHeight="0.0" prefWidth="0.0">
<children>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" spacing="10.0">
<children>
<TextField fx:id="usernameField" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="266.0" promptText="PTC Username:" />
<PasswordField fx:id="passwordField" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="266.0" promptText="PTC Password:" />
<Button fx:id="ptcLoginBtn" alignment="CENTER" contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="25.0" prefWidth="111.0" text="Use PTC Auth" />
<Separator />
<Pane>
<StackPane xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<StackPane prefHeight="0.0" prefWidth="0.0">
<children>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" spacing="10.0">
<children>
<HBox spacing="5">
<children>
<RadioButton fx:id="ptcRadio" selected="true" text="PTC" />
<RadioButton fx:id="googleRadio" text="Google Token" />
<RadioButton fx:id="googleAppRadio" layoutX="57.0" layoutY="10.0" text="Google App Pass" />
</children>
</HBox>
<Pane fx:id="ptcPane">
<children>
<TextField fx:id="usernameField" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="266.0" promptText="PTC Username:" />
<PasswordField fx:id="passwordField" layoutY="35.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="266.0" promptText="PTC Password:" />
</children>
</Pane>
<Separator prefWidth="200.0" />
<HBox fx:id="googlePane" prefWidth="260.0" spacing="5.0">
<children>
<TextField fx:id="tokenField" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="187.0" promptText="Google Auth Token:" />
<Button fx:id="getTokenBtn" layoutX="198.0" mnemonicParsing="false" text="Get Token" />
<TextField fx:id="tokenField" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" prefHeight="25.0" promptText="Google Auth Token:" HBox.hgrow="ALWAYS" />
<Button fx:id="getTokenBtn" mnemonicParsing="false" prefWidth="80.0" text="Get Token" />
<Button fx:id="helpGoogleBtn" text="?" />
</children>
</HBox>
<Separator layoutX="10.0" layoutY="107.0" prefWidth="200.0" />
<Pane fx:id="googleAppPane" layoutX="10.0" layoutY="37.0">
<children>
<TextField fx:id="googleUsernameField" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="243.0" promptText="Google Username:" />
<PasswordField fx:id="googlePasswordField" layoutY="35.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="243.0" promptText="Google Password:" />
<Button fx:id="helpGoogleAppBtn" layoutX="248.0" text="?" />
</children>
</Pane>
<Button fx:id="googleAuthBtn" alignment="CENTER" contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="25.0" prefWidth="111.0" text="Use Google Auth" />
<CheckBox fx:id="saveAuthChkbx" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="17.0" prefWidth="147.0" text="Remember Credencials" />
</children>
</VBox>
</children>
</StackPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
<AnchorPane>
<children>
<Separator prefWidth="269.0" AnchorPane.topAnchor="10.0" />
<Label layoutY="24.0" text="Hash Key:" AnchorPane.topAnchor="24.0" />
<TextField fx:id="hashKeyField" layoutX="56.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="187.0" promptText="0123456789ABCDEFGHIJ" AnchorPane.topAnchor="20.0" />
<Button fx:id="helpBtn" layoutX="248.0" layoutY="20.0" text="?" AnchorPane.topAnchor="20.0" />
<CheckBox fx:id="saveAuthChkbx" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="17.0" prefWidth="147.0" text="Remember Credentials" AnchorPane.topAnchor="60.0" />
<Button fx:id="loginBtn" alignment="CENTER" contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="25.0" prefWidth="111.0" text="ENTER" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="55.0" />
</children>
</AnchorPane>
</children>
</VBox>
</children>
</StackPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</StackPane>
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.7-hotfix4
v0.1.7-hotfix7
127 changes: 79 additions & 48 deletions src/me/corriekay/pokegoutil/BlossomsPoGoManager.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package me.corriekay.pokegoutil;

import java.awt.event.WindowAdapter;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.stage.Stage;
import me.corriekay.pokegoutil.data.managers.AccountController;
import me.corriekay.pokegoutil.data.managers.GlobalSettingsController;
import me.corriekay.pokegoutil.gui.controller.ChooseGuiWindowController;
import me.corriekay.pokegoutil.utils.ConfigKey;
import me.corriekay.pokegoutil.utils.ConfigNew;
import me.corriekay.pokegoutil.gui.controller.LoginController;
import me.corriekay.pokegoutil.utils.StringLiterals;
import me.corriekay.pokegoutil.utils.helpers.FileHelper;
import me.corriekay.pokegoutil.utils.helpers.UIHelper;
import me.corriekay.pokegoutil.utils.windows.WindowStuffHelper;

/**
* The main project class. Contains the runtime stuff.
*/
public class BlossomsPoGoManager {
public class BlossomsPoGoManager extends Application {

private static Stage sPrimaryStage;
private static JFrame mainWindow;

/**
* Entry point of the application.
Expand All @@ -30,8 +34,7 @@ public class BlossomsPoGoManager {
*/
public static void main(final String[] args) {
GlobalSettingsController.setup();
// launch(args);
new BlossomsPoGoManager().start(null);
launch(args);
}

/**
Expand All @@ -55,20 +58,52 @@ public static void setNewPrimaryStage(final Stage stage) {
sPrimaryStage = stage;
}

// @Override
/**
* Legacy start method from JavaFX nature.
* @param primaryStage Received when have JavaFX nature
* Get the current main window.
*
* @return current main window
*/
public void start(final Stage primaryStage) {
setupGlobalExceptionHandling();
public static JFrame getMainWindow() {
return mainWindow;
}

if (ConfigNew.getConfig().getBool(ConfigKey.DEVELOPFLAG)) {
new ChooseGuiWindowController();
sPrimaryStage.show();
} else {
openOldGui();
/**
* Set the new main window.
*
* @param window main window
*/
public static void setNewMainWindow(final JFrame window) {
if(BlossomsPoGoManager.mainWindow != null && BlossomsPoGoManager.mainWindow.isVisible()) {
BlossomsPoGoManager.mainWindow.setVisible(false);
}
BlossomsPoGoManager.mainWindow = window;
}

@Override
public void start(final Stage primaryStage) {
setupGlobalExceptionHandling();
new LoginController();
SwingUtilities.invokeLater(() -> {
UIHelper.setNativeLookAndFeel();
JFrame frame = new JFrame();
final JFXPanel jfxPanel = new JFXPanel();
frame.getContentPane().add(jfxPanel);
frame.setSize(310, 370);
frame.setLocationRelativeTo(null);
frame.setIconImage(FileHelper.loadImage("icon/PokeBall-icon.png"));
frame.setTitle(BlossomsPoGoManager.getPrimaryStage().getTitle());
frame.setVisible(true);
setNewMainWindow(frame);
Platform.runLater(() -> {
jfxPanel.setScene(BlossomsPoGoManager.getPrimaryStage().getScene());
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Platform.runLater(() -> System.exit(0));
}
});
});
});
}

/**
Expand All @@ -85,37 +120,33 @@ private static void setupGlobalExceptionHandling() {
result.add(current.getClass().getSimpleName() + StringLiterals.COLON_SEPARATOR + current.getLocalizedMessage());
current = current.getCause();
}
SwingUtilities.invokeLater(() -> {
final String[] options = new String[] {"Continue anyway", "Exit"};
final int continueChoice = JOptionPane.showOptionDialog(
WindowStuffHelper.ALWAYS_ON_TOP_PARENT,
String.join(StringLiterals.NEWLINE, result)
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "Application got a critical error."
+ StringLiterals.NEWLINE + "You can report the error on GitHub or Discord."
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "It is possible to continue here, but do note that the application might not work as expected."
+ StringLiterals.NEWLINE + "Close and restart if that's the case.",
"General Unhandled Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, options, options[0]);
if (continueChoice == 1) {
// If exit is chosen, we exit here.
System.exit(-1);
}
});
});
}

/**
* Opens the old GUI.
*/
private void openOldGui() {
// SwingUtilities.invokeLater(() -> {
UIHelper.setNativeLookAndFeel();
AccountController.initialize();
AccountController.logOn();
// });
final String[] options = new String[] {"Continue anyway", "Exit"};
final int continueChoice = JOptionPane.showOptionDialog(
WindowStuffHelper.ALWAYS_ON_TOP_PARENT,
String.join(StringLiterals.NEWLINE, result)
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "Application got a critical error."
+ StringLiterals.NEWLINE + "You can report the error on GitHub or Discord."
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "It is possible to continue here, but do note that the application might not work as expected."
+ StringLiterals.NEWLINE + "Close and restart if that's the case.",
"General Unhandled Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, options, options[0]);
if (continueChoice == 1) {
// If exit is chosen, we exit here.
System.exit(-1);
}
});
}

// private void openOldGui() {
// SwingUtilities.invokeLater(() -> {
// UIHelper.setNativeLookAndFeel();
// AccountController.initialize();
// AccountController.logOn();
// });
// }
}
41 changes: 41 additions & 0 deletions src/me/corriekay/pokegoutil/data/enums/ColumnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

import me.corriekay.pokegoutil.utils.ConfigKey;
import me.corriekay.pokegoutil.utils.ConfigNew;
import me.corriekay.pokegoutil.utils.StringLiterals;
import me.corriekay.pokegoutil.utils.helpers.DateHelper;
import me.corriekay.pokegoutil.utils.helpers.EvolveHelper;
Expand Down Expand Up @@ -63,6 +65,11 @@ public enum ColumnType {
String.class,
Comparators.STRING
),
NUMBER_STRING(
String.class,
Comparators.NUMBER_STRING,
CellRendererHelper.NUMBER_STRING
),
FUTURE_STRING(
String.class,
Comparators.FUTURE_STRING,
Expand Down Expand Up @@ -102,6 +109,40 @@ private static final class Comparators {
}
return Integer.compare(Integer.parseInt(left), Integer.parseInt(right));
};
public static final Comparator<String> NUMBER_STRING = (left, right) -> {
// pre-initialize first split entries with "-1" so "-" (= NO_VALUE_SIGN) will be sorted separate from 0
String[] sLeft = {StringLiterals.MINUS_ONE, StringLiterals.MINUS_ONE};
String[] sRight = {StringLiterals.MINUS_ONE, StringLiterals.MINUS_ONE};
Integer iResult0 = 0;
Integer iResult1 = 0;

if (left.indexOf(StringLiterals.SLASH) > -1) {
sLeft = left.split(StringLiterals.SLASH);
}
if (right.indexOf(StringLiterals.SLASH) > -1) {
sRight = right.split(StringLiterals.SLASH);
}

iResult0 = Integer.compare(Integer.parseInt(sLeft[0]), Integer.parseInt(sRight[0]));
iResult1 = Integer.compare(Integer.parseInt(sLeft[1]), Integer.parseInt(sRight[1]));

final boolean useFullHP = ConfigNew.getConfig().getBool(ConfigKey.HP_SORT_ON_FULL);
final String sortEnum1 = ConfigNew.getConfig().getString(ConfigKey.SORT_ENUM_1);

if (useFullHP && "HP".equals(sortEnum1)) {
if (iResult1 == 0) {
return iResult0;
} else {
return iResult1;
}
} else {
if (iResult0 == 0) {
return iResult1;
} else {
return iResult0;
}
}
};
}

/**
Expand Down
Loading