Defined theme specific icon folders, renamed icon loading method
@ -25,7 +25,7 @@ import envoy.util.SerializationUtils;
|
||||
public class Settings {
|
||||
|
||||
// Actual settings accessible by the rest of the application
|
||||
private Map<String, SettingsItem<?>> items;
|
||||
private Map<String, SettingsItem<?>> items;
|
||||
|
||||
/**
|
||||
* Settings are stored in this file.
|
||||
@ -93,6 +93,15 @@ public class Settings {
|
||||
*/
|
||||
public void setCurrentTheme(String themeName) { ((SettingsItem<String>) items.get("currentTheme")).set(themeName); }
|
||||
|
||||
/**
|
||||
* @return true if the currently used theme is one of the default themes
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public boolean isUsingDefaultTheme() {
|
||||
final var theme = getCurrentTheme();
|
||||
return theme.equals("dark") || theme.equals("light");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true}, if pressing the {@code Enter} key suffices to send a
|
||||
* message. Otherwise it has to be pressed in conjunction with the
|
||||
|
@ -47,7 +47,7 @@ public class ClearableTextField extends GridPane {
|
||||
public ClearableTextField(String text, int size) {
|
||||
// initializing the textField and the button
|
||||
textField = new TextField(text);
|
||||
clearButton = new Button("", new ImageView(IconUtil.loadDefaultThemeSensitive("clear_button_", size)));
|
||||
clearButton = new Button("", new ImageView(IconUtil.loadIconThemeSensitive("clear_button", size)));
|
||||
clearButton.setOnAction(e -> textField.clear());
|
||||
clearButton.setFocusTraversable(false);
|
||||
clearButton.getStyleClass().clear();
|
||||
|
@ -66,23 +66,23 @@ public class IconUtil {
|
||||
* folder and scales it to 16px.<br>
|
||||
* The suffix {@code .png} is automatically appended.
|
||||
*
|
||||
* @param name the image name without the .png - suffix
|
||||
* @param name the image name without the .png suffix
|
||||
* @return the loaded image
|
||||
* @since Envoy Client v0.1-beta
|
||||
* @apiNote let's take a sample image {@code abc.png} in the folder
|
||||
* {@code /icons/}.
|
||||
* <br>
|
||||
* To do that, we only have to call
|
||||
* {@code IconUtil.loadDefault("abc")}
|
||||
* {@code IconUtil.loadIcon("abc")}
|
||||
*/
|
||||
public static Image loadDefault(String name) { return load("/icons/" + name + ".png"); }
|
||||
public static Image loadIcon(String name) { return load("/icons/" + name + ".png"); }
|
||||
|
||||
/**
|
||||
* Loads a {@code .png} icon from the sub-folder {@code /icons/} of the resource
|
||||
* folder and scales it to a given size.<br>
|
||||
* The suffix {@code .png} is automatically appended.
|
||||
*
|
||||
* @param name the image name without the .png - suffix
|
||||
* @param name the image name without the .png suffix
|
||||
* @param size the size of the image to scale to
|
||||
* @return the loaded image
|
||||
* @since Envoy Client v0.1-beta
|
||||
@ -90,9 +90,9 @@ public class IconUtil {
|
||||
* {@code /icons/} and load it in size 16.
|
||||
* <br>
|
||||
* To do that, we only have to call
|
||||
* {@code IconUtil.loadDefault("abc", 16)}
|
||||
* {@code IconUtil.loadIcon("abc", 16)}
|
||||
*/
|
||||
public static Image loadDefault(String name, int size) { return load("/icons/" + name + ".png", size); }
|
||||
public static Image loadIcon(String name, int size) { return load("/icons/" + name + ".png", size); }
|
||||
|
||||
/**
|
||||
* Loads a {@code .png} icon whose design depends on the currently active theme
|
||||
@ -104,16 +104,16 @@ public class IconUtil {
|
||||
* The suffix {@code .png} is automatically appended.
|
||||
*
|
||||
* @param name the image name without the "black" or "white" suffix and without
|
||||
* the .png - suffix
|
||||
* the .png suffix
|
||||
* @return the loaded image
|
||||
* @since Envoy Client v0.1-beta
|
||||
* @apiNote let's take two sample images {@code abc_black.png} and
|
||||
* {@code abc_white.png} in the folder {@code /icons/} and load them.
|
||||
* <br>
|
||||
* To do that theme sensitve, we only have to call
|
||||
* {@code IconUtil.loadDefaultThemeSensitive("abc_")}
|
||||
* {@code IconUtil.loadIconThemeSensitive("abc_")}
|
||||
*/
|
||||
public static Image loadDefaultThemeSensitive(String name) { return loadDefault(name + themeSpecificSuffix()); }
|
||||
public static Image loadIconThemeSensitive(String name) { return loadIcon(themeSpecificSubFolder() + name); }
|
||||
|
||||
/**
|
||||
* Loads a {@code .png} icon whose design depends on the currently active theme
|
||||
@ -125,7 +125,7 @@ public class IconUtil {
|
||||
* <p>
|
||||
* The suffix {@code .png} is automatically appended.
|
||||
*
|
||||
* @param name the image name without the .png - suffix
|
||||
* @param name the image name without the .png suffix
|
||||
* @param size the size of the image to scale to
|
||||
* @return the loaded image
|
||||
* @since Envoy Client v0.1-beta
|
||||
@ -134,9 +134,9 @@ public class IconUtil {
|
||||
* size 16.
|
||||
* <br>
|
||||
* To do that theme sensitve, we only have to call
|
||||
* {@code IconUtil.loadDefaultThemeSensitive("abc_", 16)}
|
||||
* {@code IconUtil.loadIconThemeSensitive("abc_", 16)}
|
||||
*/
|
||||
public static Image loadDefaultThemeSensitive(String name, int size) { return loadDefault(name + themeSpecificSuffix(), size); }
|
||||
public static Image loadIconThemeSensitive(String name, int size) { return loadIcon(themeSpecificSubFolder() + name, size); }
|
||||
|
||||
/**
|
||||
*
|
||||
@ -163,11 +163,13 @@ public class IconUtil {
|
||||
/**
|
||||
* This method should be called if the display of an icon depends upon the
|
||||
* currently active theme.<br>
|
||||
* In case of the dark theme, the suffix {@code "white"} will be appended, else
|
||||
* the suffix {@code "black"} will be appended.
|
||||
* In case of a default theme, the string returned will be
|
||||
* returned ({@code dark/} or {@code light/}), else it will be empty.
|
||||
*
|
||||
* @return the theme specific suffix
|
||||
* @return the theme specific folder
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public static String themeSpecificSuffix() { return Settings.getInstance().getCurrentTheme().equals("dark") ? "white" : "black"; }
|
||||
public static String themeSpecificSubFolder() {
|
||||
return Settings.getInstance().isUsingDefaultTheme() ? Settings.getInstance().getCurrentTheme() + "/" : "";
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public final class Startup extends Application {
|
||||
messageStatusCache = new Cache<>();
|
||||
|
||||
stage.setTitle("Envoy");
|
||||
stage.getIcons().add(IconUtil.loadDefault("envoy_logo"));
|
||||
stage.getIcons().add(IconUtil.loadIcon("envoy_logo"));
|
||||
|
||||
final var sceneContext = new SceneContext(stage);
|
||||
sceneContext.load(SceneInfo.LOGIN_SCENE);
|
||||
|
@ -110,8 +110,8 @@ public final class ChatScene implements Restorable {
|
||||
messageList.setCellFactory(MessageListCellFactory::new);
|
||||
userList.setCellFactory(ContactListCellFactory::new);
|
||||
|
||||
settingsButton.setGraphic(new ImageView(IconUtil.loadDefault("settings", 16)));
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefaultThemeSensitive("", 24)));
|
||||
settingsButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("settings", 16)));
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", 20)));
|
||||
|
||||
// Listen to received messages
|
||||
eventBus.register(MessageCreationEvent.class, e -> {
|
||||
@ -265,17 +265,17 @@ public final class ChatScene implements Restorable {
|
||||
recording = true;
|
||||
Platform.runLater(() -> {
|
||||
voiceButton.setText("Recording");
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefault("microphone_recording", 24)));
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadIcon("microphone_recording", 24)));
|
||||
});
|
||||
recorder.start();
|
||||
} else {
|
||||
pendingAttachment = new Attachment(recorder.finish(), AttachmentType.VOICE);
|
||||
recording = false;
|
||||
Platform.runLater(() -> {
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefaultThemeSensitive("microphone_", 24)));
|
||||
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", 20)));
|
||||
voiceButton.setText(null);
|
||||
checkPostConditions(false);
|
||||
attachmentView.setImage(IconUtil.loadDefaultThemeSensitive("attachment_present_", 20));
|
||||
attachmentView.setImage(IconUtil.loadIconThemeSensitive("attachment_present", 20));
|
||||
attachmentView.setVisible(true);
|
||||
});
|
||||
}
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 28 KiB |