diff --git a/src/controller/UserController.java b/src/controller/UserController.java deleted file mode 100755 index 52f84f7..0000000 --- a/src/controller/UserController.java +++ /dev/null @@ -1,130 +0,0 @@ -package controller; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.methods.RequestBuilder; -import org.apache.http.impl.client.HttpClientBuilder; -import org.json.JSONException; -import org.json.JSONObject; - -import gui.premium.PremiumCheckerTask; -import model.User; - -public class UserController { - - private User user; - private final String tempLoginKey = "MjMGqzdkMSs4K4PNkN454Ufc"; - private PremiumCheckerTask premiumCheckerTask; - - public UserController() { - user = new User(); - premiumCheckerTask = new PremiumCheckerTask(this); - } - - public boolean isTempUserSelected(String tempLoginKey) { - return tempLoginKey.equals(this.tempLoginKey) ? true : false; - } - - public String authenticateUser(String email, String pass) { - String error = ""; - try { - HttpClient httpclient = HttpClientBuilder.create().build(); - - // Creating the RequestBuilder object - RequestBuilder reqbuilder = RequestBuilder.get(); - - // Setting URI and parameters - RequestBuilder reqbuilder1 = reqbuilder - .setUri("https://www.psychotechnology.com/api/get-subliminator-premium"); - RequestBuilder reqbuilder2 = reqbuilder1.addParameter("email", email).addParameter("password", pass); - - // Building the HttpUriRequest object - HttpUriRequest httpget = reqbuilder2.build(); - - HttpResponse response = httpclient.execute(httpget); - BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); - - String output; - while ((output = br.readLine()) != null) { - - JSONObject json = new JSONObject(output); - - int id = json.getInt("id"); - String firstName = json.getString("firstName"); - String lastName = json.getString("lastName"); - boolean active = json.getBoolean("active"); - boolean premium = json.getBoolean("premium"); - - user.setId(id); - user.setFirstName(firstName); - user.setLastName(lastName); - user.setAccountActive(active); - user.setUserPremium(premium); - - } - - if (user.isAccountActive()) { - user.setEmail(email); - user.setPassword(pass); - } - - } catch (ClientProtocolException e) { - error = "Cannot connect to the server"; - } catch (IOException e) { - error = "Error processing data"; - } catch (JSONException e) { - error = "Incorrect / user password"; - } - return error; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public void handleLogout() { - this.user.setAccountActive(false); - this.user.setUserPremium(false); - } - - public boolean isAuthenticated() { - return this.user.isAccountActive(); - } - - public boolean isPremium() { - return this.user.isUserPremium(); - } - - public void setUserPremium(boolean isPremium) { - this.user.setUserPremium(isPremium); - } - - public void runPremiumPrompter() { - if (!premiumCheckerTask.isAlive()) { - premiumCheckerTask = new PremiumCheckerTask(this); - premiumCheckerTask.start(); - premiumCheckerTask.runPremiumReminder(); - } - } - - public void stopPremiumPrompter() { - if (!premiumCheckerTask.isInterrupted()) { - premiumCheckerTask.interrupt(); - premiumCheckerTask.stopPremiumReminder(); - } - } - - public void showPremiumPopup() { - premiumCheckerTask.showPopup(); - } -} diff --git a/src/gui/MainFrame.java b/src/gui/MainFrame.java index e86e581..702ac96 100755 --- a/src/gui/MainFrame.java +++ b/src/gui/MainFrame.java @@ -7,8 +7,6 @@ import java.awt.Insets; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import javax.swing.JDesktopPane; import javax.swing.JFrame; @@ -18,7 +16,6 @@ import Network.SocketBinder; import controller.MessageController; -import controller.UserController; import gui.category.CategoryEvent; import gui.category.CategoryListener; import gui.category.CategoryPanel; @@ -30,10 +27,6 @@ import gui.dialogs.DeleteMessage; import gui.dialogs.EditImage; import gui.dialogs.EditMessage; -import gui.login.LoginEvent; -import gui.login.LoginFrame; -import gui.login.LoginListener; -import gui.login.LogoutEvent; import gui.message.MessagePanel; import gui.settings.SettingsEvent; import gui.settings.SettingsListener; @@ -43,17 +36,14 @@ import gui.util.MBSystemTray; import gui.util.SetScreenLocation; import model.Message; -import model.User; import utility.FontPicker; import validation.ArrayValidator; @SuppressWarnings("serial") -public class MainFrame extends JFrame implements CategoryListener, MessageListener, SettingsListener, LoginListener { +public class MainFrame extends JFrame implements CategoryListener, MessageListener, SettingsListener { public static final String appName = "Subliminator"; private MessageController messageController; - private UserController userController; - private LoginFrame loginFrame; private CategoryPanel categoryPanel; private MessagePanel messagePanel; private SettingsPanel settingsPanel; @@ -63,7 +53,6 @@ public class MainFrame extends JFrame implements CategoryListener, MessageListen private MBSystemTray hideToSystemTray; private ProfileDropdownLabel profileDropdownLabel; private JLabel errorMsg; - private UserProfileMenu userProfileMenu; public MainFrame() { @@ -72,12 +61,7 @@ public MainFrame() { "Two instances", JOptionPane.ERROR_MESSAGE); dispose(); } else { - - loginFrame = new LoginFrame(); - loginFrame.setLoginListener(this); - messageController = new MessageController(); - userController = new UserController(); categoryPanel = new CategoryPanel(messageController); categoryPanel.setCategorySelectionListener(this); @@ -113,7 +97,7 @@ public void componentResized(ComponentEvent evt) { (int) (SetScreenLocation.screenSize.height * 0.9))); pack(); SetScreenLocation.centerFrame(this); - setVisible(false); + setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } @@ -131,15 +115,6 @@ private void initComponents() { errorMsg.setVisible(false); profileDropdownLabel = new ProfileDropdownLabel(); - profileDropdownLabel.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - userProfileMenu.show(e.getComponent(), e.getX(), e.getY()); - } - }); - - userProfileMenu = new UserProfileMenu(userController, profileDropdownLabel, settingsPanel); - userProfileMenu.setLoginListener(this); } private void setupUI() { @@ -245,17 +220,7 @@ public void messageEventOccurred(MessageEvent event) { errorMsg.setVisible(true); controlPanel.showStartButton(); } else { - if (userController.isPremium() == true) { - runMessageActivity(settingsPanel.getSelectedScreenPositions()); - } else { - if (ArrayValidator.isMoreThanOneTrue(settingsPanel.getSelectedScreenPositions())) { - userController.showPremiumPopup(); - controlPanel.showStartButton(); - } else { - controlPanel.showStopButton(); - runMessageActivity(settingsPanel.getSelectedScreenPositions()); - } - } + runMessageActivity(settingsPanel.getSelectedScreenPositions()); } } } else if (messageController.isMessagesOn() == true) { @@ -350,84 +315,4 @@ public void settingsEventOccurred(SettingsEvent e) { messageController.setSpeed(e.getMessageSpeed()); messageController.setInterval(e.getMessageInterval()); } - - @Override - public void loginEventOccurred(LoginEvent event) { - - String email = event.getUser(); - String pass = event.getPass(); - - if (userController.isTempUserSelected(email)) { - -// userController.setUserPremium(false); - userController.runPremiumPrompter(); - - settingsPanel.checkForActiveMessages(); - settingsPanel.deactivateActiveMessages(); - - userProfileMenu.createMenuItemsForTempUser(); - - profileDropdownLabel.setToUnregistered(); - - setVisible(true); - loginFrame.dispose(); - } else { - String errorMessage = userController.authenticateUser(email, pass); - - if (userController.isAuthenticated() == false) { - - loginFrame.setErrorMessage(errorMessage); - - } else { - User user = userController.getUser(); - profileDropdownLabel.setText(user.getFirstName() + " " + user.getLastName()); - - settingsPanel.checkForActiveMessages(); - - if (user.isUserPremium() == true) { - - userProfileMenu.createMenuItemsForPremiumUser(); - - profileDropdownLabel.setToPremium(); - - SettingsPanel.isUserPremium = true; - userController.setUserPremium(true); - userController.stopPremiumPrompter(); - - } else { - - profileDropdownLabel.setToBasic(); - - SettingsPanel.isUserPremium = false; - userController.runPremiumPrompter(); - - userProfileMenu.createMenuItemsForBasicUser(); - - if (settingsPanel.isMoreThanOneMsgSelected() == true) { - settingsPanel.deactivateActiveMessages(); - } - } - setVisible(true); - loginFrame.dispose(); - } - } - } - - @Override - public void logoutEventOccurred(LogoutEvent event) { - dispose(); - - userController.handleLogout(); - - userProfileMenu.removeAll(); - - SettingsPanel.isUserPremium = false; - userController.setUserPremium(false); - - userController.stopPremiumPrompter(); - - loginFrame = new LoginFrame(); - loginFrame.setUserAndPassFields(userController.getUser().getEmail(), userController.getUser().getPassword()); - loginFrame.setLoginListener(this); - } } \ No newline at end of file diff --git a/src/gui/UserProfileMenu.java b/src/gui/UserProfileMenu.java deleted file mode 100755 index d75f6e4..0000000 --- a/src/gui/UserProfileMenu.java +++ /dev/null @@ -1,145 +0,0 @@ -package gui; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JPopupMenu; - -import controller.UserController; -import gui.component.MenuItem; -import gui.component.ProfileDropdownLabel; -import gui.login.LoginEvent; -import gui.login.LoginFrame; -import gui.login.LoginListener; -import gui.login.LogoutEvent; -import gui.settings.SettingsPanel; -import model.User; -import utility.FontPicker; - -@SuppressWarnings("serial") -public class UserProfileMenu extends JPopupMenu implements ActionListener, LoginListener { - - private LoginFrame loginFrame; - private SettingsPanel settingsPanelReference; - private ProfileDropdownLabel profileDropdownLabel; - private UserController userController; - private MenuItem premiumItem, loginItem, logoutItem; - private LoginListener loginListener; - - public UserProfileMenu(UserController userController, ProfileDropdownLabel profileDropdownLabel, - SettingsPanel settingsPanelReference) { - super(); - - this.userController = userController; - this.profileDropdownLabel = profileDropdownLabel; - this.settingsPanelReference = settingsPanelReference; - - setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - } - - public void createMenuItemsForBasicUser() { - premiumItem = new MenuItem("Get Premium"); - styleMenuItem(premiumItem); - - logoutItem = new MenuItem("Logout"); - styleMenuItem(logoutItem); - logoutItem.addActionListener(this); - - if (userController.isPremium() == false) { - add(premiumItem); - } - add(logoutItem); - } - - public void createMenuItemsForPremiumUser() { - premiumItem = new MenuItem("Get Premium"); - styleMenuItem(premiumItem); - logoutItem = new MenuItem("Logout"); - styleMenuItem(logoutItem); - logoutItem.addActionListener(this); - - if (userController.isPremium() == false) { - add(premiumItem); - } - add(logoutItem); - } - - public void createMenuItemsForTempUser() { - loginItem = new MenuItem("Login"); - styleMenuItem(loginItem); - loginItem.addActionListener(this); - premiumItem = new MenuItem("Premium"); - styleMenuItem(premiumItem); - - add(loginItem); - add(premiumItem); - } - - public void removeMenuItems() { - remove(loginItem); - remove(premiumItem); - } - - private void styleMenuItem(MenuItem item) { - item.setFont(FontPicker.getFont(FontPicker.latoRegular, 20)); - item.setForeground(Color.BLACK); - item.setBackground(Color.decode("#dbdbdb")); - item.setOpaque(true); - } - - @Override - public void actionPerformed(ActionEvent ae) { - if (ae.getSource() == loginItem) { - loginFrame = new LoginFrame(); - loginFrame.setLoginListener(this); - } else if (ae.getSource() == logoutItem) { - if (loginListener != null) { - LogoutEvent logoutEvent = new LogoutEvent(this); - loginListener.logoutEventOccurred(logoutEvent); - } - } - } - - public void setLoginListener(LoginListener loginListener) { - this.loginListener = loginListener; - } - - @Override - public void loginEventOccurred(LoginEvent event) { - - if (userController.isTempUserSelected(event.getUser())) { - loginFrame.setErrorMessage("Already logged in as temp user"); - } else { - - String errorMessage = userController.authenticateUser(event.getUser(), event.getPass()); - - if (userController.isAuthenticated() == false) { - loginFrame.setErrorMessage(errorMessage); - } else { - loginFrame.dispose(); - removeMenuItems(); - - User user = userController.getUser(); - profileDropdownLabel.setText(user.getFirstName() + " " + user.getLastName()); - - if (userController.isPremium() == true) { - profileDropdownLabel.setToPremium(); - createMenuItemsForPremiumUser(); - } else { - if (settingsPanelReference.isMoreThanOneMsgSelected() == true) { - settingsPanelReference.deactivateActiveMessages(); - } - profileDropdownLabel.setToBasic(); - createMenuItemsForBasicUser(); - } - } - } - } - - @Override - public void logoutEventOccurred(LogoutEvent event) { - // TODO Auto-generated method stub - } -} diff --git a/src/gui/login/LoginEvent.java b/src/gui/login/LoginEvent.java deleted file mode 100755 index 4df868d..0000000 --- a/src/gui/login/LoginEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package gui.login; - -import java.util.EventObject; - -@SuppressWarnings("serial") -public class LoginEvent extends EventObject { - - private String user; - private String pass; - - public LoginEvent(Object source, String user, String pass) { - super(source); - this.user = user; - this.pass = pass; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getPass() { - return pass; - } - - public void setPass(String pass) { - this.pass = pass; - } -} diff --git a/src/gui/login/LoginFrame.java b/src/gui/login/LoginFrame.java deleted file mode 100755 index 1b8034e..0000000 --- a/src/gui/login/LoginFrame.java +++ /dev/null @@ -1,227 +0,0 @@ -package gui.login; - -import java.awt.Color; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JSeparator; -import javax.swing.SwingConstants; - -import gui.component.LoginButton; -import gui.component.RegisterButton; -import gui.component.RoundJPasswordField; -import gui.component.RoundJTextField; -import gui.util.IconFetch; -import gui.util.SetScreenLocation; -import utility.FontPicker; - -@SuppressWarnings("serial") -public class LoginFrame extends JFrame implements ActionListener { - - public static final int W = 750, H = 750, minW = 700, minH = 700; - private final String tempPass = "MjMGqzdkMSs4K4PNkN454Ufc"; - private JButton logo; - private JLabel registerLbl, errorLbl; - private RoundJTextField userTxt; - private RoundJPasswordField passTxt; - private JButton submitBtn, tempLoginBtn, registerBtn; - private LoginListener loginListener; - private LoginPanel loginPanel; - - public LoginFrame() { - loginPanel = new LoginPanel(IconFetch.getInstance().getIcon("/images/login-background.png").getImage()); - initComponents(); - setupUI(); - - setTitle("Login"); - setIconImage(IconFetch.getInstance().getIcon("/images/icon.png").getImage()); - setContentPane(loginPanel); - loginPanel.setBackground(Color.decode("#1975be")); - setPreferredSize(new Dimension(W, H)); - setMinimumSize(new Dimension(minW, minH)); - SetScreenLocation.centerFrame(this); - setResizable(true); - pack(); - setVisible(true); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - } - - private void initComponents() { - ImageIcon icon = IconFetch.getInstance().getIcon("/images/logo-small.png"); - - logo = new JButton(); - logo.setIcon(icon); - logo.setOpaque(false); - logo.setContentAreaFilled(false); - logo.setBorderPainted(false); - logo.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ae) { - try { - URI uri = new URI("https://www.psychotechnology.com/"); - Desktop dt = Desktop.getDesktop(); - dt.browse(uri); - } catch (IOException | URISyntaxException e1) { - e1.printStackTrace(); - } - } - }); - - registerLbl = new JLabel("Not registered? Click the button below to register for a FREE account"); - registerLbl.setFont(FontPicker.getFont(FontPicker.latoRegular, 18.0f)); - registerLbl.setForeground(Color.WHITE); - - errorLbl = new JLabel(); - errorLbl.setFont(FontPicker.getFont(FontPicker.robotoRegular, 22.0f)); - errorLbl.setForeground(Color.decode("#B31616")); - - userTxt = new RoundJTextField(15); - userTxt.setPlaceholder("Username"); - - userTxt.setFont(FontPicker.getFont(FontPicker.robotoRegular, 32.0f)); - userTxt.setPreferredSize(new Dimension(350, 50)); - - passTxt = new RoundJPasswordField(15); - passTxt.setPlaceholder("Password"); - passTxt.setFont(FontPicker.getFont(FontPicker.robotoRegular, 32.0f)); - passTxt.setPreferredSize(new Dimension(350, 50)); - - submitBtn = new LoginButton("Login", Color.decode("#ededed")); - submitBtn.setForeground(Color.decode("#828282")); - submitBtn.setBackground(Color.decode("#f4f4f4")); - submitBtn.addActionListener(this); - - tempLoginBtn = new LoginButton("Skip", 30.0f, Color.decode("#1975bf")); - tempLoginBtn.setContentAreaFilled(false); - tempLoginBtn.addActionListener(this); - - registerBtn = new RegisterButton("Register"); - registerBtn.addActionListener(this); - } - - public void setUsername(String username) { - userTxt.setText(username); - } - - public void setPassword(String password) { - passTxt.setText(password); - } - - private void setupUI() { - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gc = new GridBagConstraints(); - loginPanel.setLayout(gbl); - - gc.gridx = 0; - gc.gridy = 0; - gc.gridheight = 1; - gc.gridwidth = 1; - gc.weightx = 0.5; - gc.weighty = 0.5; - gc.insets = new Insets(10, 0, 0, 0); - gc.anchor = GridBagConstraints.CENTER; - gc.fill = GridBagConstraints.NONE; - loginPanel.add(logo, gc); - - JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL); - sep.setBackground(Color.decode("#5d9ed3")); - sep.setForeground(Color.decode("#5d9ed3")); - - gc.gridy++; - gc.insets = new Insets(0, 0, 0, 0); - gc.fill = GridBagConstraints.BOTH; - gc.anchor = GridBagConstraints.NORTH; - loginPanel.add(sep, gc); - - gc.gridy++; - gc.insets = new Insets(20, 75, 0, 0); - gc.anchor = GridBagConstraints.LINE_START; - gc.fill = GridBagConstraints.NONE; - loginPanel.add(errorLbl, gc); - - gc.gridy++; - gc.insets = new Insets(0, 75, 0, 75); - gc.anchor = GridBagConstraints.NORTHWEST; - gc.fill = GridBagConstraints.HORIZONTAL; - loginPanel.add(userTxt, gc); - - gc.gridy++; - gc.insets = new Insets(25, 75, 0, 75); - loginPanel.add(passTxt, gc); - - gc.gridy++; - gc.gridwidth = 2; - gc.insets = new Insets(25, 0, 0, 0); - gc.anchor = GridBagConstraints.NORTH; - gc.fill = GridBagConstraints.NONE; - loginPanel.add(submitBtn, gc); - - gc.gridy++; - gc.gridwidth = 2; - gc.insets = new Insets(0, 0, 20, 0); - loginPanel.add(tempLoginBtn, gc); - - gc.gridy++; - gc.gridwidth = 1; - gc.insets = new Insets(0, 75, 0, 0); - gc.fill = GridBagConstraints.BOTH; - loginPanel.add(registerLbl, gc); - - gc.gridy++; - gc.gridwidth = 2; - gc.insets = new Insets(0, 75, 90, 75); - loginPanel.add(registerBtn, gc); - } - - @Override - public void actionPerformed(ActionEvent ae) { - - if (ae.getSource() == submitBtn) { - if (loginListener != null) { - String user = userTxt.getText(); - String pass = String.valueOf(passTxt.getPassword()); - LoginEvent loginEvent = new LoginEvent(this, user, pass); - loginListener.loginEventOccurred(loginEvent); - } - } else if (ae.getSource() == tempLoginBtn) { - if (loginListener != null) { - LoginEvent loginEvent = new LoginEvent(this, tempPass, ""); - loginListener.loginEventOccurred(loginEvent); - } - } else if (ae.getSource() == registerBtn) { - try { - URI uri = new URI("https://www.psychotechnology.com/register"); - Desktop dt = Desktop.getDesktop(); - dt.browse(uri); - } catch (IOException | URISyntaxException e1) { - e1.printStackTrace(); - } - } - } - - public void setLoginListener(LoginListener loginListener) { - this.loginListener = loginListener; - } - - public void setErrorMessage(String errorMsg) { - errorLbl.setText(errorMsg); - } - - public void setUserAndPassFields(String user, String pass) { - userTxt.setText(user); - passTxt.setText(pass); - } -} diff --git a/src/gui/login/LoginListener.java b/src/gui/login/LoginListener.java deleted file mode 100755 index 447c7d7..0000000 --- a/src/gui/login/LoginListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package gui.login; - -import java.util.EventListener; - -public interface LoginListener extends EventListener { - - public void loginEventOccurred(LoginEvent event); - - public void logoutEventOccurred(LogoutEvent event); -} diff --git a/src/gui/login/LoginPanel.java b/src/gui/login/LoginPanel.java deleted file mode 100755 index bb4189c..0000000 --- a/src/gui/login/LoginPanel.java +++ /dev/null @@ -1,22 +0,0 @@ -package gui.login; - -import java.awt.Graphics; -import java.awt.Image; - -import javax.swing.JPanel; - -@SuppressWarnings("serial") -public class LoginPanel extends JPanel { - - private Image image; - - public LoginPanel(Image image) { - this.image = image; - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.drawImage(image, 0, 0, getWidth(), getHeight(),this); - } -} diff --git a/src/gui/login/LogoutEvent.java b/src/gui/login/LogoutEvent.java deleted file mode 100755 index 3377de9..0000000 --- a/src/gui/login/LogoutEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package gui.login; - -import java.util.EventObject; - -@SuppressWarnings("serial") -public class LogoutEvent extends EventObject { - - public LogoutEvent(Object source) { - super(source); - } -} diff --git a/src/gui/premium/PremiumCheckerTask.java b/src/gui/premium/PremiumCheckerTask.java deleted file mode 100755 index 74d8b18..0000000 --- a/src/gui/premium/PremiumCheckerTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package gui.premium; - -import controller.UserController; - -public class PremiumCheckerTask extends Thread { - - private UserController userController; - private PremiumReminderDialog premiumReminderDialog; - private PremiumReminderTask premiumReminderTask; - private final int delay = 6; - - public PremiumCheckerTask(UserController userController) { - this.userController = userController; - premiumReminderTask = new PremiumReminderTask(); - } - - @Override - public void run() { - if (userController.isPremium()) { - userController.setUserPremium(true); - premiumReminderDialog.setVisible(false); - premiumReminderTask.interrupt(); - interrupt(); - } else { - try { - sleep(delay); - } catch (InterruptedException e) { - System.err.println("Premium check sleep failed"); - } - } - } - - public void runPremiumReminder() { - if (!premiumReminderTask.isAlive()) { - premiumReminderTask.start(); - } - } - - public void stopPremiumReminder() { - if (!premiumReminderTask.isInterrupted()) { - premiumReminderTask.interrupt(); - } - } - - public void showPopup() { - premiumReminderTask.showPopup(); - } -} diff --git a/src/gui/premium/PremiumReminderDialog.java b/src/gui/premium/PremiumReminderDialog.java deleted file mode 100755 index c40946a..0000000 --- a/src/gui/premium/PremiumReminderDialog.java +++ /dev/null @@ -1,138 +0,0 @@ -package gui.premium; - -import java.awt.Color; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JSeparator; -import javax.swing.SwingConstants; - -import gui.MainFrame; -import gui.component.OrderButton; -import gui.component.PictureLabel; -import gui.util.IconFetch; -import gui.util.SetScreenLocation; -import utility.FontPicker; - -@SuppressWarnings("serial") -public class PremiumReminderDialog extends JDialog { - - private JLabel title, subheading, description; - private PictureLabel logo, screen; - private OrderButton orderButton; - - public PremiumReminderDialog() { - initComponents(); - setupUI(); - - getContentPane().setBackground(Color.decode("#fefefe")); - setTitle(MainFrame.appName); - setIconImage(IconFetch.getInstance().getIcon("/images/icon.png").getImage()); - setPreferredSize(new Dimension(900, 700)); - setMinimumSize(new Dimension(800, 650)); - pack(); - SetScreenLocation.centerFrame(this); - setModal(true); - setResizable(false); - setVisible(false); - } - - private void initComponents() { - logo = new PictureLabel(IconFetch.getInstance().getIcon("/images/logo-small.png")); - - title = new JLabel("Buy Subliminator Premium and Unlock up to 5 Messages", SwingConstants.CENTER); - title.setFont(FontPicker.getFont(FontPicker.latoRegular, 22.0f)); - - subheading = new JLabel("Subliminator Premium Benefits"); - subheading.setFont(FontPicker.getFont(FontPicker.latoRegular, 22.0f)); - subheading.setHorizontalAlignment(SwingConstants.CENTER); - - description = new JLabel("Select up to 5 subliminal messages to display
onto your screen at once. 5x the power: let
these messages enter your subconscious mind
while you surf the web."); - description.setFont(FontPicker.getFont(FontPicker.latoRegular, 16.0f)); - description.setHorizontalAlignment(SwingConstants.CENTER); - - screen = new PictureLabel(IconFetch.getInstance().getIcon("/images/screen-premium.png")); - - orderButton = new OrderButton("Subliminator Premium only £19.99"); - orderButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ae) { - try { - URI uri = new URI("https://www.psychotechnology.com/subliminator/premium"); - Desktop dt = Desktop.getDesktop(); - dt.browse(uri); - } catch (IOException | URISyntaxException e1) { - e1.printStackTrace(); - } - } - }); - } - - private void setupUI() { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gc = new GridBagConstraints(); - setLayout(gbl); - - gc.gridx = 0; - gc.gridy = 0; - gc.gridheight = 1; - gc.gridwidth = 3; - gc.weightx = 1; - gc.weighty = 1; - gc.insets = new Insets(40, 0, 0, 0); - gc.anchor = GridBagConstraints.NORTH; - gc.fill = GridBagConstraints.NONE; - add(logo, gc); - - gc.weighty++; - gc.insets = new Insets(75, 0, 0, 0); - gc.anchor = GridBagConstraints.CENTER; - gc.fill = GridBagConstraints.BOTH; - add(title, gc); - - gc.gridy++; - gc.gridwidth = 1; - gc.insets = new Insets(40, 40, 0, 0); - gc.anchor = GridBagConstraints.WEST; - gc.fill = GridBagConstraints.NONE; - add(screen, gc); - - gc.gridwidth = 1; - gc.gridx++; - gc.insets = new Insets(40, 30, 0, 0); - gc.anchor = GridBagConstraints.LINE_END; - gc.fill = GridBagConstraints.BOTH; - add(new JSeparator(SwingConstants.VERTICAL), gc); - - gc.gridx++; - gc.insets = new Insets(100, 0, 0, 50); - gc.anchor = GridBagConstraints.NORTHWEST; - gc.fill = GridBagConstraints.NONE; - add(subheading, gc); - - gc.insets = new Insets(40, 0, 0, 50); - gc.fill = GridBagConstraints.BOTH; - add(description, gc); - - gc.gridx = 0; - gc.gridy++; - gc.gridheight = 1; - gc.gridwidth = 3; - gc.weightx = 1; - gc.weighty = 1; - gc.insets = new Insets(40, 50, 50, 50); - gc.anchor = GridBagConstraints.CENTER; - gc.fill = GridBagConstraints.BOTH; - add(orderButton, gc); - } -} diff --git a/src/gui/premium/PremiumReminderTask.java b/src/gui/premium/PremiumReminderTask.java deleted file mode 100755 index f7900bd..0000000 --- a/src/gui/premium/PremiumReminderTask.java +++ /dev/null @@ -1,34 +0,0 @@ -package gui.premium; - -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -public class PremiumReminderTask extends Thread { - - private PremiumReminderDialog premiumReminderDialog; - private final int delay = 6; - - public PremiumReminderTask() { - premiumReminderDialog = new PremiumReminderDialog(); - - premiumReminderDialog.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent evt) { - premiumReminderDialog.setVisible(false); - } - }); - } - @Override - public void run() { - premiumReminderDialog.setVisible(true); - try { - sleep(delay); - } catch (InterruptedException e) { - System.err.println("Premium reminder sleep failed"); - } - } - - public void showPopup() { - premiumReminderDialog.setVisible(true); - } -} \ No newline at end of file diff --git a/src/gui/settings/ScreenMessage.java b/src/gui/settings/ScreenMessage.java index 313bcab..4083284 100755 --- a/src/gui/settings/ScreenMessage.java +++ b/src/gui/settings/ScreenMessage.java @@ -17,14 +17,12 @@ import javax.swing.JColorChooser; import javax.swing.JPanel; import javax.swing.JPopupMenu; -import javax.swing.WindowConstants; import constants.CustomColor; import gui.component.BlueGreyMenuItem; import gui.component.BlueGreyRadioItem; import gui.component.MessagePreview; import gui.component.MessageSwitch; -import gui.premium.PremiumReminderDialog; import gui.util.JFontChooser; import utility.FontPicker; @@ -75,34 +73,12 @@ private void initComponents() { messageSwitch.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (SettingsPanel.isUserPremium == false) { - - if (SettingsPanel.numMessagesSelected == 1) { - if (isActive()) { - switchMessageOff(); - SettingsPanel.numMessagesSelected--; - } else { - PremiumReminderDialog premiumReminderDialog = new PremiumReminderDialog(); - premiumReminderDialog.setVisible(true); - premiumReminderDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - } - } else if (SettingsPanel.numMessagesSelected == 0) { - if (isActive()) { - switchMessageOff(); - SettingsPanel.numMessagesSelected--; - } else { - switchMessageOn(); - SettingsPanel.numMessagesSelected++; - } - } - } else if (SettingsPanel.isUserPremium == true) { - if (isActive()) { - switchMessageOff(); - SettingsPanel.numMessagesSelected--; - } else { - switchMessageOn(); - SettingsPanel.numMessagesSelected++; - } + if (isActive()) { + switchMessageOff(); + SettingsPanel.numMessagesSelected--; + } else { + switchMessageOn(); + SettingsPanel.numMessagesSelected++; } } }); diff --git a/src/gui/subliminal/SubliminalFrame.java b/src/gui/subliminal/SubliminalFrame.java index 2e0e9f1..a422ab7 100755 --- a/src/gui/subliminal/SubliminalFrame.java +++ b/src/gui/subliminal/SubliminalFrame.java @@ -59,8 +59,6 @@ public void setMessage(Message message) { subliminalMessage.setActiveBackground(activeBackground); subliminalMessage.setBackgroundSelected(isBackgroundSelected); subliminalMessage.repaint(); - System.out.println(message); - System.out.println(); } @Override diff --git a/src/gui/util/SetScreenLocation.java b/src/gui/util/SetScreenLocation.java index b43d172..d2ce87e 100755 --- a/src/gui/util/SetScreenLocation.java +++ b/src/gui/util/SetScreenLocation.java @@ -1 +1 @@ -package gui.util; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; import javax.swing.JFrame; import gui.login.LoginFrame; public class SetScreenLocation { public static final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); /** * A general-purpose method to vertically and horizontally center a window. * http://stackoverflow.com/questions/144892/how-to-center-a-window-in-java */ public static void centerFrame(JFrame frame) { int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } public static void centerFrame(JDialog dialog) { int x = (int) ((screenSize.getWidth() - dialog.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - dialog.getHeight()) / 2); dialog.setLocation(x, y); } public static void centerFrame(LoginFrame loginFrame) { int x = (int) ((screenSize.getWidth() - loginFrame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - loginFrame.getHeight()) / 2); loginFrame.setLocation(x, y); } public static void center(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - message.getHeight()) / 2); message.setLocation(x, y); } public static void topLeft(JDialog message) { message.setLocation(0, 0); } public static void topRight(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth())); message.setLocation(x, 0); } public static void botLeft(JDialog message) { int y = (int) ((screenSize.getHeight() - message.getHeight())); message.setLocation(0, y); } public static void botRight(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth())); int y = (int) ((screenSize.getHeight() - message.getHeight())); message.setLocation(x, y); } } \ No newline at end of file +package gui.util; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; import javax.swing.JFrame; public class SetScreenLocation { public static final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); /** * A general-purpose method to vertically and horizontally center a window. * http://stackoverflow.com/questions/144892/how-to-center-a-window-in-java */ public static void centerFrame(JFrame frame) { int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } public static void centerFrame(JDialog dialog) { int x = (int) ((screenSize.getWidth() - dialog.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - dialog.getHeight()) / 2); dialog.setLocation(x, y); } public static void center(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - message.getHeight()) / 2); message.setLocation(x, y); } public static void topLeft(JDialog message) { message.setLocation(0, 0); } public static void topRight(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth())); message.setLocation(x, 0); } public static void botLeft(JDialog message) { int y = (int) ((screenSize.getHeight() - message.getHeight())); message.setLocation(0, y); } public static void botRight(JDialog message) { int x = (int) ((screenSize.getWidth() - message.getWidth())); int y = (int) ((screenSize.getHeight() - message.getHeight())); message.setLocation(x, y); } } \ No newline at end of file diff --git a/src/model/User.java b/src/model/User.java deleted file mode 100755 index 4931949..0000000 --- a/src/model/User.java +++ /dev/null @@ -1,68 +0,0 @@ -package model; - -public class User { - - private int id; - private String firstName; - private String lastName; - private String email; - private String password; - private boolean accountActive; - private boolean isUserPremium; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public boolean isAccountActive() { - return accountActive; - } - - public void setAccountActive(boolean accountActive) { - this.accountActive = accountActive; - } - - public boolean isUserPremium() { - return isUserPremium; - } - - public void setUserPremium(boolean isUserPremium) { - this.isUserPremium = isUserPremium; - } -} \ No newline at end of file