Fixed errors caused by preparing the merge into develop

This commit is contained in:
Kai S. K. Engelbart 2019-12-20 12:36:53 +01:00
parent e8d15be940
commit 02baf70d92
3 changed files with 12 additions and 22 deletions

View File

@ -170,7 +170,7 @@ public class ChatWindow extends JFrame {
settingsButton.addActionListener((evt) -> {
try {
new SettingsScreen().setVisible(true);
changeChatWindowColors(Settings.getInstance().getCurrentTheme());
changeChatWindowColors(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()));
} catch (Exception e) {
logger.log(Level.WARNING, "An error occured while opening the settings screen", e);
e.printStackTrace();

View File

@ -64,17 +64,10 @@ public class SettingsScreen extends JDialog {
private static int space = 5;
private Theme temporaryTheme;
private Theme temporaryTheme, selectedTheme;
private static final Logger logger = EnvoyLog.getLogger(SettingsScreen.class.getSimpleName());
private static SettingsScreen settingsScreen;
// TODO: Add a JPanel with all the Information necessary:
// change (Picture,Username, Email, Password) and toggle(light/dark mode,
// "ctrl+enter"/"enter"
// to send a message directly)
/**
* Builds the settings screen.
*

View File

@ -2,6 +2,7 @@ package envoy.client.ui;
import java.awt.EventQueue;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
@ -10,9 +11,7 @@ import javax.swing.JOptionPane;
import envoy.client.Client;
import envoy.client.Config;
import envoy.client.LocalDB;
import envoy.client.Settings;
import envoy.client.util.EnvoyLog;
import envoy.exception.EnvoyException;
import envoy.schema.User;
@ -57,7 +56,7 @@ public class Startup {
logger.severe("User name is not set or empty. Exiting...");
System.exit(1);
}
// Initialize the local database
LocalDB localDB;
try {
@ -81,19 +80,18 @@ public class Startup {
// Try entering offline mode
localDB.loadUsers();
User clientUser = localDB.getUsers().get(userName);
if(clientUser == null)
throw new EnvoyException("Could not enter offline mode: user name unknown");
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser);
} catch(Exception e2) {
} catch (Exception e2) {
JOptionPane.showMessageDialog(null, e2.toString(), "Client error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
return;
}
}
// Set client user in local database
localDB.setUser(client.getSender());
// Initialize chats in local database
try {
localDB.initializeDBFile();
@ -105,13 +103,12 @@ public class Startup {
"Local DB error",
JOptionPane.WARNING_MESSAGE);
}
logger.info("Client user ID: " + client.getSender().getID());
// Save all users to the local database
if(client.isOnline())
localDB.setUsers(client.getUsers());
if (client.isOnline()) localDB.setUsers(client.getUsers());
EventQueue.invokeLater(() -> {
try {
ChatWindow chatWindow = new ChatWindow(client, localDB);
@ -119,7 +116,7 @@ public class Startup {
try {
new StatusTrayIcon(chatWindow).show();
// If the tray icon is supported, hide the chat window on close
chatWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
} catch (EnvoyException e) {