Merge branch 'develop' into f/finishing_new_UI
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -17,9 +17,9 @@ import envoy.client.ui.Startup;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class Main {
|
||||
public final class Main {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean debug = false;
|
||||
|
||||
/**
|
||||
* Starts the application.
|
||||
@ -29,7 +29,7 @@ public class Main {
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (DEBUG) {
|
||||
if (debug) {
|
||||
// Put testing code here
|
||||
System.out.println();
|
||||
System.exit(0);
|
||||
|
@ -3,10 +3,8 @@ package envoy.client.data;
|
||||
import static java.util.function.Function.identity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import envoy.data.Config;
|
||||
import envoy.data.ConfigItem;
|
||||
|
||||
/**
|
||||
* Implements a configuration specific to the Envoy Client with default values
|
||||
@ -19,7 +17,7 @@ import envoy.data.ConfigItem;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ClientConfig extends Config {
|
||||
public final class ClientConfig extends Config {
|
||||
|
||||
private static ClientConfig config;
|
||||
|
||||
@ -33,15 +31,13 @@ public class ClientConfig extends Config {
|
||||
}
|
||||
|
||||
private ClientConfig() {
|
||||
items.put("server", new ConfigItem<>("server", "s", identity(), null, true));
|
||||
items.put("port", new ConfigItem<>("port", "p", Integer::parseInt, null, true));
|
||||
items.put("localDB", new ConfigItem<>("localDB", "db", File::new, new File("localDB"), true));
|
||||
items.put("ignoreLocalDB", new ConfigItem<>("ignoreLocalDB", "nodb", Boolean::parseBoolean, false, false));
|
||||
items.put("homeDirectory", new ConfigItem<>("homeDirectory", "h", File::new, new File(System.getProperty("user.home"), ".envoy"), true));
|
||||
items.put("fileLevelBarrier", new ConfigItem<>("fileLevelBarrier", "fb", Level::parse, Level.OFF, true));
|
||||
items.put("consoleLevelBarrier", new ConfigItem<>("consoleLevelBarrier", "cb", Level::parse, Level.OFF, true));
|
||||
items.put("user", new ConfigItem<>("user", "u", identity()));
|
||||
items.put("password", new ConfigItem<>("password", "pw", identity()));
|
||||
super(".envoy");
|
||||
put("server", "s", identity());
|
||||
put("port", "p", Integer::parseInt);
|
||||
put("localDB", "db", File::new);
|
||||
put("ignoreLocalDB", "nodb", Boolean::parseBoolean);
|
||||
put("user", "u", identity());
|
||||
put("password", "pw", identity());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,24 +64,6 @@ public class ClientConfig extends Config {
|
||||
*/
|
||||
public Boolean isIgnoreLocalDB() { return (Boolean) items.get("ignoreLocalDB").get(); }
|
||||
|
||||
/**
|
||||
* @return the directory in which all local files are saves
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public File getHomeDirectory() { return (File) items.get("homeDirectory").get(); }
|
||||
|
||||
/**
|
||||
* @return the minimal {@link Level} to log inside the log file
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public Level getFileLevelBarrier() { return (Level) items.get("fileLevelBarrier").get(); }
|
||||
|
||||
/**
|
||||
* @return the minimal {@link Level} to log inside the console
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public Level getConsoleLevelBarrier() { return (Level) items.get("consoleLevelBarrier").get(); }
|
||||
|
||||
/**
|
||||
* @return the user name
|
||||
* @since Envoy Client v0.3-alpha
|
||||
|
@ -17,11 +17,11 @@ import envoy.event.GroupMessageStatusChange;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>GroupChat.java</strong><br>
|
||||
* Created: <strong>05.07.2020</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GroupChat extends Chat {
|
||||
public final class GroupChat extends Chat {
|
||||
|
||||
private final User sender;
|
||||
|
||||
@ -41,13 +41,10 @@ public class GroupChat extends Chat {
|
||||
public void read(WriteProxy writeProxy) throws IOException {
|
||||
for (int i = messages.size() - 1; i >= 0; --i) {
|
||||
final GroupMessage gmsg = (GroupMessage) messages.get(i);
|
||||
if (gmsg.getSenderID() != sender.getID()) {
|
||||
if (gmsg.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break;
|
||||
else {
|
||||
gmsg.getMemberStatuses().replace(sender.getID(), MessageStatus.READ);
|
||||
writeProxy
|
||||
.writeMessageStatusChange(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.READ, Instant.now(), sender.getID()));
|
||||
}
|
||||
if (gmsg.getSenderID() != sender.getID()) if (gmsg.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break;
|
||||
else {
|
||||
gmsg.getMemberStatuses().replace(sender.getID(), MessageStatus.READ);
|
||||
writeProxy.writeMessageStatusChange(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.READ, Instant.now(), sender.getID()));
|
||||
}
|
||||
}
|
||||
unreadAmount = 0;
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class Settings {
|
||||
public final class Settings {
|
||||
|
||||
// Actual settings accessible by the rest of the application
|
||||
private Map<String, SettingsItem<?>> items;
|
||||
@ -139,7 +139,9 @@ public class Settings {
|
||||
* before
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public void setDownloadSavedWithoutAsking(boolean autosaveDownload) { ((SettingsItem<Boolean>) items.get("autoSaveDownloads")).set(autosaveDownload); }
|
||||
public void setDownloadSavedWithoutAsking(boolean autosaveDownload) {
|
||||
((SettingsItem<Boolean>) items.get("autoSaveDownloads")).set(autosaveDownload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path where downloads should be saved
|
||||
|
@ -17,7 +17,7 @@ import javax.swing.JComponent;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class SettingsItem<T> implements Serializable {
|
||||
public final class SettingsItem<T> implements Serializable {
|
||||
|
||||
private T value;
|
||||
private String userFriendlyName, description;
|
||||
|
@ -24,7 +24,7 @@ import java.util.function.Supplier;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class SystemCommand implements OnCall {
|
||||
public final class SystemCommand implements OnCall {
|
||||
|
||||
protected int relevance;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.Consumer;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class SystemCommandBuilder {
|
||||
public final class SystemCommandBuilder {
|
||||
|
||||
private int numberOfArguments;
|
||||
private Consumer<List<String>> action;
|
||||
|
@ -11,7 +11,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class MessageCreationEvent extends Event<Message> {
|
||||
public final class MessageCreationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class MessageModificationEvent extends Event<Message> {
|
||||
public final class MessageModificationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import envoy.event.Event;
|
||||
* @author: Maximilian Käfer
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class SendEvent extends Event<Event<?>> {
|
||||
public final class SendEvent extends Event<Event<?>> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class ThemeChangeEvent extends Event<String> {
|
||||
public final class ThemeChangeEvent extends Event<String> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-alpha
|
||||
*/
|
||||
public class Client implements Closeable {
|
||||
public final class Client implements Closeable {
|
||||
|
||||
// Connection handling
|
||||
private Socket socket;
|
||||
@ -164,6 +164,13 @@ public class Client implements Closeable {
|
||||
// Process ProfilePicChanges
|
||||
receiver.registerProcessor(ProfilePicChange.class, eventBus::dispatch);
|
||||
|
||||
// Process requests to not send any more attachments as they will not be shown to
|
||||
// other users
|
||||
receiver.registerProcessor(NoAttachments.class, eventBus::dispatch);
|
||||
|
||||
// Process group creation results - they might have been disabled on the server
|
||||
receiver.registerProcessor(GroupCreationResult.class, eventBus::dispatch);
|
||||
|
||||
// Send event
|
||||
eventBus.register(SendEvent.class, evt -> {
|
||||
try {
|
||||
|
@ -12,14 +12,14 @@ import envoy.util.EnvoyLog;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>GroupMessageStatusChangePocessor.java</strong><br>
|
||||
* Created: <strong>03.07.2020</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GroupMessageStatusChangeProcessor implements Consumer<GroupMessageStatusChange> {
|
||||
public final class GroupMessageStatusChangeProcessor implements Consumer<GroupMessageStatusChange> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(GroupMessageStatusChangeProcessor.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(GroupMessageStatusChange evt) {
|
||||
if (evt.get().ordinal() < MessageStatus.RECEIVED.ordinal()) logger.warning("Received invalid group message status change " + evt);
|
||||
|
@ -16,7 +16,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class MessageStatusChangeProcessor implements Consumer<MessageStatusChange> {
|
||||
public final class MessageStatusChangeProcessor implements Consumer<MessageStatusChange> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(MessageStatusChangeProcessor.class);
|
||||
|
||||
|
@ -13,11 +13,11 @@ import envoy.util.EnvoyLog;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>ReceivedGroupMessageProcessor.java</strong><br>
|
||||
* Created: <strong>13.06.2020</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ReceivedGroupMessageProcessor implements Consumer<GroupMessage> {
|
||||
public final class ReceivedGroupMessageProcessor implements Consumer<GroupMessage> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(ReceivedGroupMessageProcessor.class);
|
||||
|
||||
|
@ -15,7 +15,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
public final class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
|
||||
@Override
|
||||
public void accept(Message message) {
|
||||
|
@ -22,7 +22,9 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class Receiver extends Thread {
|
||||
public final class Receiver extends Thread {
|
||||
|
||||
private boolean isAlive = true;
|
||||
|
||||
private final InputStream in;
|
||||
private final Map<Class<?>, Consumer<?>> processors = new HashMap<>();
|
||||
@ -49,7 +51,7 @@ public class Receiver extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
while (isAlive)
|
||||
try {
|
||||
// Read object length
|
||||
final byte[] lenBytes = new byte[4];
|
||||
@ -64,6 +66,12 @@ public class Receiver extends Thread {
|
||||
|
||||
// Catch LV encoding errors
|
||||
if (len != bytesRead) {
|
||||
// Server has stopped sending, i.e. because he went offline
|
||||
if (bytesRead == -1) {
|
||||
isAlive = false;
|
||||
logger.log(Level.INFO, "Lost connection to the server. Exiting receiver...");
|
||||
continue;
|
||||
}
|
||||
logger.log(Level.WARNING,
|
||||
String.format("LV encoding violated: expected %d bytes, received %d bytes. Discarding object...", len, bytesRead));
|
||||
continue;
|
||||
@ -87,7 +95,6 @@ public class Receiver extends Thread {
|
||||
} catch (final Exception e) {
|
||||
logger.log(Level.SEVERE, "Error on receiver thread", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,7 +109,7 @@ public class Receiver extends Thread {
|
||||
|
||||
/**
|
||||
* Adds a map of object processors to this {@link Receiver}.
|
||||
*
|
||||
*
|
||||
* @param processors the processors to add the processors to add
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class WriteProxy {
|
||||
public final class WriteProxy {
|
||||
|
||||
private final Client client;
|
||||
private final LocalDB localDB;
|
||||
@ -68,9 +68,7 @@ public class WriteProxy {
|
||||
*
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public void flushCache() {
|
||||
localDB.getCacheMap().getMap().values().forEach(Cache::relay);
|
||||
}
|
||||
public void flushCache() { localDB.getCacheMap().getMap().values().forEach(Cache::relay); }
|
||||
|
||||
/**
|
||||
* Delivers a message to the server if online. Otherwise the message is cached
|
||||
|
@ -22,7 +22,7 @@ import javafx.scene.layout.GridPane;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ClearableTextField extends GridPane {
|
||||
public final class ClearableTextField extends GridPane {
|
||||
|
||||
private final TextField textField;
|
||||
|
||||
@ -88,82 +88,82 @@ public class ClearableTextField extends GridPane {
|
||||
* @see javafx.scene.control.TextInputControl#promptTextProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final StringProperty promptTextProperty() { return textField.promptTextProperty(); }
|
||||
public StringProperty promptTextProperty() { return textField.promptTextProperty(); }
|
||||
|
||||
/**
|
||||
* @return the current prompt text
|
||||
* @see javafx.scene.control.TextInputControl#getPromptText()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final String getPromptText() { return textField.getPromptText(); }
|
||||
public String getPromptText() { return textField.getPromptText(); }
|
||||
|
||||
/**
|
||||
* @param value the prompt text to display
|
||||
* @see javafx.scene.control.TextInputControl#setPromptText(java.lang.String)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setPromptText(String value) { textField.setPromptText(value); }
|
||||
public void setPromptText(String value) { textField.setPromptText(value); }
|
||||
|
||||
/**
|
||||
* @return the current property of the tooltip
|
||||
* @see javafx.scene.control.Control#tooltipProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ObjectProperty<Tooltip> tooltipProperty() { return textField.tooltipProperty(); }
|
||||
public ObjectProperty<Tooltip> tooltipProperty() { return textField.tooltipProperty(); }
|
||||
|
||||
/**
|
||||
* @param value the new tooltip
|
||||
* @see javafx.scene.control.Control#setTooltip(javafx.scene.control.Tooltip)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setTooltip(Tooltip value) { textField.setTooltip(value); }
|
||||
public void setTooltip(Tooltip value) { textField.setTooltip(value); }
|
||||
|
||||
/**
|
||||
* @return the current tooltip
|
||||
* @see javafx.scene.control.Control#getTooltip()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final Tooltip getTooltip() { return textField.getTooltip(); }
|
||||
public Tooltip getTooltip() { return textField.getTooltip(); }
|
||||
|
||||
/**
|
||||
* @return the current property of the context menu
|
||||
* @see javafx.scene.control.Control#contextMenuProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ObjectProperty<ContextMenu> contextMenuProperty() { return textField.contextMenuProperty(); }
|
||||
public ObjectProperty<ContextMenu> contextMenuProperty() { return textField.contextMenuProperty(); }
|
||||
|
||||
/**
|
||||
* @param value the new context menu
|
||||
* @see javafx.scene.control.Control#setContextMenu(javafx.scene.control.ContextMenu)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setContextMenu(ContextMenu value) { textField.setContextMenu(value); }
|
||||
public void setContextMenu(ContextMenu value) { textField.setContextMenu(value); }
|
||||
|
||||
/**
|
||||
* @return the current context menu
|
||||
* @see javafx.scene.control.Control#getContextMenu()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ContextMenu getContextMenu() { return textField.getContextMenu(); }
|
||||
public ContextMenu getContextMenu() { return textField.getContextMenu(); }
|
||||
|
||||
/**
|
||||
* @param value whether this ClearableTextField should be editable
|
||||
* @see javafx.scene.control.TextInputControl#setEditable(boolean)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setEditable(boolean value) { textField.setEditable(value); }
|
||||
public void setEditable(boolean value) { textField.setEditable(value); }
|
||||
|
||||
/**
|
||||
* @return the current property whether this ClearableTextField is editable
|
||||
* @see javafx.scene.control.TextInputControl#editableProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final BooleanProperty editableProperty() { return textField.editableProperty(); }
|
||||
public BooleanProperty editableProperty() { return textField.editableProperty(); }
|
||||
|
||||
/**
|
||||
* @return whether this {@code ClearableTextField} is editable
|
||||
* @see javafx.scene.control.TextInputControl#isEditable()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final boolean isEditable() { return textField.isEditable(); }
|
||||
public boolean isEditable() { return textField.isEditable(); }
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class IconUtil {
|
||||
public final class IconUtil {
|
||||
|
||||
private IconUtil() {}
|
||||
|
||||
@ -160,7 +160,7 @@ public class IconUtil {
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
image = ImageIO.read(IconUtil.class.getResource(path));
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
EnvoyLog.getLogger(IconUtil.class).log(Level.WARNING, String.format("Could not load image at path %s: ", path), e);
|
||||
}
|
||||
return image;
|
||||
|
@ -2,7 +2,6 @@ package envoy.client.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -19,7 +18,6 @@ import envoy.data.GroupMessage;
|
||||
import envoy.data.Message;
|
||||
import envoy.event.GroupMessageStatusChange;
|
||||
import envoy.event.MessageStatusChange;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
/**
|
||||
@ -57,30 +55,13 @@ public final class Startup extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
try {
|
||||
// Load the configuration from client.properties first
|
||||
final Properties properties = new Properties();
|
||||
properties.load(Startup.class.getClassLoader().getResourceAsStream("client.properties"));
|
||||
config.load(properties);
|
||||
|
||||
// Override configuration values with command line arguments
|
||||
final String[] args = getParameters().getRaw().toArray(new String[0]);
|
||||
if (args.length > 0) config.load(args);
|
||||
|
||||
// Check if all mandatory configuration values have been initialized
|
||||
if (!config.isInitialized()) throw new EnvoyException("Configuration is not fully initialized");
|
||||
} catch (final Exception e) {
|
||||
config.loadAll(Startup.class, "client.properties", getParameters().getRaw().toArray(new String[0]));
|
||||
EnvoyLog.initialize(config);
|
||||
} catch (final IllegalStateException e) {
|
||||
new Alert(AlertType.ERROR, "Error loading configuration values:\n" + e);
|
||||
logger.log(Level.SEVERE, "Error loading configuration values: ", e);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Setup logger for the envoy package
|
||||
EnvoyLog.initialize(config);
|
||||
EnvoyLog.attach("envoy");
|
||||
EnvoyLog.setFileLevelBarrier(config.getFileLevelBarrier());
|
||||
EnvoyLog.setConsoleLevelBarrier(config.getConsoleLevelBarrier());
|
||||
|
||||
logger.log(Level.INFO, "Envoy starting...");
|
||||
|
||||
// Initialize the local database
|
||||
|
@ -18,7 +18,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class StatusTrayIcon {
|
||||
public final class StatusTrayIcon {
|
||||
|
||||
/**
|
||||
* The {@link TrayIcon} provided by the System Tray API for controlling the
|
||||
@ -85,12 +85,12 @@ public class StatusTrayIcon {
|
||||
public void show() {
|
||||
try {
|
||||
SystemTray.getSystemTray().add(trayIcon);
|
||||
} catch (AWTException e) {}
|
||||
} catch (final AWTException e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the icon from the system tray.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public void hide() { SystemTray.getSystemTray().remove(trayIcon); }
|
||||
|
@ -87,6 +87,12 @@ public final class ChatScene implements Restorable {
|
||||
@FXML
|
||||
private Button settingsButton;
|
||||
|
||||
@FXML
|
||||
private Button messageSearchButton;
|
||||
|
||||
@FXML
|
||||
private Button newGroupButton;
|
||||
|
||||
@FXML
|
||||
private TextArea messageTextArea;
|
||||
|
||||
@ -108,9 +114,6 @@ public final class ChatScene implements Restorable {
|
||||
@FXML
|
||||
private Label topBarStatusLabel;
|
||||
|
||||
@FXML
|
||||
private Button messageSearchButton;
|
||||
|
||||
@FXML
|
||||
private ImageView clientProfilePic;
|
||||
|
||||
@ -141,7 +144,7 @@ public final class ChatScene implements Restorable {
|
||||
private AudioRecorder recorder;
|
||||
private boolean recording;
|
||||
private Attachment pendingAttachment;
|
||||
private boolean postingPermanentlyDisabled;
|
||||
private boolean postingPermanentlyDisabled;
|
||||
|
||||
private final SystemCommandsMap messageTextAreaCommands = new SystemCommandsMap();
|
||||
|
||||
@ -265,6 +268,21 @@ public final class ChatScene implements Restorable {
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Disable attachment button if server says attachments will be filtered out
|
||||
eventBus.register(NoAttachments.class, e -> {
|
||||
Platform.runLater(() -> {
|
||||
attachmentButton.setDisable(true);
|
||||
voiceButton.setDisable(true);
|
||||
final var alert = new Alert(AlertType.ERROR);
|
||||
alert.setTitle("No attachments possible");
|
||||
alert.setHeaderText("Your current server does not support attachments.");
|
||||
alert.setContentText("If this is unplanned, please contact your server administrator.");
|
||||
alert.showAndWait();
|
||||
});
|
||||
});
|
||||
|
||||
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); }));
|
||||
}
|
||||
|
||||
private AnchorPane createOfflineNote() {
|
||||
|
@ -18,7 +18,7 @@ import envoy.client.ui.settings.*;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class SettingsScene {
|
||||
public final class SettingsScene {
|
||||
|
||||
@FXML
|
||||
private ListView<SettingsPane> settingsList;
|
||||
@ -36,12 +36,10 @@ public class SettingsScene {
|
||||
*/
|
||||
public void initializeData(SceneContext sceneContext, Client client) {
|
||||
this.sceneContext = sceneContext;
|
||||
final var user = client.getSender();
|
||||
final var online = client.isOnline();
|
||||
settingsList.getItems().add(new GeneralSettingsPane());
|
||||
settingsList.getItems().add(new UserSettingsPane(sceneContext, user, online));
|
||||
settingsList.getItems().add(new UserSettingsPane(sceneContext, client.getSender(), client.isOnline()));
|
||||
settingsList.getItems().add(new DownloadSettingsPane(sceneContext));
|
||||
settingsList.getItems().add(new BugReportPane( user, online));
|
||||
settingsList.getItems().add(new BugReportPane(client.getSender(), client.isOnline()));
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -23,7 +23,7 @@ import envoy.data.Group;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ChatControl extends HBox {
|
||||
public final class ChatControl extends HBox {
|
||||
|
||||
/**
|
||||
* @param chat the chat to display
|
||||
@ -36,7 +36,7 @@ public class ChatControl extends HBox {
|
||||
ImageView contactProfilePic;
|
||||
if (chat.getRecipient() instanceof Group) contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("group_icon", 32));
|
||||
else contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
|
||||
Rectangle clip = new Rectangle();
|
||||
final var clip = new Rectangle();
|
||||
clip.setWidth(32);
|
||||
clip.setHeight(32);
|
||||
clip.setArcHeight(32);
|
||||
@ -44,7 +44,7 @@ public class ChatControl extends HBox {
|
||||
contactProfilePic.setClip(clip);
|
||||
getChildren().add(contactProfilePic);
|
||||
// spacing
|
||||
Region leftSpacing = new Region();
|
||||
final var leftSpacing = new Region();
|
||||
leftSpacing.setPrefSize(8, 0);
|
||||
leftSpacing.setMinSize(8, 0);
|
||||
leftSpacing.setMaxSize(8, 0);
|
||||
|
@ -18,7 +18,7 @@ import envoy.data.User;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class ContactControl extends VBox {
|
||||
public final class ContactControl extends VBox {
|
||||
|
||||
/**
|
||||
* @param contact the contact to display
|
||||
|
@ -24,7 +24,6 @@ import envoy.client.data.Settings;
|
||||
import envoy.client.ui.AudioControl;
|
||||
import envoy.client.ui.IconUtil;
|
||||
import envoy.client.ui.SceneContext;
|
||||
|
||||
import envoy.data.GroupMessage;
|
||||
import envoy.data.Message;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
@ -42,7 +41,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class MessageControl extends Label {
|
||||
public final class MessageControl extends Label {
|
||||
|
||||
private boolean ownMessage;
|
||||
|
||||
@ -179,7 +178,7 @@ public class MessageControl extends Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param localDB the localDB used by the current user
|
||||
* @param localDB the localDB used by the current user
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public static void setLocalDB(LocalDB localDB) { MessageControl.localDB = localDB; }
|
||||
|
@ -5,6 +5,7 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.input.InputEvent;
|
||||
|
||||
import envoy.client.event.SendEvent;
|
||||
import envoy.client.util.IssueUtil;
|
||||
import envoy.data.User;
|
||||
import envoy.event.EventBus;
|
||||
import envoy.event.IssueProposal;
|
||||
@ -20,7 +21,7 @@ import envoy.event.IssueProposal;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
public final class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
|
||||
private final Label titleLabel = new Label("Suggest a title for the bug:");
|
||||
private final TextField titleTextField = new TextField();
|
||||
@ -41,7 +42,7 @@ public class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
public BugReportPane(User user, boolean online) {
|
||||
super("Report a bug", online);
|
||||
setSpacing(10);
|
||||
setToolTipText("A bug can only be reported when being online");
|
||||
setToolTipText("A bug can only be reported while being online");
|
||||
|
||||
// Displaying the label to ask for a title
|
||||
titleLabel.setWrapText(true);
|
||||
@ -68,8 +69,9 @@ public class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
submitReportButton.setDisable(true);
|
||||
submitReportButton.setOnAction(e -> {
|
||||
EventBus.getInstance()
|
||||
.dispatch(new SendEvent(new IssueProposal(titleTextField.getText(), errorDetailArea.getText(),
|
||||
showUsernameInBugReport.isSelected() ? user.getName() : null, true)));
|
||||
.dispatch(new SendEvent(new IssueProposal(titleTextField.getText(),
|
||||
IssueUtil.sanitizeIssueDescription(errorDetailArea.getText(), showUsernameInBugReport.isSelected() ? user.getName() : null),
|
||||
true)));
|
||||
});
|
||||
getChildren().add(submitReportButton);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import envoy.client.ui.SceneContext;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class DownloadSettingsPane extends SettingsPane {
|
||||
public final class DownloadSettingsPane extends SettingsPane {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code DownloadSettingsPane}.
|
||||
|
@ -16,7 +16,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GeneralSettingsPane extends SettingsPane {
|
||||
public final class GeneralSettingsPane extends SettingsPane {
|
||||
|
||||
/**
|
||||
* @since Envoy Client v0.1-beta
|
||||
|
@ -16,14 +16,14 @@ import javafx.scene.paint.Color;
|
||||
* <p>
|
||||
* Project: <strong>client</strong><br>
|
||||
* File: <strong>OnlyIfOnlineSettingsPane.java</strong><br>
|
||||
* Created: <strong>Aug 4, 2020</strong><br>
|
||||
* Created: <strong>04.08.2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public abstract class OnlyIfOnlineSettingsPane extends SettingsPane {
|
||||
|
||||
private final Tooltip beOnlineReminder = new Tooltip("You need to be online to modify your acount.");
|
||||
private final Tooltip beOnlineReminder = new Tooltip("You need to be online to modify your account.");
|
||||
|
||||
/**
|
||||
* @param title
|
||||
@ -32,11 +32,9 @@ public abstract class OnlyIfOnlineSettingsPane extends SettingsPane {
|
||||
protected OnlyIfOnlineSettingsPane(String title, boolean online) {
|
||||
super(title);
|
||||
|
||||
final var offline = !online;
|
||||
setDisable(!online);
|
||||
|
||||
setDisable(offline);
|
||||
|
||||
if (offline) {
|
||||
if (!online) {
|
||||
final var infoLabel = new Label("You shall not pass!\n(... Unless you would happen to be online)");
|
||||
infoLabel.setId("infoLabel-warning");
|
||||
infoLabel.setWrapText(true);
|
||||
|
@ -35,7 +35,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class UserSettingsPane extends OnlyIfOnlineSettingsPane {
|
||||
public final class UserSettingsPane extends OnlyIfOnlineSettingsPane {
|
||||
|
||||
private boolean profilePicChanged, usernameChanged, validPassword;
|
||||
private byte[] currentImageBytes;
|
||||
|
40
client/src/main/java/envoy/client/util/IssueUtil.java
Normal file
40
client/src/main/java/envoy/client/util/IssueUtil.java
Normal file
@ -0,0 +1,40 @@
|
||||
package envoy.client.util;
|
||||
|
||||
/**
|
||||
* Provides methods to handle outgoing issues.
|
||||
* <p>
|
||||
* Project: <strong>client</strong><br>
|
||||
* File: <strong>IssueUtil.java</strong><br>
|
||||
* Created: <strong>20.08.2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public final class IssueUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
private IssueUtil() {}
|
||||
|
||||
/**
|
||||
* Performs actions to ensure the description of an issue will be displayed as
|
||||
* intended by the user.
|
||||
*
|
||||
* @param rawDescription the description to sanitize
|
||||
* @param username the user who submitted the issue. Should be
|
||||
* {@code null} if he does not want to be named.
|
||||
* @return the sanitized description
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public static String sanitizeIssueDescription(String rawDescription, String username) {
|
||||
// Appending the submitter name, if this option was enabled
|
||||
rawDescription += username != null
|
||||
? (rawDescription.endsWith("\n") || rawDescription.endsWith("<br>") ? "" : "<br>") + String.format("Submitted by user %s.", username)
|
||||
: "";
|
||||
// Markdown does not support "normal" line breaks. It uses "<br>"
|
||||
rawDescription = rawDescription.replaceAll(System.getProperty("line.separator", "\r?\n"), "<br>");
|
||||
return rawDescription;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ import javafx.scene.Node;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class ReflectionUtil {
|
||||
public final class ReflectionUtil {
|
||||
|
||||
private ReflectionUtil() {}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
server=localhost
|
||||
port=8080
|
||||
localDB=localDB
|
||||
consoleLevelBarrier=FINER
|
||||
server=localhost
|
||||
port=8080
|
||||
localDB=localDB
|
||||
consoleLevelBarrier=FINER
|
||||
fileLevelBarrier=OFF
|
||||
ignoreLocalDB=false
|
||||
|
@ -113,8 +113,71 @@
|
||||
<GridPane.margin>
|
||||
<Insets right="1.0" />
|
||||
</GridPane.margin>
|
||||
<<<<<<< HEAD
|
||||
</TabPane>
|
||||
<HBox id="top-bar" alignment="CENTER_LEFT" prefHeight="100.0">
|
||||
=======
|
||||
<children>
|
||||
<VBox id="search-panel" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="80.0" prefWidth="316.0">
|
||||
<children>
|
||||
<Label id="contact-search-enter-container" maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="325.0">
|
||||
<graphic>
|
||||
<TextArea id="contactSearchInput" fx:id="contactSearch" focusTraversable="false" maxHeight="30.0" minHeight="30.0" onInputMethodTextChanged="#searchContacts" onKeyTyped="#searchContacts" prefHeight="30.0" prefWidth="200.0" promptText="Search Contacts">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
<padding>
|
||||
<Insets left="12.0" right="12.0" />
|
||||
</padding>
|
||||
</TextArea>
|
||||
</graphic>
|
||||
<VBox.margin>
|
||||
<Insets left="10.0" right="10.0" top="3.0" />
|
||||
</VBox.margin>
|
||||
</Label>
|
||||
<HBox id="underline" alignment="TOP_CENTER" prefHeight="41.0" prefWidth="296.0" spacing="5.0">
|
||||
<children>
|
||||
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" prefWidth="100.0" text=" Add Contact">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<Button fx:id="newGroupButton" mnemonicParsing="false" prefWidth="100.0" text="New Group">
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></Button>
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets left="10.0" right="10.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets top="3.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
<ListView id="chatList" fx:id="chatList" focusTraversable="false" onMouseClicked="#chatListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
|
||||
<contextMenu>
|
||||
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
|
||||
<items>
|
||||
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" onAction="#deleteContact" text="Delete" />
|
||||
</items>
|
||||
</ContextMenu>
|
||||
</contextMenu>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="2.0" top="5.0" />
|
||||
</padding>
|
||||
</ListView>
|
||||
</children>
|
||||
</VBox>
|
||||
<HBox id="topBar" alignment="CENTER_LEFT" prefHeight="100.0">
|
||||
>>>>>>> refs/heads/develop
|
||||
<children>
|
||||
<ImageView id="profile-pic" fx:id="clientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true">
|
||||
<HBox.margin>
|
||||
|
Reference in New Issue
Block a user